-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[flang] Support for warning and error compiler directives. #151510
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1847,6 +1847,8 @@ class UnparseVisitor { | |
[&](const std::list<CompilerDirective::NameValue> &names) { | ||
Walk("!DIR$ ", names, " "); | ||
}, | ||
[&](const CompilerDirective::Error &) { Word("!DIR$ ERROR"); }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How will you test this? The directive will emit a fatal error in semantics, and then unpausing won't be run. |
||
[&](const CompilerDirective::Warning &) { Word("!DIR$ WARNING"); }, | ||
[&](const CompilerDirective::Unrecognized &) { | ||
Word("!DIR$ "); | ||
Word(x.source.ToString()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9248,7 +9248,12 @@ void ResolveNamesVisitor::Post(const parser::CompilerDirective &x) { | |
if (std::holds_alternative<parser::CompilerDirective::VectorAlways>(x.u)) { | ||
return; | ||
} | ||
if (const auto *tkr{ | ||
if (const auto *err{std::get_if<parser::CompilerDirective::Error>(&x.u)}) { | ||
Say(err->v, "%s"_err_en_US); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. thank you. |
||
else if (const auto *warn{std::get_if<parser::CompilerDirective::Warning>(&x.u)}) { | ||
Say(warn->v, "%s"_warn_en_US); | ||
} else if (const auto *tkr{ | ||
std::get_if<std::list<parser::CompilerDirective::IgnoreTKR>>(&x.u)}) { | ||
if (currScope().IsTopLevel() || | ||
GetProgramUnitContaining(currScope()).kind() != | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s | ||
|
||
! Test that error compiler directive issues error | ||
program error | ||
!dir$ error "Error!" | ||
!CHECK: error: Error! | ||
end program | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
! RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s | ||
|
||
! Test that warning compiler directive issues warning | ||
program warn | ||
!dir$ warning "Warning!" | ||
!CHECK: warning: Warning! | ||
end program | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR comment, these character literals are parenthesized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. updated the PR comment.