public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Committed: Fix C99:ism (declaration after statement) in java FE.
@ 2004-10-16 18:29 Hans-Peter Nilsson
  2004-10-17  3:05 ` Kaveh R. Ghazi
  0 siblings, 1 reply; 5+ messages in thread
From: Hans-Peter Nilsson @ 2004-10-16 18:29 UTC (permalink / raw)
  To: gcc-patches, java-patches

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Committed: Fix C99:ism (declaration after statement) in java FE.
  2004-10-16 18:29 Committed: Fix C99:ism (declaration after statement) in java FE Hans-Peter Nilsson
@ 2004-10-17  3:05 ` Kaveh R. Ghazi
  2004-10-17 11:52   ` Hans-Peter Nilsson
  0 siblings, 1 reply; 5+ messages in thread
From: Kaveh R. Ghazi @ 2004-10-17  3:05 UTC (permalink / raw)
  To: hp; +Cc: gcc-patches, java-patches

 > Hope to look into adding -Wdeclaration-after-statement for all
 > front-ends @WERROR@ settings (stage2 or where supported).

No need for a new flag, just add -pedantic like the other FEs do.
(Haven't tried it myself, probably requires cleaning other fallout.)

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Committed: Fix C99:ism (declaration after statement) in java FE.
  2004-10-17  3:05 ` Kaveh R. Ghazi
@ 2004-10-17 11:52   ` Hans-Peter Nilsson
  2004-10-17 13:22     ` Steven Bosscher
  0 siblings, 1 reply; 5+ messages in thread
From: Hans-Peter Nilsson @ 2004-10-17 11:52 UTC (permalink / raw)
  To: Kaveh R. Ghazi; +Cc: gcc-patches, java-patches

