-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[flang] Prevent errors from being suppressed #114420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang] Prevent errors from being suppressed #114420
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-flang-semantics Author: Iñaki Amatria Barral (inaki-amatria) Changes
This commit also replaces two uses of Full diff: https://github.com/llvm/llvm-project/pull/114420.diff 4 Files Affected:
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 075f33cb684885..c0065045ebee0b 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -1480,19 +1480,13 @@ Scope *ModFileReader::Read(SourceName name, std::optional<bool> isIntrinsic,
std::optional<ModuleCheckSumType> checkSum{
VerifyHeader(sourceFile->content())};
if (!checkSum) {
- if (context_.ShouldWarn(common::UsageWarning::ModuleFile)) {
- Say(name, ancestorName, "File has invalid checksum: %s"_warn_en_US,
- sourceFile->path())
- .set_usageWarning(common::UsageWarning::ModuleFile);
- }
+ Say(name, ancestorName, "File has invalid checksum: %s"_err_en_US,
+ sourceFile->path());
return nullptr;
} else if (requiredHash && *requiredHash != *checkSum) {
- if (context_.ShouldWarn(common::UsageWarning::ModuleFile)) {
- Say(name, ancestorName,
- "File is not the right module file for %s"_warn_en_US,
- "'"s + name.ToString() + "': "s + sourceFile->path())
- .set_usageWarning(common::UsageWarning::ModuleFile);
- }
+ Say(name, ancestorName,
+ "File is not the right module file for %s"_err_en_US,
+ "'"s + name.ToString() + "': "s + sourceFile->path());
return nullptr;
}
llvm::raw_null_ostream NullStream;
diff --git a/flang/test/Semantics/Inputs/modfile70.mod b/flang/test/Semantics/Inputs/modfile70.mod
new file mode 100644
index 00000000000000..14cb3dcde66a28
--- /dev/null
+++ b/flang/test/Semantics/Inputs/modfile70.mod
@@ -0,0 +1,5 @@
+!mod$ v1 sum:invalid_checksum
+module modfile70
+ ! This module file intentionally contains an invalid checksum to trigger a
+ ! semantic error
+end
diff --git a/flang/test/Semantics/modfile63.f90 b/flang/test/Semantics/modfile63.f90
index 0783121017243e..ea8e11958ed8b5 100644
--- a/flang/test/Semantics/modfile63.f90
+++ b/flang/test/Semantics/modfile63.f90
@@ -1,5 +1,5 @@
! RUN: %flang_fc1 -fsyntax-only -I%S/Inputs/dir1 %s
-! RUN: not %flang_fc1 -fsyntax-only -I%S/Inputs/dir2 %s 2>&1 | FileCheck --check-prefix=ERROR %s
+! RUN: not %flang_fc1 -fsyntax-only -I%S/Inputs/dir2 -w %s 2>&1 | FileCheck --check-prefix=ERROR %s
! RUN: %flang_fc1 -Werror -fsyntax-only -I%S/Inputs/dir1 -I%S/Inputs/dir2 %s
! Inputs/dir1 and Inputs/dir2 each have identical copies of modfile63b.mod.
diff --git a/flang/test/Semantics/modfile70.f90 b/flang/test/Semantics/modfile70.f90
new file mode 100644
index 00000000000000..ab387bbf0db689
--- /dev/null
+++ b/flang/test/Semantics/modfile70.f90
@@ -0,0 +1,5 @@
+ use modfile70
+end
+
+! RUN: not %flang_fc1 -fsyntax-only -J%S/Inputs -w %s 2>&1 | FileCheck --check-prefix=ERROR %s
+! ERROR: Cannot read module file for module 'modfile70': File has invalid checksum:
|
|
A module file with an incorrect checksum might still be valid or useful, so I didn't want the error to be fatal. Sometimes it is useful (but dangerous) to be able to modify a module file by hand. If you must turn these warnings into unconditional errors, then Fortran::common::UsageWarning::ModuleFile will become obsolete and should be deleted. |
Thank you for the feedback, klausler! I believe there is a slight mismatch in the current code's behavior and the intent described here. Even if Flang does not report this error specifically,
I have added a fixup commit removing Thanks again for the review! Please feel free to close or merge the PR if you are in agreement. |
`ModFileReader::Say()` flags all messages as errors, but Flang was mistakenly suppressing two errors when the `-w` flag was used, as they were incorrectly conditioned to warning suppression. This fix ensures that errors are reported regardless of the `-w` flag. This commit also replaces two uses of `_warn_en_US` with `_err_en_US` to prevent potential confusion in the future.
|
I have squashed the commits and updated the branch to be up-to-date with the latest main. Could someone with write access kindly merge this PR for me, as I don't have the necessary permissions? Thanks so much!! |
Please get commit privileges to LLVM for yourself, if possible. |
|
@inaki-amatria Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
ModFileReader::Say()flags all messages as errors, but Flang was mistakenly suppressing two errors when the-wflag was used, as they were incorrectly conditioned to warning suppression. This fix ensures that errors are reported regardless of the-wflag.This commit also replaces two uses of
_warn_en_USwith_err_en_USto prevent potential confusion in the future.