aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-06-13 10:16:10 -0400
committerPatrick Palka <ppalka@redhat.com>2024-06-13 10:16:10 -0400
commitd387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9 (patch)
tree9fdd9fd06015d3708592c277b4107173c3494554 /gcc/cp/parser.cc
parent83a765768510d1f329887116757d6818d7846717 (diff)
downloadgcc-d387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9.zip
gcc-d387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9.tar.gz
gcc-d387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9.tar.bz2
c++: undeclared identifier in requires-clause [PR99678]
Since the terms of a requires-clause are grammatically primary-expressions and not e.g. postfix-expressions, it seems we need to explicitly handle and diagnose the case where a term parses to a bare unresolved identifier, like cp_parser_postfix_expression does, since cp_parser_primary_expression leaves that up to its callers. Otherwise we incorrectly accept the first three requires-clauses below. Note that the only occurrences of primary-expression in the grammar are postfix-expression and constraint-logical-and-expression, so it's not too surprising that we need this special handling here. PR c++/99678 gcc/cp/ChangeLog: * parser.cc (cp_parser_constraint_primary_expression): Diagnose a bare unresolved unqualified-id. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires38.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r--gcc/cp/parser.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 01a1908..e7409b8 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -31525,6 +31525,8 @@ cp_parser_constraint_primary_expression (cp_parser *parser, bool lambda_p)
}
if (pce == pce_ok)
{
+ if (idk == CP_ID_KIND_UNQUALIFIED && identifier_p (expr))
+ expr = unqualified_name_lookup_error (expr);
cp_lexer_commit_tokens (parser->lexer);
return finish_constraint_primary_expr (expr);
}