This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Committed: Fix C99:ism (declaration after statement) in java FE.
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Sat, 16 Oct 2004 14:29:11 -0400 (EDT)
- Subject: Committed: Fix C99:ism (declaration after statement) in java FE.
Compiling with gcc-2.95 errors out. With these changes,
compilation of the java FE finished. Committed as obvious.
Hope to look into adding -Wdeclaration-after-statement for all
front-ends @WERROR@ settings (stage2 or where supported).
* expr.c (expr_add_location): Move declaration to before all
statements.
* parse.y (java_expand_classes): Ditto.
* lex.c (java_peek_unicode): Ditto.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.208
diff -p -c -r1.208 expr.c
*** expr.c 15 Oct 2004 18:43:10 -0000 1.208
--- expr.c 16 Oct 2004 18:16:35 -0000
*************** build_expr_wfl (tree node,
*** 3239,3253 ****
)
{
tree wfl;
#ifdef USE_MAPPED_LOCATION
wfl = make_node (EXPR_WITH_FILE_LOCATION);
SET_EXPR_LOCATION (wfl, location);
#else
wfl = make_node (EXPR_WITH_FILE_LOCATION);
- static const char *last_file = 0;
- static tree last_filenode = NULL_TREE;
-
EXPR_WFL_SET_LINECOL (wfl, line, col);
if (file != last_file)
{
--- 3239,3253 ----
)
{
tree wfl;
+ static const char *last_file = 0;
+ static tree last_filenode = NULL_TREE;
+
#ifdef USE_MAPPED_LOCATION
wfl = make_node (EXPR_WITH_FILE_LOCATION);
SET_EXPR_LOCATION (wfl, location);
#else
wfl = make_node (EXPR_WITH_FILE_LOCATION);
EXPR_WFL_SET_LINECOL (wfl, line, col);
if (file != last_file)
{
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.518
diff -p -c -r1.518 parse.y
*** parse.y 15 Oct 2004 18:43:09 -0000 1.518
--- parse.y 16 Oct 2004 18:16:45 -0000
*************** java_expand_classes (void)
*** 9173,9185 ****
{
int save_error_count = 0;
static struct parser_ctxt *cur_ctxp = NULL;
java_parse_abort_on_error ();
if (!(ctxp = ctxp_for_generation))
return;
java_layout_classes ();
java_parse_abort_on_error ();
! location_t save_location = input_location;
for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
--- 9173,9186 ----
{
int save_error_count = 0;
static struct parser_ctxt *cur_ctxp = NULL;
+ location_t save_location;
java_parse_abort_on_error ();
if (!(ctxp = ctxp_for_generation))
return;
java_layout_classes ();
java_parse_abort_on_error ();
! save_location = input_location;
for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
Index: lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.117
diff -p -c -r1.117 lex.c
*** lex.c 15 Oct 2004 18:43:10 -0000 1.117
--- lex.c 16 Oct 2004 18:16:46 -0000
*************** java_peek_unicode (void)
*** 544,552 ****
{
int unicode_escape_p;
java_lexer *lex = ctxp->lexer;
if (lex->avail_unicode)
return lex->next_unicode;
- int next;
next = java_read_unicode (lex, &unicode_escape_p);
--- 544,553 ----
{
int unicode_escape_p;
java_lexer *lex = ctxp->lexer;
+ int next;
+
if (lex->avail_unicode)
return lex->next_unicode;
next = java_read_unicode (lex, &unicode_escape_p);
brgds, H-P