* c.opt (Wextra-semi): New C++ warning flag.
* doc/invoke.texi (-Wextra-semi): Document new warning option.
* parser.c (cp_parser_member_declaration): Add warning with fixit
information for extra semicolon after in-class function definition.
* g++.dg/warn/Wextra-semi.C: New test.
From-SVN: r247028
+2017-04-20 Volker Reichelt <v.reichelt@netcologne.de>
+
+ * doc/invoke.texi (-Wextra-semi): Document new warning option.
+
2017-04-20 Richard Biener <rguenther@suse.de>
PR tree-optimization/57796
+2017-04-20 Volker Reichelt <v.reichelt@netcologne.de>
+
+ * c.opt (Wextra-semi): New C++ warning flag.
+
2017-04-20 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80423
C ObjC C++ ObjC++ Warning
; in common.opt
+Wextra-semi
+C++ ObjC++ Var(warn_extra_semi) Warning
+Warn about semicolon after in-class function definition.
+
Wfloat-conversion
C ObjC C++ ObjC++ Var(warn_float_conversion) Warning LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
Warn for implicit type conversions that cause loss of floating point precision.
+2017-04-20 Volker Reichelt <v.reichelt@netcologne.de>
+
+ * parser.c (cp_parser_member_declaration): Add warning with fixit
+ information for extra semicolon after in-class function definition.
+
2017-04-20 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80423
token = cp_lexer_peek_token (parser->lexer);
/* If the next token is a semicolon, consume it. */
if (token->type == CPP_SEMICOLON)
- cp_lexer_consume_token (parser->lexer);
+ {
+ location_t semicolon_loc
+ = cp_lexer_consume_token (parser->lexer)->location;
+ gcc_rich_location richloc (semicolon_loc);
+ richloc.add_fixit_remove ();
+ warning_at_rich_loc (&richloc, OPT_Wextra_semi,
+ "extra %<;%> after in-class "
+ "function definition");
+ }
goto out;
}
else
-Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol
-Wno-div-by-zero -Wdouble-promotion -Wduplicated-cond @gol
-Wempty-body -Wenum-compare -Wno-endif-labels -Wexpansion-to-defined @gol
--Werror -Werror=* -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
+-Werror -Werror=* -Wextra-semi -Wfatal-errors @gol
+-Wfloat-equal -Wformat -Wformat=2 @gol
-Wno-format-contains-nul -Wno-format-extra-args @gol
-Wformat-nonliteral -Wformat-overflow=@var{n} @gol
-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol
diagnosed and the warning is enabled by default. In C this warning is
enabled by @option{-Wall}.
+@item -Wextra-semi @r{(C++, Objective-C++ only)}
+@opindex Wextra-semi
+@opindex Wno-extra-semi
+Warn about redundant semicolon after in-class function definition.
+
@item -Wjump-misses-init @r{(C, Objective-C only)}
@opindex Wjump-misses-init
@opindex Wno-jump-misses-init
+2017-04-20 Volker Reichelt <v.reichelt@netcologne.de>
+
+ * g++.dg/warn/Wextra-semi.C: New test.
+
2017-04-20 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80423
--- /dev/null
+// { dg-options "-Wextra-semi -fdiagnostics-show-caret" }
+
+struct A
+{
+ A() {}; /* { dg-warning "after in-class function definition" }
+ { dg-begin-multiline-output "" }
+ A() {};
+ ^
+ -
+ { dg-end-multiline-output "" } */
+
+ void foo() {}; /* { dg-warning "after in-class function definition" }
+ { dg-begin-multiline-output "" }
+ void foo() {};
+ ^
+ -
+ { dg-end-multiline-output "" } */
+
+ friend void bar() {}; /* { dg-warning "after in-class function definition" }
+ { dg-begin-multiline-output "" }
+ friend void bar() {};
+ ^
+ -
+ { dg-end-multiline-output "" } */
+};