public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode
@ 2024-02-05 7:07 tanksherman27 at gmail dot com
2024-02-05 7:14 ` [Bug c++/113760] " pinskia at gcc dot gnu.org
` (19 more replies)
0 siblings, 20 replies; 21+ messages in thread
From: tanksherman27 at gmail dot com @ 2024-02-05 7:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Bug ID: 113760
Summary: gcc rejects valid empty-declaration in pedantic mode
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tanksherman27 at gmail dot com
Target Milestone: ---
In https://github.com/openjdk/jdk/pull/17687#issuecomment-1926154325 we
discovered a possible g++ bug where g++ rejects empty semicolons in pedantic
mode, this is rather evident in code like
#define DEBUG_ONLY(code) code;
DEBUG_ONLY(foo());
which will fire a -Werror warning even in C++11 and above, where such empty
declarations are allowed
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
@ 2024-02-05 7:14 ` pinskia at gcc dot gnu.org
2024-02-05 7:19 ` pinskia at gcc dot gnu.org
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-05 7:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-02-05
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I can't reproduce this at all.
I tried:
```
void foo();
#define DEBUG_ONLY(code) code;
void f() {
DEBUG_ONLY(foo());
}
```
The only time I can reproduce an error is:
```
;
```
And with `-std=c++98 -W -Wall -pedantic-errors`.
Can you provide a full example where you are getting into an issue?
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
2024-02-05 7:14 ` [Bug c++/113760] " pinskia at gcc dot gnu.org
@ 2024-02-05 7:19 ` pinskia at gcc dot gnu.org
2024-02-05 7:23 ` pinskia at gcc dot gnu.org
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-05 7:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=96068
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Or is it just a dup of bug 96068 ? Which was fixed in GCC 11.1.0. GCC 10.5.0
was the last released of the GCC 10 branch. And GCC 9 is also in this mode.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
2024-02-05 7:14 ` [Bug c++/113760] " pinskia at gcc dot gnu.org
2024-02-05 7:19 ` pinskia at gcc dot gnu.org
@ 2024-02-05 7:23 ` pinskia at gcc dot gnu.org
2024-02-05 10:13 ` redi at gcc dot gnu.org
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-05 7:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
From JDK bug report:
> It looks like it only removed
> the warnings for empty declarations at namespace scope. I couldn't find
> anything for other cases, including empty class member declarations.
Yes because the C++ defect report was only for `Spurious semicolons at
namespace scope should be allowed`. See
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#569 .
```
struct f
{
int t; ;
};
```
Is not allowed by the C++ standard currently and is a GCC extension, maybe it
should have a seperate flag to control that but I am not 100% sure.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (2 preceding siblings ...)
2024-02-05 7:23 ` pinskia at gcc dot gnu.org
@ 2024-02-05 10:13 ` redi at gcc dot gnu.org
2024-02-05 14:49 ` kab at acm dot org
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-05 10:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please provide a proper bug report not a macro definition out of context and a
URL.
https://gcc.gnu.org/bugs/
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (3 preceding siblings ...)
2024-02-05 10:13 ` redi at gcc dot gnu.org
@ 2024-02-05 14:49 ` kab at acm dot org
2024-02-05 15:10 ` [Bug c++/113760] [DR1693] " redi at gcc dot gnu.org
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: kab at acm dot org @ 2024-02-05 14:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
kab at acm dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kab at acm dot org
--- Comment #5 from kab at acm dot org ---
(In reply to Andrew Pinski from comment #3)
> From JDK bug report:
> > It looks like it only removed
> > the warnings for empty declarations at namespace scope. I couldn't find
> > anything for other cases, including empty class member declarations.
>
> Yes because the C++ defect report was only for `Spurious semicolons at
> namespace scope should be allowed`. See
> https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#569 .
>
>
> ```
> struct f
> {
> int t; ;
> };
> ```
>
> Is not allowed by the C++ standard currently and is a GCC extension, maybe
> it should have a seperate flag to control that but I am not 100% sure.
It's C++14 that the openjdk currently cares about. C++14 added
"empty-declaration" to the syntax for "member-declaration".
C++14 9.2 [class.mem]
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1693
The above "struct f" declaration warns with C++14 and -Wpedantic, but
shouldn't.
Tested with that struct as the only contents of "test.cpp" and this command
line for g++13.2.0:
g++ -c -Wpedantic -std=c++14 -o test.o test.cpp
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (4 preceding siblings ...)
2024-02-05 14:49 ` kab at acm dot org
@ 2024-02-05 15:10 ` redi at gcc dot gnu.org
2024-02-07 9:29 ` jakub at gcc dot gnu.org
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-05 15:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|gcc rejects valid |[DR1693] gcc rejects valid
|empty-declaration in |empty-declaration in
|pedantic mode |pedantic mode
Keywords| |rejects-valid
Status|WAITING |NEW
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
OK, so a proper bug report would be that there's a diagnostic with -std=c++14
-pedantic for this code:
struct f
{
int t; ;
};
Confirmed.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (5 preceding siblings ...)
2024-02-05 15:10 ` [Bug c++/113760] [DR1693] " redi at gcc dot gnu.org
@ 2024-02-07 9:29 ` jakub at gcc dot gnu.org
2024-02-12 16:38 ` mpolacek at gcc dot gnu.org
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-07 9:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org,
| |mpolacek at gcc dot gnu.org
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
g++ emits 4 errors on
struct S
{
void foo () {}
void bar () {};
void baz () = delete;
void qux () = delete;
;
void corge () = delete;
;
;
int s;
;
};
;
;
(one after qux, 2 after corge, one after s), clang++ -pedantic-errors
-std=c++23 including trunk 2 (one after corge, one after s), so neither
implements the DR. Strangely, with -pedantic-errors -std=c++23 -Wextra-semi it
warns 7 times but doesn't error (which is I think the desirable state).
Now, g++ with -pedantic-errors -std=c++23 -Wextra-semi emits just one warning
on the ; after bar and still the 4 errors.
That said, -Wextra-semi in GCC is documented that way:
Warn about redundant semicolons after in-class function
definitions.
and clang doesn't bother to document it at all (at least haven't found it).
So, shall we change documentation of -Wextra-semi and say change
/* A declaration consisting of a single semicolon is invalid
* before C++11. Allow it unless we're being pedantic. */
if (cxx_dialect < cxx11)
pedwarn (input_location, OPT_Wpedantic, "extra %<;%>");
to else warning (OPT_Wextra_semi, "extra %<;%>"); etc.?
Then there is
if (!in_system_header_at (token->location))
{
gcc_rich_location richloc (token->location);
richloc.add_fixit_remove ();
pedwarn (&richloc, OPT_Wpedantic, "extra %<;%>");
}
should that be similarly if (cxx_dialect < cxx11) pedwarn; else warning ?
Or, if we want to change this already for GCC 14, do that if (cxx_dialect <
cxx11) part
just before the last pedwarn above and add the else warning for GCC 15?
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (6 preceding siblings ...)
2024-02-07 9:29 ` jakub at gcc dot gnu.org
@ 2024-02-12 16:38 ` mpolacek at gcc dot gnu.org
2024-02-12 16:46 ` mpolacek at gcc dot gnu.org
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-12 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #7)
> g++ emits 4 errors on
> struct S
> {
> void foo () {}
> void bar () {};
> void baz () = delete;
> void qux () = delete;
> ;
> void corge () = delete;
> ;
> ;
> int s;
> ;
> };
> ;
> ;
> (one after qux, 2 after corge, one after s), clang++ -pedantic-errors
> -std=c++23 including trunk 2 (one after corge, one after s), so neither
> implements the DR. Strangely, with -pedantic-errors -std=c++23 -Wextra-semi
> it warns 7 times but doesn't error (which is I think the desirable state).
> Now, g++ with -pedantic-errors -std=c++23 -Wextra-semi emits just one
> warning on the ; after bar and still the 4 errors.
>
> That said, -Wextra-semi in GCC is documented that way:
> Warn about redundant semicolons after in-class function
> definitions.
> and clang doesn't bother to document it at all (at least haven't found it).
>
> So, shall we change documentation of -Wextra-semi and say change
> /* A declaration consisting of a single semicolon is invalid
> * before C++11. Allow it unless we're being pedantic. */
> if (cxx_dialect < cxx11)
> pedwarn (input_location, OPT_Wpedantic, "extra %<;%>");
> to else warning (OPT_Wextra_semi, "extra %<;%>"); etc.?
Yeah, I'd say so.
> Then there is
> if (!in_system_header_at (token->location))
> {
> gcc_rich_location richloc (token->location);
> richloc.add_fixit_remove ();
> pedwarn (&richloc, OPT_Wpedantic, "extra %<;%>");
> }
> should that be similarly if (cxx_dialect < cxx11) pedwarn; else warning ?
I think so. The < cxx11 is definitely missing here.
> Or, if we want to change this already for GCC 14, do that if (cxx_dialect <
> cxx11) part
> just before the last pedwarn above and add the else warning for GCC 15?
I would do it all at once.
I guess:
{} -> no warnings in any dialect
-pedantic -> pedwarns only in C++03
-Wextra-semi -> all warnings in all dialects
-std=c++11 -pedantic -Wextra-semi -> only -Wextra-semi warnings
-std=c++03 -pedantic -Wextra-semi -> pedwarns
-std=c++11 -pedantic -Wno-extra-semi -> no warnings
-std=c++03 -pedantic -Wno-extra-semi -> no warnings
-std=c++03 -pedantic-errors -Wextra-semi -> errors (?)
-std=c++11 -pedantic-errors -Wextra-semi -> warnings
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (7 preceding siblings ...)
2024-02-12 16:38 ` mpolacek at gcc dot gnu.org
@ 2024-02-12 16:46 ` mpolacek at gcc dot gnu.org
2024-02-12 17:07 ` mpolacek at gcc dot gnu.org
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-12 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And:
-pedantic-errors -> errors only in C++03
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (8 preceding siblings ...)
2024-02-12 16:46 ` mpolacek at gcc dot gnu.org
@ 2024-02-12 17:07 ` mpolacek at gcc dot gnu.org
2024-02-12 21:29 ` mpolacek at gcc dot gnu.org
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-12 17:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (9 preceding siblings ...)
2024-02-12 17:07 ` mpolacek at gcc dot gnu.org
@ 2024-02-12 21:29 ` mpolacek at gcc dot gnu.org
2024-02-12 23:36 ` harald at gigawatt dot nl
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-12 21:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And we should also warn in C++98 with -Wc++11-extensions for an extra ';'
outside of a function I suppose...
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (10 preceding siblings ...)
2024-02-12 21:29 ` mpolacek at gcc dot gnu.org
@ 2024-02-12 23:36 ` harald at gigawatt dot nl
2024-02-12 23:49 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: harald at gigawatt dot nl @ 2024-02-12 23:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #11 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Marek Polacek from comment #8)
> -std=c++03 -pedantic-errors -Wextra-semi -> errors (?)
Speaking as a user: that makes sense to me, but I would also expect:
-std=c++03 -pedantic-errors -Wno-error=extra-semi -> warnings
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (11 preceding siblings ...)
2024-02-12 23:36 ` harald at gigawatt dot nl
@ 2024-02-12 23:49 ` mpolacek at gcc dot gnu.org
2024-02-13 1:17 ` harald at gigawatt dot nl
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-12 23:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #12 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thank for your comment. In the end I went with
-std=c++03 -pedantic-errors -Wextra-semi -> warnings
-std=c++03 -pedantic -Wextra-semi -> warnings (not pedwarn)
based on the principle that a more specific option overrides a more general
option. This is also what clang++ does. Granted, -Wvla in C doesn't behave
like that...
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (12 preceding siblings ...)
2024-02-12 23:49 ` mpolacek at gcc dot gnu.org
@ 2024-02-13 1:17 ` harald at gigawatt dot nl
2024-02-13 1:54 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: harald at gigawatt dot nl @ 2024-02-13 1:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #13 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Marek Polacek from comment #12)
> Thank for your comment. In the end I went with
>
> -std=c++03 -pedantic-errors -Wextra-semi -> warnings
> -std=c++03 -pedantic -Wextra-semi -> warnings (not pedwarn)
>
> based on the principle that a more specific option overrides a more general
> option. This is also what clang++ does. Granted, -Wvla in C doesn't behave
> like that...
That also makes sense. The more specific option overriding a more general
option is also the reasoning why I expect no error with -pedantic-errors
-Wno-error=extra-semi.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (13 preceding siblings ...)
2024-02-13 1:17 ` harald at gigawatt dot nl
@ 2024-02-13 1:54 ` mpolacek at gcc dot gnu.org
2024-02-13 19:27 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-13 1:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #14 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
My current patch appears to handle that correctly:
$ ./cc1plus -quiet q.C -pedantic-errors -std=c++98 -Wno-error=extra-semi
q.C:3:3: warning: extra ‘;’ outside of a function only allowed in C++11
[-Wextra-semi]
3 | };;
| ^
| -
I'll add a test for that combination.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (14 preceding siblings ...)
2024-02-13 1:54 ` mpolacek at gcc dot gnu.org
@ 2024-02-13 19:27 ` mpolacek at gcc dot gnu.org
2024-02-13 23:08 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-13 19:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #15 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch posted. I don't foresee it being part of GCC 14.
https://gcc.gnu.org/pipermail/gcc-patches/2024-February/645494.html
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (15 preceding siblings ...)
2024-02-13 19:27 ` mpolacek at gcc dot gnu.org
@ 2024-02-13 23:08 ` cvs-commit at gcc dot gnu.org
2024-02-13 23:09 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-13 23:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #16 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:6fec511f2d23cc70ab29d1ba79c2415ab51bcb60
commit r14-8967-g6fec511f2d23cc70ab29d1ba79c2415ab51bcb60
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Feb 13 16:21:32 2024 -0500
c++: adjust the extra ; warning [PR113760]
A minimal fix to quash an extra ; warning. I have a more complete
patch for GCC 15.
DR 1693
PR c++/113760
gcc/cp/ChangeLog:
* parser.cc (cp_parser_member_declaration): Only pedwarn about an
extra
semicolon in C++98.
gcc/testsuite/ChangeLog:
* g++.dg/semicolon-fixits.C: Run in C++98 only.
* g++.dg/warn/pedantic2.C: Adjust dg-warning.
* g++.old-deja/g++.jason/parse11.C: Adjust dg-error.
* g++.dg/DRs/dr1693-1.C: New test.
* g++.dg/DRs/dr1693-2.C: New test.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (16 preceding siblings ...)
2024-02-13 23:08 ` cvs-commit at gcc dot gnu.org
@ 2024-02-13 23:09 ` mpolacek at gcc dot gnu.org
2024-05-15 17:26 ` cvs-commit at gcc dot gnu.org
2024-05-15 17:26 ` mpolacek at gcc dot gnu.org
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-13 23:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #17 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Partially fixed for GCC 14. Leaving this open for more changes in GCC 15.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (17 preceding siblings ...)
2024-02-13 23:09 ` mpolacek at gcc dot gnu.org
@ 2024-05-15 17:26 ` cvs-commit at gcc dot gnu.org
2024-05-15 17:26 ` mpolacek at gcc dot gnu.org
19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-15 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
--- Comment #18 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:0b3eac4b54a52bf206b88743d1e987badc97cff4
commit r15-522-g0b3eac4b54a52bf206b88743d1e987badc97cff4
Author: Marek Polacek <polacek@redhat.com>
Date: Mon Feb 12 19:36:16 2024 -0500
c++: DR 569, DR 1693: fun with semicolons [PR113760]
Prompted by c++/113760, I started looking into a bogus "extra ;"
warning in C++11. It quickly turned out that if I want to fix
this for good, the fix will not be so small.
This patch touches on DR 569, an extra ; at namespace scope should
be allowed since C++11:
struct S {
};
; // pedwarn in C++98
It also touches on DR 1693, which allows superfluous semicolons in
class definitions since C++11:
struct S {
int a;
; // pedwarn in C++98
};
Note that a single semicolon is valid after a member function definition:
struct S {
void foo () {}; // only warns with -Wextra-semi
};
There's a new function maybe_warn_extra_semi to handle all of the above
in a single place. So now they all get a fix-it hint.
-Wextra-semi turns on all "extra ;" diagnostics. Currently, options
like -Wc++11-compat or -Wc++11-extensions are not considered.
DR 1693
PR c++/113760
DR 569
gcc/c-family/ChangeLog:
* c.opt (Wextra-semi): Initialize to -1.
gcc/cp/ChangeLog:
* parser.cc (extra_semi_kind): New.
(maybe_warn_extra_semi): New.
(cp_parser_declaration): Call maybe_warn_extra_semi.
(cp_parser_member_declaration): Likewise.
gcc/ChangeLog:
* doc/invoke.texi: Update -Wextra-semi documentation.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/semicolon1.C: New test.
* g++.dg/diagnostic/semicolon10.C: New test.
* g++.dg/diagnostic/semicolon11.C: New test.
* g++.dg/diagnostic/semicolon12.C: New test.
* g++.dg/diagnostic/semicolon13.C: New test.
* g++.dg/diagnostic/semicolon14.C: New test.
* g++.dg/diagnostic/semicolon15.C: New test.
* g++.dg/diagnostic/semicolon16.C: New test.
* g++.dg/diagnostic/semicolon17.C: New test.
* g++.dg/diagnostic/semicolon2.C: New test.
* g++.dg/diagnostic/semicolon3.C: New test.
* g++.dg/diagnostic/semicolon4.C: New test.
* g++.dg/diagnostic/semicolon5.C: New test.
* g++.dg/diagnostic/semicolon6.C: New test.
* g++.dg/diagnostic/semicolon7.C: New test.
* g++.dg/diagnostic/semicolon8.C: New test.
* g++.dg/diagnostic/semicolon9.C: New test.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Bug c++/113760] [DR1693] gcc rejects valid empty-declaration in pedantic mode
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
` (18 preceding siblings ...)
2024-05-15 17:26 ` cvs-commit at gcc dot gnu.org
@ 2024-05-15 17:26 ` mpolacek at gcc dot gnu.org
19 siblings, 0 replies; 21+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-05-15 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113760
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #19 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Ought to be fully fixed now.
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2024-05-15 17:26 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 7:07 [Bug c++/113760] New: gcc rejects valid empty-declaration in pedantic mode tanksherman27 at gmail dot com
2024-02-05 7:14 ` [Bug c++/113760] " pinskia at gcc dot gnu.org
2024-02-05 7:19 ` pinskia at gcc dot gnu.org
2024-02-05 7:23 ` pinskia at gcc dot gnu.org
2024-02-05 10:13 ` redi at gcc dot gnu.org
2024-02-05 14:49 ` kab at acm dot org
2024-02-05 15:10 ` [Bug c++/113760] [DR1693] " redi at gcc dot gnu.org
2024-02-07 9:29 ` jakub at gcc dot gnu.org
2024-02-12 16:38 ` mpolacek at gcc dot gnu.org
2024-02-12 16:46 ` mpolacek at gcc dot gnu.org
2024-02-12 17:07 ` mpolacek at gcc dot gnu.org
2024-02-12 21:29 ` mpolacek at gcc dot gnu.org
2024-02-12 23:36 ` harald at gigawatt dot nl
2024-02-12 23:49 ` mpolacek at gcc dot gnu.org
2024-02-13 1:17 ` harald at gigawatt dot nl
2024-02-13 1:54 ` mpolacek at gcc dot gnu.org
2024-02-13 19:27 ` mpolacek at gcc dot gnu.org
2024-02-13 23:08 ` cvs-commit at gcc dot gnu.org
2024-02-13 23:09 ` mpolacek at gcc dot gnu.org
2024-05-15 17:26 ` cvs-commit at gcc dot gnu.org
2024-05-15 17:26 ` mpolacek at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).