* java-tree.h (flag_extraneous_semicolon): New extern.
* lang-options.h: (-Wextraneous-semicolon): New option.
* lang.c (flag_redundant): Fixed typo in leading comment.
(flag_extraneous_semicolon): New global.
(lang_decode_option): Set `flag_extraneous_semicolon' when
-Wall. Decode `-Wextraneous-semicolon'.
* parse.y (type_declaration:): Removed `SC_TK' hack, added
`empty_statement' rule.
(class_body_declaration): Likewise.
(method_body:): Accept `;' as a method body.
(static_initializer:): Removed `SC_TK' hack.
(constructor_block_end:): Likewise.
(empty_statement:): Report deprecated empty declaration. Fixes
gcj/295
(Fix to gcj/295: http://sources.redhat.com/ml/java-prs/2000-q3/msg00095.html)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35929
138bc75d-0d04-0410-961f-
82ee72b054a4
`case' statement.
(patch_assignment): Set DECL_INITIAL on integral final local.
+2000-08-08 Alexandre Petit-Bianco <apbianco@cygnus.com>
+
+ * java-tree.h (flag_extraneous_semicolon): New extern.
+ * lang-options.h: (-Wextraneous-semicolon): New option.
+ * lang.c (flag_redundant): Fixed typo in leading comment.
+ (flag_extraneous_semicolon): New global.
+ (lang_decode_option): Set `flag_extraneous_semicolon' when
+ -Wall. Decode `-Wextraneous-semicolon'.
+ * parse.y (type_declaration:): Removed `SC_TK' hack, added
+ `empty_statement' rule.
+ (class_body_declaration): Likewise.
+ (method_body:): Accept `;' as a method body.
+ (static_initializer:): Removed `SC_TK' hack.
+ (constructor_block_end:): Likewise.
+ (empty_statement:): Report deprecated empty declaration. Fixes
+ gcj/295
+
2000-08-07 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (build_dot_class_method_invocation): Changed parameter
extern int flag_jni;
+/* When non zero, report the now deprecated empty statements. */
+
+extern int flag_extraneous_semicolon;
+
/* When non zero, we emit xref strings. Values of the flag for xref
backends are defined in xref.h. */
{ "-Wredundant-modifiers",
"Warn if modifiers are specified when not necessary"},
{ "-Wunsupported-jdk11", "Warn if `final' local variables are specified"},
+ { "-Wextraneous-semicolon", "Warn if deprecated empty statements are found"},
/* When non zero, -Wall was turned on. */
int flag_wall = 0;
-/* When non zero, check for redundant modifier uses. */
+/* When non zero, check for redundant modifier uses. */
int flag_redundant = 0;
/* When non zero, warns about overridings that don't occur. */
JNI, not CNI. */
int flag_jni = 0;
+/* When non zero, report the now deprecated empty statements. */
+int flag_extraneous_semicolon;
+
/* From gcc/flags.h, and indicates if exceptions are turned on or not. */
extern int flag_new_exceptions;
{
flag_wall = 1;
flag_redundant = 1;
+ flag_extraneous_semicolon = 1;
/* When -Wall given, enable -Wunused. We do this because the C
compiler does it, and people expect it. */
set_Wunused (1);
return 1;
}
+ if (strcmp (p, "-Wextraneous-semicolon") == 0)
+ {
+ flag_extraneous_semicolon = 1;
+ return 1;
+ }
+
if (strcmp (p, "-MD") == 0)
{
jcf_dependency_init (1);
{ end_class_declaration (0); }
| interface_declaration
{ end_class_declaration (0); }
-| SC_TK
- { $$ = NULL; }
+| empty_statement
| error
{
YYERROR_NOW;
class_member_declaration:
field_declaration
-| field_declaration SC_TK
- { $$ = $1; }
| method_declaration
| class_declaration /* Added, JDK1.1 inner classes */
{ end_class_declaration (1); }
| interface_declaration /* Added, JDK1.1 inner interfaces */
{ end_class_declaration (1); }
+| empty_statement
;
/* 19.8.2 Productions from 8.3: Field Declarations */
method_body:
block
-| block SC_TK
-| SC_TK
- { $$ = NULL_TREE; } /* Probably not the right thing to do. */
+| SC_TK { $$ = NULL_TREE; }
;
/* 19.8.4 Productions from 8.5: Static Initializers */
TREE_CHAIN ($2) = CPC_STATIC_INITIALIZER_STMT (ctxp);
SET_CPC_STATIC_INITIALIZER_STMT (ctxp, $2);
}
-| static block SC_TK /* Shouldn't be here. FIXME */
- {
- TREE_CHAIN ($2) = CPC_STATIC_INITIALIZER_STMT (ctxp);
- SET_CPC_STATIC_INITIALIZER_STMT (ctxp, $2);
- }
;
static: /* Test lval.sub_token here */
constructor_block_end:
block_end
-| block_end SC_TK
+;
/* Error recovery for that rule moved down expression_statement: rule. */
explicit_constructor_invocation:
empty_statement:
SC_TK
- { $$ = empty_stmt_node; }
+ {
+ if (flag_extraneous_semicolon)
+ {
+ EXPR_WFL_SET_LINECOL (wfl_operator, lineno, -1);
+ parse_warning_context (wfl_operator, "An empty declaration is a deprecated feature that should not be used");
+ }
+ $$ = empty_stmt_node;
+ }
;
label_decl: