[flang] Improve error message for missing primary expression (#185484)

Don't mention the possible expectation that the extension %LOC() could
appear when emitting the error messages for a completely missing primary
expression; it's just confusing.
This commit is contained in:
Peter Klausler 2026-03-11 16:36:48 -07:00 committed by GitHub
parent 79026d22e2
commit 92623c5cc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -80,10 +80,13 @@ constexpr auto primary{instrumented("primary"_en_US,
// PGI/XLF extension: COMPLEX constructor (x,y)
construct<Expr>(parenthesized(
construct<Expr::ComplexConstructor>(expr, "," >> expr))),
extension<LanguageFeature::PercentLOC>(
"nonstandard usage: %LOC"_port_en_US,
construct<Expr>("%LOC" >> parenthesized(construct<Expr::PercentLoc>(
indirect(variable)))))))};
// prevent confusing error on missing primary expression
lookAhead("%LOC"_tok) >>
extension<LanguageFeature::PercentLOC>(
"nonstandard usage: %LOC"_port_en_US,
construct<Expr>("%LOC" >>
parenthesized(
construct<Expr::PercentLoc>(indirect(variable)))))))};
// R1002 level-1-expr -> [defined-unary-op] primary
// TODO: Reasonable extension: permit multiple defined-unary-ops

View File

@ -0,0 +1,8 @@
!RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
logical b
a = 0.
!CHECK: error: expected '('
!CHECK-NOT: error: expected '%LOC'
b = .t.
c = 0.
end