diff options
author | apbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-08-24 01:44:00 +0000 |
---|---|---|
committer | apbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-08-24 01:44:00 +0000 |
commit | 1679257174031625aa5b868054e16af1a6241253 (patch) | |
tree | cd7ce89a24dfddf5ffd3d4ad167f1f4b902ed92c /gcc | |
parent | 6f52caf7927286fd8f2c4a4dfd83e06a3ee2b8fe (diff) | |
download | gcc-1679257174031625aa5b868054e16af1a6241253.tar.gz |
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)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35929 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 4 | ||||
-rw-r--r-- | gcc/java/lang-options.h | 1 | ||||
-rw-r--r-- | gcc/java/lang.c | 12 | ||||
-rw-r--r-- | gcc/java/parse.y | 26 |
5 files changed, 45 insertions, 15 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 80b1b2aec53..1addb289e19 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -66,6 +66,23 @@ Sun Aug 13 09:41:49 2000 Anthony Green <green@redhat.com> `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 diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index a6098200dd1..0dd57eab59b 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -141,6 +141,10 @@ extern int flag_emit_class_files; 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. */ diff --git a/gcc/java/lang-options.h b/gcc/java/lang-options.h index 76c6fe2fbec..630e6d8a1bd 100644 --- a/gcc/java/lang-options.h +++ b/gcc/java/lang-options.h @@ -51,3 +51,4 @@ DEFINE_LANG_NAME ("Java") { "-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"}, diff --git a/gcc/java/lang.c b/gcc/java/lang.c index c86b568fb5f..ae038967c68 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -98,7 +98,7 @@ int flag_emit_xref = 0; /* 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. */ @@ -121,6 +121,9 @@ int flag_hash_synchronization; 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; @@ -256,6 +259,7 @@ lang_decode_option (argc, argv) { 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); @@ -274,6 +278,12 @@ lang_decode_option (argc, argv) return 1; } + if (strcmp (p, "-Wextraneous-semicolon") == 0) + { + flag_extraneous_semicolon = 1; + return 1; + } + if (strcmp (p, "-MD") == 0) { jcf_dependency_init (1); diff --git a/gcc/java/parse.y b/gcc/java/parse.y index ae60ebee04f..dcebab9d01e 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -755,8 +755,7 @@ type_declaration: { end_class_declaration (0); } | interface_declaration { end_class_declaration (0); } -| SC_TK - { $$ = NULL; } +| empty_statement | error { YYERROR_NOW; @@ -880,13 +879,12 @@ class_body_declaration: 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 */ @@ -1085,9 +1083,7 @@ class_type_list: 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 */ @@ -1097,11 +1093,6 @@ static_initializer: 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 */ @@ -1166,7 +1157,7 @@ constructor_body: constructor_block_end: block_end -| block_end SC_TK +; /* Error recovery for that rule moved down expression_statement: rule. */ explicit_constructor_invocation: @@ -1397,7 +1388,14 @@ statement_without_trailing_substatement: 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: |