[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2024-04-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |14.0

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2024-02-10 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Marek Polacek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #10 from Marek Polacek  ---
Should be all fixed now.

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2024-02-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

--- Comment #9 from GCC Commits  ---
The trunk branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:cff174fabd6c980c09aee95db1d9d5c22421761f

commit r14-8915-gcff174fabd6c980c09aee95db1d9d5c22421761f
Author: Marek Polacek 
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
  struct S {
S();
  };

in C++20 we emit the ugly:

q.C:3:8: error: expected unqualified-id before ')' token
3 |   S();

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();
q.C:3:7: note: remove the '< >'

This patch also fixes

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.

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2022-02-08 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

--- Comment #8 from Jonathan Wakely  ---
PR 104437 pointed out that the invalid constructor is accepted if it has a
redundant inline specifier:

template struct S : Base {
inline S() {}
};

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2022-02-08 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Jonathan Wakely  changed:

   What|Removed |Added

 CC||jengelh at inai dot de

--- Comment #7 from Jonathan Wakely  ---
*** Bug 104437 has been marked as a duplicate of this bug. ***

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2021-06-11 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

--- Comment #6 from Jonathan Wakely  ---
If the invalid special member is defined out of the class body, you get another
error:

template
struct F
{
  F();
};

template
inline F::F() { }


101032.C:4:8: error: expected unqualified-id before ‘)’ token
4 |   F();
  |^
101032.C:8:8: error: no declaration matches ‘F::F()’
8 | inline F::F() { }
  |^~~~
101032.C:8:8: note: no functions named ‘F::F()’
101032.C:2:8: note: ‘struct F’ 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.

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2021-06-11 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Jonathan Wakely  changed:

   What|Removed |Added

 CC||kevin.c.eady at gmail dot com

--- Comment #5 from Jonathan Wakely  ---
*** Bug 101032 has been marked as a duplicate of this bug. ***

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2021-06-09 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Marek Polacek  changed:

   What|Removed |Added

 CC||felix.morgner at gmail dot com

--- Comment #4 from Marek Polacek  ---
*** Bug 100997 has been marked as a duplicate of this bug. ***

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2020-09-25 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Marek Polacek  changed:

   What|Removed |Added

   Target Milestone|11.0|---

[Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’

2020-09-25 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202

Marek Polacek  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  ---
Actually, let me reopen this to improve the diagnostic.