* [Bug c++/99678] c++20 trailing requires clauses allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
@ 2024-05-07 14:12 ` ppalka at gcc dot gnu.org
2024-05-07 14:13 ` [Bug c++/99678] [concepts] requires-clause " ppalka at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-07 14:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nshead at gcc dot gnu.org
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 114946 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
2024-05-07 14:12 ` [Bug c++/99678] " ppalka at gcc dot gnu.org
@ 2024-05-07 14:13 ` ppalka at gcc dot gnu.org
2024-06-12 18:25 ` ppalka at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-07 14:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|c++20 trailing requires |[concepts] requires-clause
|clauses allows undeclared |allows undeclared
|identifier |identifier
CC| |ppalka at gcc dot gnu.org
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
From PR114946:
(In reply to Nathaniel Shead from comment #0)
> The following sample compiles fine with 'g++ -std=c++20 -pedantic-errors':
>
> template <typename T>
> requires xxxx
> struct S {};
>
> template <typename T>
> requires xxxx
> void foo() {}
>
> Note that 'xxxx' has not been declared or defined. Both MSVC and Clang
> complain about the undeclared identifier. GCC does error if we attempt to
> instantiate either of these specialisations, but they always (silently) lose
> to a better match:
>
> template <typename T> struct S {};
> template <typename T> requires xxxx struct S<T> {};
>
> template <typename T> void foo() {}
> template <typename T> requires xxxx void foo() {}
>
> int main() {
> S<int> x;
> foo<int>();
> }
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
2024-05-07 14:12 ` [Bug c++/99678] " ppalka at gcc dot gnu.org
2024-05-07 14:13 ` [Bug c++/99678] [concepts] requires-clause " ppalka at gcc dot gnu.org
@ 2024-06-12 18:25 ` ppalka at gcc dot gnu.org
2024-06-12 18:25 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-06-12 18:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |eratchias at gmail dot com
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 115429 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
` (2 preceding siblings ...)
2024-06-12 18:25 ` ppalka at gcc dot gnu.org
@ 2024-06-12 18:25 ` ppalka at gcc dot gnu.org
2024-06-13 14:16 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-06-12 18:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2024-06-12
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
` (3 preceding siblings ...)
2024-06-12 18:25 ` ppalka at gcc dot gnu.org
@ 2024-06-13 14:16 ` cvs-commit at gcc dot gnu.org
2024-06-13 14:18 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-13 14:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:d387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9
commit r15-1294-gd387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jun 13 10:16:10 2024 -0400
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>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
` (4 preceding siblings ...)
2024-06-13 14:16 ` cvs-commit at gcc dot gnu.org
@ 2024-06-13 14:18 ` ppalka at gcc dot gnu.org
2024-06-17 14:26 ` cvs-commit at gcc dot gnu.org
2024-06-17 14:27 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-06-13 14:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
` (5 preceding siblings ...)
2024-06-13 14:18 ` ppalka at gcc dot gnu.org
@ 2024-06-17 14:26 ` cvs-commit at gcc dot gnu.org
2024-06-17 14:27 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-17 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:20cda2e85c307096a3856f7f27215b8a28982fb6
commit r14-10320-g20cda2e85c307096a3856f7f27215b8a28982fb6
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jun 13 10:16:10 2024 -0400
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>
(cherry picked from commit d387ecb2b2f44f33fd6a7c5ec7eadaf6dd70efc9)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99678] [concepts] requires-clause allows undeclared identifier
2021-03-20 4:17 [Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier hewillk at gmail dot com
` (6 preceding siblings ...)
2024-06-17 14:26 ` cvs-commit at gcc dot gnu.org
@ 2024-06-17 14:27 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-06-17 14:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.2, thanks for the bug report.
^ permalink raw reply [flat|nested] 9+ messages in thread