* [Bug c++/97202] [11 Regression] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
@ 2020-09-25 8:27 ` rguenth at gcc dot gnu.org
2020-09-25 8:40 ` pinskia at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-25 8:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|GCC reports an error: |[11 Regression] GCC reports
|expected unqualified-id |an error: expected
|before ‘short’ |unqualified-id before
| |‘short’
Keywords| |rejects-valid
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] [11 Regression] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
2020-09-25 8:27 ` [Bug c++/97202] [11 Regression] " rguenth at gcc dot gnu.org
@ 2020-09-25 8:40 ` pinskia at gcc dot gnu.org
2020-09-25 13:16 ` mpolacek at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-09-25 8:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Could this be a c++17 difference?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] [11 Regression] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
2020-09-25 8:27 ` [Bug c++/97202] [11 Regression] " rguenth at gcc dot gnu.org
2020-09-25 8:40 ` pinskia at gcc dot gnu.org
@ 2020-09-25 13:16 ` mpolacek at gcc dot gnu.org
2020-09-25 13:20 ` [Bug c++/97202] " mpolacek at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-25 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
CC| |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is C++20 DR 2237, disallow simple-template-id in cdtor: see
[diff.cpp17.class]p2. Just the diagnostic we give is horrible ;(.
Remove <T> to make this work.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (2 preceding siblings ...)
2020-09-25 13:16 ` mpolacek at gcc dot gnu.org
@ 2020-09-25 13:20 ` mpolacek at gcc dot gnu.org
2020-09-25 13:21 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-25 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|rejects-valid |diagnostic
Status|RESOLVED |ASSIGNED
Last reconfirmed| |2020-09-25
Summary|[11 Regression] GCC reports |GCC reports an error:
|an error: expected |expected unqualified-id
|unqualified-id before |before ‘short’
|‘short’ |
Resolution|INVALID |---
Ever confirmed|0 |1
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Actually, let me reopen this to improve the diagnostic.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (3 preceding siblings ...)
2020-09-25 13:20 ` [Bug c++/97202] " mpolacek at gcc dot gnu.org
@ 2020-09-25 13:21 ` mpolacek at gcc dot gnu.org
2021-06-09 17:12 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-25 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.0 |---
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (4 preceding siblings ...)
2020-09-25 13:21 ` mpolacek at gcc dot gnu.org
@ 2021-06-09 17:12 ` mpolacek at gcc dot gnu.org
2021-06-11 16:54 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-09 17:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |felix.morgner at gmail dot com
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 100997 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (5 preceding siblings ...)
2021-06-09 17:12 ` mpolacek at gcc dot gnu.org
@ 2021-06-11 16:54 ` redi at gcc dot gnu.org
2021-06-11 16:58 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-11 16:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kevin.c.eady at gmail dot com
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 101032 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (6 preceding siblings ...)
2021-06-11 16:54 ` redi at gcc dot gnu.org
@ 2021-06-11 16:58 ` redi at gcc dot gnu.org
2022-02-08 10:15 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-11 16:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If the invalid special member is defined out of the class body, you get another
error:
template<typename T>
struct F
{
F<T>();
};
template<typename T>
inline F<T>::F() { }
101032.C:4:8: error: expected unqualified-id before ‘)’ token
4 | F<T>();
| ^
101032.C:8:8: error: no declaration matches ‘F<T>::F()’
8 | inline F<T>::F() { }
| ^~~~
101032.C:8:8: note: no functions named ‘F<T>::F()’
101032.C:2:8: note: ‘struct F<T>’ defined here
2 | struct F
| ^
As well as improving the first error (which is the subject of this bug) maybe
the constructor could be parsed as though it had been written correctly, so
that the "no declaration matches" error doesn't happen. Compilation is already
going to fail, we don't need to also complain about the valid function
definition not matching anything.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (7 preceding siblings ...)
2021-06-11 16:58 ` redi at gcc dot gnu.org
@ 2022-02-08 10:15 ` redi at gcc dot gnu.org
2022-02-08 10:17 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-08 10:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jengelh at inai dot de
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 104437 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (8 preceding siblings ...)
2022-02-08 10:15 ` redi at gcc dot gnu.org
@ 2022-02-08 10:17 ` redi at gcc dot gnu.org
2024-02-10 13:38 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-08 10:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
PR 104437 pointed out that the invalid constructor is accepted if it has a
redundant inline specifier:
template<typename Base> struct S : Base {
inline S<Base>() {}
};
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (9 preceding siblings ...)
2022-02-08 10:17 ` redi at gcc dot gnu.org
@ 2024-02-10 13:38 ` cvs-commit at gcc dot gnu.org
2024-02-10 13:43 ` mpolacek at gcc dot gnu.org
2024-04-21 21:38 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-10 13:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:cff174fabd6c980c09aee95db1d9d5c22421761f
commit r14-8915-gcff174fabd6c980c09aee95db1d9d5c22421761f
Author: Marek Polacek <polacek@redhat.com>
Date: Fri Feb 2 14:53:01 2024 -0500
c++: DR2237, cdtor and template-id tweaks [PR107126]
Since my r11-532 changes to implement DR2237, for this test:
template<typename T>
struct S {
S<T>();
};
in C++20 we emit the ugly:
q.C:3:8: error: expected unqualified-id before ')' token
3 | S<T>();
which doesn't explain what the problem is. This patch improves that
diagnostic, reduces the error to a pedwarn, and adds a -Wc++20-compat
diagnostic. We now say:
q.C:3:7: warning: template-id not allowed for constructor in C++20
[-Wtemplate-id-cdtor]
3 | S<T>();
q.C:3:7: note: remove the '< >'
This patch also fixes
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202#c8>
where the C++20 diagnostic was missing altogether: The problem was that I
checked
for CPP_TEMPLATE_ID too early, at a point at which cp_parser_template_id
may not
have been called yet. So let's check for it at the end of the function,
after
the tentative parse and rollback.
-Wc++20-compat triggered in libitm/; I sent a patch for that.
DR 2237
PR c++/107126
PR c++/97202
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): In C++20 or with
-Wc++20-compat,
turn on -Wtemplate-id-cdtor.
* c.opt (Wtemplate-id-cdtor): New.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_unqualified_id): Downgrade the DR2237 error
to
a pedwarn.
(cp_parser_constructor_declarator_p): Likewise.
gcc/ChangeLog:
* doc/invoke.texi: Document -Wtemplate-id-cdtor.
gcc/testsuite/ChangeLog:
* g++.dg/DRs/dr2237.C: Adjust dg-error.
* g++.dg/parse/constructor2.C: Likewise.
* g++.dg/template/error34.C: Likewise.
* g++.old-deja/g++.pt/ctor2.C: Likewise.
* g++.dg/DRs/dr2237-2.C: New test.
* g++.dg/DRs/dr2237-3.C: New test.
* g++.dg/DRs/dr2237-4.C: New test.
* g++.dg/DRs/dr2237-5.C: New test.
* g++.dg/warn/Wtemplate-id-cdtor-1.C: New test.
* g++.dg/warn/Wtemplate-id-cdtor-2.C: New test.
* g++.dg/warn/Wtemplate-id-cdtor-3.C: New test.
* g++.dg/warn/Wtemplate-id-cdtor-4.C: New test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (10 preceding siblings ...)
2024-02-10 13:38 ` cvs-commit at gcc dot gnu.org
@ 2024-02-10 13:43 ` mpolacek at gcc dot gnu.org
2024-04-21 21:38 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-10 13:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Should be all fixed now.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’
2020-09-25 8:05 [Bug c++/97202] New: GCC reports an error: expected unqualified-id before ‘short’ tangyixuan at mail dot dlut.edu.cn
` (11 preceding siblings ...)
2024-02-10 13:43 ` mpolacek at gcc dot gnu.org
@ 2024-04-21 21:38 ` pinskia at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-21 21:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 14+ messages in thread