This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lift -Werror checks into local functions
ClosedPublic

Authored by ashermancinelli on Apr 25 2021, 10:30 AM.

Details

Summary

Lift checks for -Werror into local functions.

Diff Detail

Event Timeline

ashermancinelli requested review of this revision.Apr 25 2021, 10:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2021, 10:30 AM

Notice that in PrescanAndSemaAction, the first check fails with a scanning error, and the second with a parsing error. This is not the case for PrescanAndParseAction, which makes me think the second check should fail with a parsing error, and the tests should be adjusted in the same way.

Really nice to see this refactor, thank you!

Notice that in PrescanAndSemaAction, the first check fails with a scanning error, and the second with a parsing error. This is not the case for PrescanAndParseAction, which makes me think the second check should fail with a parsing error, and the tests should be adjusted in the same way.

I agree with you. Could you update it?

@ashermancinelli , I had a quick look and I believe that this is what you had in mind (with a test):

diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 1dcb6e0a16be..ba738170e1e0 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -106,7 +106,7 @@ bool PrescanAndParseAction::BeginSourceFileAction(CompilerInstance &c1) {
   // Parse. In case of failure, report and return.
   ci.parsing().Parse(llvm::outs());

-  if (reportFatalScanningErrors(this))
+  if (reportFatalParsingErrors(this))
     return false;

   // Report the diagnostics from parsing
diff --git a/flang/test/Driver/parse-error.f95 b/flang/test/Driver/parse-error.f95
index 00126047e6df..cdcde0ee47f6 100644
--- a/flang/test/Driver/parse-error.f95
+++ b/flang/test/Driver/parse-error.f95
@@ -1,5 +1,8 @@
-! Verify that parsing errors are correctly reported by the driver
+! Verify that parsing errors are correctly reported by the driver. Currently this test focuses on actions inheriting from:
+!   * PrescanAndSemaAction (-fsyntax-only)
+!   * PrescanAndParseAction (-fdebug-unparse-no-sema)

+! RUN: not %flang_fc1 -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s --check-prefix=ERROR
 ! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=ERROR

 ! ERROR: Could not parse {{.*}}parse-error.f95

The updated test won't pass without the change in FrontendActions.cpp that you suggested earlier. Does this make sense?

Update revision with supporting functionality test.

awarzynski accepted this revision.Aug 6 2021, 9:30 AM

LGTM

Apologies for not getting back to this earlier and thanks again for working on this!

This revision is now accepted and ready to land.Aug 6 2021, 9:30 AM

Rebase to ensure patch still builds cleanly.

This revision was landed with ongoing or failed builds.Aug 6 2021, 11:43 AM
This revision was automatically updated to reflect the committed changes.