On Sat, 16 Oct 2004, Kaveh R. Ghazi wrote:
>  > Hope to look into adding -Wdeclaration-after-statement for all
>  > front-ends @WERROR@ settings (stage2 or where supported).
>
> No need for a new flag, just add -pedantic like the other FEs do.
> (Haven't tried it myself, probably requires cleaning other fallout.)

Hmm, looks like you're right.  Tom Tromey mentioned on IRC that
he'd like more warnings enabled, so it seems this would be the
way to go.  Maybe I'll do it.

brgds, H-P

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Committed: Fix C99:ism (declaration after statement) in java FE.
  2004-10-17 11:52   ` Hans-Peter Nilsson
@ 2004-10-17 13:22     ` Steven Bosscher
  2004-10-17 18:00       ` Zack Weinberg
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Bosscher @ 2004-10-17 13:22 UTC (permalink / raw)
  To: Hans-Peter Nilsson, Kaveh R. Ghazi; +Cc: gcc-patches, java-patches

On Sunday 17 October 2004 12:59, Hans-Peter Nilsson wrote:
> On Sat, 16 Oct 2004, Kaveh R. Ghazi wrote:
> >  > Hope to look into adding -Wdeclaration-after-statement for all
> >  > front-ends @WERROR@ settings (stage2 or where supported).
> >
> > No need for a new flag, just add -pedantic like the other FEs do.
> > (Haven't tried it myself, probably requires cleaning other fallout.)
>
> Hmm, looks like you're right.  Tom Tromey mentioned on IRC that
> he'd like more warnings enabled, so it seems this would be the
> way to go.  Maybe I'll do it.

I've just done it.  It's still bootstrapping on x86_64-suse-linux-gnu
but I'm not expecting any problems (it's well into libjava now).

OK if it completes bootstrapping and testing?

Gr.
Steven



	* class.c (ident_subst): Always alloca buffer.
	* java-opcodes.h (LAST_AND_UNUSED_JAVA_OPCODE): Add this dummy
	opcode after including javaop.def.
	* jcf-dump.c (CHECK_PC_IN_RANGE): Return 0 from the arm of the
	conditional expression that exits, to avoid warnings.
	* verify.c (CHECK_PC_IN_RANGE): Mark the __GNUC__ definition as
	a user of an extension.
	* win32-host.c: Move check down to have non-empty file when
	WIN32 is not defined.

	* Make-lang.in (java-warn): Add STRICT_WARN.
	(java/jcf-io.o-warn): Don't have Werror for this file.
	* jcf-io.c (caching_stat): Add FIXME for non-POSIX scandir use.

Index: Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.145
diff -c -3 -p -r1.145 Make-lang.in
*** Make-lang.in	22 Sep 2004 11:21:21 -0000	1.145
--- Make-lang.in	17 Oct 2004 11:41:56 -0000
*************** JCFDUMP_OBJS = java/jcf-dump.o java/jcf-
*** 118,128 ****
  
  JVGENMAIN_OBJS = java/jvgenmain.o java/mangle_name.o errors.o intl.o
  
! # Use loose warnings for this front end.
! java-warn = $(WERROR)
  # String length warnings
  jvspec.o-warn = -Wno-error
  
  jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
  	rm -f $@
  	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
--- 118,132 ----
  
  JVGENMAIN_OBJS = java/jvgenmain.o java/mangle_name.o errors.o intl.o
  
! # Use strict warnings for this front end.
! java-warn = $(STRICT_WARN) $(WERROR)
! 
  # String length warnings
  jvspec.o-warn = -Wno-error
  
+ # Use of non-standardized scandir
+ java/jcf-io.o-warn = -Wno-error
+ 
  jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
  	rm -f $@
  	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.210
diff -c -3 -p -r1.210 class.c
*** class.c	15 Oct 2004 18:43:10 -0000	1.210
--- class.c	17 Oct 2004 11:41:57 -0000
*************** ident_subst (const char* old_name,
*** 268,278 ****
    int prefix_len = strlen (prefix);
    int suffix_len = strlen (suffix);
    int i = prefix_len + old_length + suffix_len + 1;
- #ifdef __GNUC__
-   char buffer[i];
- #else
    char *buffer = alloca (i);
! #endif
    strcpy (buffer, prefix);
    for (i = 0; i < old_length; i++)
      {
--- 268,275 ----
    int prefix_len = strlen (prefix);
    int suffix_len = strlen (suffix);
    int i = prefix_len + old_length + suffix_len + 1;
    char *buffer = alloca (i);
! 
    strcpy (buffer, prefix);
    for (i = 0; i < old_length; i++)
      {
Index: java-opcodes.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-opcodes.h,v
retrieving revision 1.2
diff -c -3 -p -r1.2 java-opcodes.h
*** java-opcodes.h	16 Dec 1998 21:20:04 -0000	1.2
--- java-opcodes.h	17 Oct 2004 11:41:57 -0000
*************** enum java_opcode {
*** 2,5 ****
--- 2,6 ----
  #define JAVAOP(NAME, CODE, KIND, TYPE, VALUE) OPCODE_##NAME = CODE,
  #include "javaop.def"
  #undef JAVAOP
+ LAST_AND_UNUSED_JAVA_OPCODE
  };
Index: jcf-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-dump.c,v
retrieving revision 1.62
diff -c -3 -p -r1.62 jcf-dump.c
*** jcf-dump.c	25 Sep 2004 13:49:22 -0000	1.62
--- jcf-dump.c	17 Oct 2004 11:41:57 -0000
*************** disassemble_method (JCF* jcf, const unsi
*** 1181,1187 ****
  #define VAR_INDEX_2 (saw_index = 1, IMMEDIATE_u2)
  
  #define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > len ? \
!   (fprintf(stderr, _("Bad byte codes.\n")), exit(-1)) : 1)
  
  /* Print out operand (if not implied by the opcode) for PUSCH opcodes.
     These all push a constant onto the opcode stack. */
--- 1181,1187 ----
  #define VAR_INDEX_2 (saw_index = 1, IMMEDIATE_u2)
  
  #define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > len ? \
!   (fprintf(stderr, _("Bad byte codes.\n")), exit(-1), 0) : 1)
  
  /* Print out operand (if not implied by the opcode) for PUSCH opcodes.
     These all push a constant onto the opcode stack. */
Index: jcf-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-io.c,v
retrieving revision 1.52
diff -c -3 -p -r1.52 jcf-io.c
*** jcf-io.c	15 Oct 2004 18:43:10 -0000	1.52
--- jcf-io.c	17 Oct 2004 11:41:57 -0000
*************** caching_stat (char *filename, struct sta
*** 376,382 ****
  	 particular, the type of the function pointer passed as the
  	 third argument sometimes takes a "const struct dirent *"
  	 parameter, and sometimes just a "struct dirent *".  We cast
! 	 to (void *) so that either way it is quietly accepted.  */
        dent->num_files = scandir (filename, &dent->files, 
  				 (void *) java_or_class_file, 
  				 alphasort);
--- 376,383 ----
  	 particular, the type of the function pointer passed as the
  	 third argument sometimes takes a "const struct dirent *"
  	 parameter, and sometimes just a "struct dirent *".  We cast
! 	 to (void *) so that either way it is quietly accepted.
! 	 FIXME: scandir is not in POSIX.  */
        dent->num_files = scandir (filename, &dent->files, 
  				 (void *) java_or_class_file, 
  				 alphasort);
Index: verify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/verify.c,v
retrieving revision 1.65
diff -c -3 -p -r1.65 verify.c
*** verify.c	24 Jul 2004 00:03:28 -0000	1.65
--- verify.c	17 Oct 2004 11:41:57 -0000
*************** pop_argument_types (tree arg_types)
*** 404,410 ****
              { oldpc = LABEL_PC (tmplab); goto verify_error; }} while (0)
  
  #ifdef __GNUC__
! #define CHECK_PC_IN_RANGE(PC) ({if (PC < 0 || PC > length) goto bad_pc; (void)1;})
  #else
  #define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > length ? (abort (), 0) : 1)
  #endif
--- 404,411 ----
              { oldpc = LABEL_PC (tmplab); goto verify_error; }} while (0)
  
  #ifdef __GNUC__
! #define CHECK_PC_IN_RANGE(PC) __extension__ \
!   ({if (PC < 0 || PC > length) goto bad_pc; (void)1;})
  #else
  #define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > length ? (abort (), 0) : 1)
  #endif
Index: win32-host.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/win32-host.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 win32-host.c
*** win32-host.c	15 Oct 2004 14:55:00 -0000	1.6
--- win32-host.c	17 Oct 2004 11:41:57 -0000
*************** The Free Software Foundation is independ
*** 24,36 ****
  
  /* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */
  
- #ifdef WIN32
  
  #include "config.h"
  #include "system.h"
  #include "coretypes.h"
  #include "jcf.h"
  
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>
  #undef WIN32_LEAN_AND_MEAN
--- 24,37 ----
  
  /* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */
  
  
  #include "config.h"
  #include "system.h"
  #include "coretypes.h"
  #include "jcf.h"
  
+ #ifdef WIN32
+ 
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>
  #undef WIN32_LEAN_AND_MEAN

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Committed: Fix C99:ism (declaration after statement) in java FE.
  2004-10-17 13:22     ` Steven Bosscher
@ 2004-10-17 18:00       ` Zack Weinberg
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2004-10-17 18:00 UTC (permalink / raw)
  To: Steven Bosscher
  Cc: Hans-Peter Nilsson, Kaveh R. Ghazi, gcc-patches, java-patches

Steven Bosscher <stevenb@suse.de> writes:

> On Sunday 17 October 2004 12:59, Hans-Peter Nilsson wrote:
>> On Sat, 16 Oct 2004, Kaveh R. Ghazi wrote:
>> >  > Hope to look into adding -Wdeclaration-after-statement for all
>> >  > front-ends @WERROR@ settings (stage2 or where supported).
>> >
>> > No need for a new flag, just add -pedantic like the other FEs do.
>> > (Haven't tried it myself, probably requires cleaning other fallout.)
>>
>> Hmm, looks like you're right.  Tom Tromey mentioned on IRC that
>> he'd like more warnings enabled, so it seems this would be the
>> way to go.  Maybe I'll do it.
>
> I've just done it.  It's still bootstrapping on x86_64-suse-linux-gnu
> but I'm not expecting any problems (it's well into libjava now).
>
> OK if it completes bootstrapping and testing?

...

> ! # Use strict warnings for this front end.
> ! java-warn = $(STRICT_WARN) $(WERROR)

Don't put $(WERROR) here, it is handled separately.

> ! 	 to (void *) so that either way it is quietly accepted.
> ! 	 FIXME: scandir is not in POSIX.  */
>         dent->num_files = scandir (filename, &dent->files, 
>   				 (void *) java_or_class_file, 
>   				 alphasort);

Is the diagnostic for an implicit declaration?  If so, you really
ought to investigate where the prototype is supposed to be coming
from, and get it declared.  You don't have to fix this in this patch
though.

Otherwise OK.

zw

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-17 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-16 18:29 Committed: Fix C99:ism (declaration after statement) in java FE Hans-Peter Nilsson
2004-10-17  3:05 ` Kaveh R. Ghazi
2004-10-17 11:52   ` Hans-Peter Nilsson
2004-10-17 13:22     ` Steven Bosscher
2004-10-17 18:00       ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).