Commit 5f1c312a by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

java-tree.h (flag_extraneous_semicolon): New extern.

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

(Fix to gcj/295: http://sources.redhat.com/ml/java-prs/2000-q3/msg00095.html)

From-SVN: r35929
parent e15a68e7
...@@ -66,6 +66,23 @@ Sun Aug 13 09:41:49 2000 Anthony Green <green@redhat.com> ...@@ -66,6 +66,23 @@ Sun Aug 13 09:41:49 2000 Anthony Green <green@redhat.com>
`case' statement. `case' statement.
(patch_assignment): Set DECL_INITIAL on integral final local. (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> 2000-08-07 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (build_dot_class_method_invocation): Changed parameter * parse.y (build_dot_class_method_invocation): Changed parameter
......
...@@ -141,6 +141,10 @@ extern int flag_emit_class_files; ...@@ -141,6 +141,10 @@ extern int flag_emit_class_files;
extern int flag_jni; 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 /* When non zero, we emit xref strings. Values of the flag for xref
backends are defined in xref.h. */ backends are defined in xref.h. */
......
...@@ -51,3 +51,4 @@ DEFINE_LANG_NAME ("Java") ...@@ -51,3 +51,4 @@ DEFINE_LANG_NAME ("Java")
{ "-Wredundant-modifiers", { "-Wredundant-modifiers",
"Warn if modifiers are specified when not necessary"}, "Warn if modifiers are specified when not necessary"},
{ "-Wunsupported-jdk11", "Warn if `final' local variables are specified"}, { "-Wunsupported-jdk11", "Warn if `final' local variables are specified"},
{ "-Wextraneous-semicolon", "Warn if deprecated empty statements are found"},
...@@ -98,7 +98,7 @@ int flag_emit_xref = 0; ...@@ -98,7 +98,7 @@ int flag_emit_xref = 0;
/* When non zero, -Wall was turned on. */ /* When non zero, -Wall was turned on. */
int flag_wall = 0; int flag_wall = 0;
/* When non zero, check for redundant modifier uses. */ /* When non zero, check for redundant modifier uses. */
int flag_redundant = 0; int flag_redundant = 0;
/* When non zero, warns about overridings that don't occur. */ /* When non zero, warns about overridings that don't occur. */
...@@ -121,6 +121,9 @@ int flag_hash_synchronization; ...@@ -121,6 +121,9 @@ int flag_hash_synchronization;
JNI, not CNI. */ JNI, not CNI. */
int flag_jni = 0; 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. */ /* From gcc/flags.h, and indicates if exceptions are turned on or not. */
extern int flag_new_exceptions; extern int flag_new_exceptions;
...@@ -256,6 +259,7 @@ lang_decode_option (argc, argv) ...@@ -256,6 +259,7 @@ lang_decode_option (argc, argv)
{ {
flag_wall = 1; flag_wall = 1;
flag_redundant = 1; flag_redundant = 1;
flag_extraneous_semicolon = 1;
/* When -Wall given, enable -Wunused. We do this because the C /* When -Wall given, enable -Wunused. We do this because the C
compiler does it, and people expect it. */ compiler does it, and people expect it. */
set_Wunused (1); set_Wunused (1);
...@@ -274,6 +278,12 @@ lang_decode_option (argc, argv) ...@@ -274,6 +278,12 @@ lang_decode_option (argc, argv)
return 1; return 1;
} }
if (strcmp (p, "-Wextraneous-semicolon") == 0)
{
flag_extraneous_semicolon = 1;
return 1;
}
if (strcmp (p, "-MD") == 0) if (strcmp (p, "-MD") == 0)
{ {
jcf_dependency_init (1); jcf_dependency_init (1);
......
...@@ -755,8 +755,7 @@ type_declaration: ...@@ -755,8 +755,7 @@ type_declaration:
{ end_class_declaration (0); } { end_class_declaration (0); }
| interface_declaration | interface_declaration
{ end_class_declaration (0); } { end_class_declaration (0); }
| SC_TK | empty_statement
{ $$ = NULL; }
| error | error
{ {
YYERROR_NOW; YYERROR_NOW;
...@@ -880,13 +879,12 @@ class_body_declaration: ...@@ -880,13 +879,12 @@ class_body_declaration:
class_member_declaration: class_member_declaration:
field_declaration field_declaration
| field_declaration SC_TK
{ $$ = $1; }
| method_declaration | method_declaration
| class_declaration /* Added, JDK1.1 inner classes */ | class_declaration /* Added, JDK1.1 inner classes */
{ end_class_declaration (1); } { end_class_declaration (1); }
| interface_declaration /* Added, JDK1.1 inner interfaces */ | interface_declaration /* Added, JDK1.1 inner interfaces */
{ end_class_declaration (1); } { end_class_declaration (1); }
| empty_statement
; ;
/* 19.8.2 Productions from 8.3: Field Declarations */ /* 19.8.2 Productions from 8.3: Field Declarations */
...@@ -1085,9 +1083,7 @@ class_type_list: ...@@ -1085,9 +1083,7 @@ class_type_list:
method_body: method_body:
block block
| block SC_TK | SC_TK { $$ = NULL_TREE; }
| SC_TK
{ $$ = NULL_TREE; } /* Probably not the right thing to do. */
; ;
/* 19.8.4 Productions from 8.5: Static Initializers */ /* 19.8.4 Productions from 8.5: Static Initializers */
...@@ -1097,11 +1093,6 @@ static_initializer: ...@@ -1097,11 +1093,6 @@ static_initializer:
TREE_CHAIN ($2) = CPC_STATIC_INITIALIZER_STMT (ctxp); TREE_CHAIN ($2) = CPC_STATIC_INITIALIZER_STMT (ctxp);
SET_CPC_STATIC_INITIALIZER_STMT (ctxp, $2); 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 */ static: /* Test lval.sub_token here */
...@@ -1166,7 +1157,7 @@ constructor_body: ...@@ -1166,7 +1157,7 @@ constructor_body:
constructor_block_end: constructor_block_end:
block_end block_end
| block_end SC_TK ;
/* Error recovery for that rule moved down expression_statement: rule. */ /* Error recovery for that rule moved down expression_statement: rule. */
explicit_constructor_invocation: explicit_constructor_invocation:
...@@ -1397,7 +1388,14 @@ statement_without_trailing_substatement: ...@@ -1397,7 +1388,14 @@ statement_without_trailing_substatement:
empty_statement: empty_statement:
SC_TK 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: label_decl:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment