This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: java/7738 Patch: Turn off assert keyword recognition


On Sat, 2002-09-28 at 18:29, Anthony Green wrote:
> 
> This patch lets users turn off recognition of the `assert' keyword.  Tested
> on x86 Linux.  This fixes a regression of sorts, since this is now required
> in order to build older java source bases, like jython.

I sent the wrong version of the patch.  This one has an important
missing bit (stripping -f[no-]assert before calling cc1).


2002-09-28  Anthony Green  <green@redhat.com>

	* gcj.texi (Invoking jv-scan): Add --no-assert documentation.
	(Code Generation): Add -fno-assert documentation.
	* jv-scan.c (flag_assert): New global.
	(options): Add assert option.
	(help): Add --no-assert documentation.
	* parse-scan.y (flag_assert): New global.
	* lang.c (lang_f_options): Add -fassert/-fno-assert support.
	(flag_assert): New global.
	* java-tree.h (flag_assert): New global.
	* lex.c (java_lex): Obey flag_assert.
	* jvspec.c (jvgenmain_spec): Strip -fassert/-fno-assert when
	calling cc1.
  
  	* expr.c (build_java_array_length_access): Check for null pointer.
Index: gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.36
diff -c -r1.36 gcj.texi
*** gcj.texi	2 Sep 2002 15:36:07 -0000	1.36
--- gcj.texi	29 Sep 2002 01:56:40 -0000
***************
*** 428,433 ****
--- 428,437 ----
  @command{gcj} to generate stubs which will invoke the underlying JNI
  methods.
  
+ @item -fno-assert
+ Don't recognize the @code{assert} keyword.  This is for compatibility
+ with older versions of the language specification.
+ 
  @item -fno-optimize-static-class-initialization
  When the optimization level is greater or equal to @code{-O2},
  @command{gcj} will try to optimize the way calls into the runtime are made
***************
*** 622,629 ****
  
  @ignore
  @c man begin SYNOPSIS jv-scan
! jv-scan [@option{--complexity}] [@option{--encoding}=@var{name}]
!     [@option{--print-main}] [@option{--list-class}] [@option{--list-filename}]
      [@option{--version}] [@option{--help}]
      [@option{-o} @var{file}] @var{inputfile}@dots{}
  @c man end
--- 626,634 ----
  
  @ignore
  @c man begin SYNOPSIS jv-scan
! jv-scan [@option{--no-assert}] [@option{--complexity}] 
!     [@option{--encoding}=@var{name}] [@option{--print-main}] 
!     [@option{--list-class}] [@option{--list-filename}]
      [@option{--version}] [@option{--help}]
      [@option{-o} @var{file}] @var{inputfile}@dots{}
  @c man end
***************
*** 634,639 ****
--- 639,649 ----
  @end ignore
  
  @c man begin OPTIONS jv-scan
+ 
+ @table @gcctabopt
+ @item --no-assert
+ Don't recognize the @code{assert} keyword, for backwards compatibility
+ with older versions of the language specification.
  
  @table @gcctabopt
  @item --complexity
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.156
diff -c -r1.156 java-tree.h
*** java-tree.h	21 Sep 2002 02:19:44 -0000	1.156
--- java-tree.h	29 Sep 2002 01:56:42 -0000
***************
*** 160,165 ****
--- 160,169 ----
  
  extern int flag_filelist_file;
  
+ /* When nonzero, permit the use of the assert keyword.  */
+ 
+ extern int flag_assert;
+ 
  /* When nonzero, assume all native functions are implemented with
     JNI, not CNI.  */
  
Index: jv-scan.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jv-scan.c,v
retrieving revision 1.29
diff -c -r1.29 jv-scan.c
*** jv-scan.c	1 Feb 2002 21:07:31 -0000	1.29
--- jv-scan.c	29 Sep 2002 01:56:42 -0000
***************
*** 64,69 ****
--- 64,70 ----
  int flag_dump_class = 0;
  int flag_list_filename = 0;
  int flag_complexity = 0;
+ int flag_assert = 1;
  
  int pedantic = 0;
  
***************
*** 85,90 ****
--- 86,93 ----
    { "list-class", no_argument,      &flag_dump_class, 1 },
    { "encoding",  required_argument, NULL, OPT_ENCODING },
    { "complexity", no_argument,	    &flag_complexity, 1 },
+   { "no-assert", no_argument,       &flag_assert, 0 },
+   { "assert",    no_argument,       &flag_assert, 1 },
    { NULL,        no_argument,       NULL, 0 }
  };
  
***************
*** 100,105 ****
--- 103,109 ----
  {
    printf ("Usage: jv-scan [OPTION]... FILE...\n\n");
    printf ("Print useful information read from Java source files.\n\n");
+   printf ("  --no-assert             Don't recognize the assert keyword\n");
    printf ("  --complexity            Print cyclomatic complexity of input file\n");
    printf ("  --encoding NAME         Specify encoding of input file\n");
    printf ("  --print-main            Print name of class containing `main'\n");
Index: jvspec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jvspec.c,v
retrieving revision 1.57
diff -c -r1.57 jvspec.c
*** jvspec.c	21 Sep 2002 02:19:44 -0000	1.57
--- jvspec.c	29 Sep 2002 01:56:42 -0000
***************
*** 62,68 ****
  		   %{v:-version} %{pg:-p} %{p}\
  		   %{<fbounds-check} %{<fno-bounds-check}\
  		   %{<fassume-compiled} %{<fno-assume-compiled}\
!                    %{<fcompile-resource*}\
  		   %{<femit-class-file} %{<femit-class-files} %{<fencoding*}\
  		   %{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\
  		   %{<findirect-dispatch} \
--- 62,68 ----
  		   %{v:-version} %{pg:-p} %{p}\
  		   %{<fbounds-check} %{<fno-bounds-check}\
  		   %{<fassume-compiled} %{<fno-assume-compiled}\
!                    %{<fcompile-resource*} %{<fassert} %{<fno-assert} \
  		   %{<femit-class-file} %{<femit-class-files} %{<fencoding*}\
  		   %{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\
  		   %{<findirect-dispatch} \
Index: lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.109
diff -c -r1.109 lang.c
*** lang.c	21 Sep 2002 02:19:44 -0000	1.109
--- lang.c	29 Sep 2002 01:56:42 -0000
***************
*** 147,152 ****
--- 147,155 ----
     object to its synchronization structure.  */
  int flag_hash_synchronization;
  
+ /* When nonzero, permit the use of the assert keyword.  */
+ int flag_assert = 1;
+ 
  /* When nonzero, assume all native functions are implemented with
     JNI, not CNI.  */
  int flag_jni = 0;
***************
*** 205,211 ****
    {"force-classes-archive-check", &flag_force_classes_archive_check, 1},
    {"optimize-static-class-initialization", &flag_optimize_sci, 1 },
    {"indirect-dispatch", &flag_indirect_dispatch, 1},
!   {"store-check", &flag_store_check, 1}
  };
  
  static const struct string_option
--- 208,215 ----
    {"force-classes-archive-check", &flag_force_classes_archive_check, 1},
    {"optimize-static-class-initialization", &flag_optimize_sci, 1 },
    {"indirect-dispatch", &flag_indirect_dispatch, 1},
!   {"store-check", &flag_store_check, 1},
!   {"no-assert", &flag_assert, 0}
  };
  
  static const struct string_option
Index: lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.91
diff -c -r1.91 lex.c
*** lex.c	17 Sep 2002 20:59:53 -0000	1.91
--- lex.c	29 Sep 2002 01:56:43 -0000
***************
*** 1604,1609 ****
--- 1604,1618 ----
  	      SET_LVAL_NODE (null_pointer_node);
  	      return NULL_TK;
  
+ 	    case ASSERT_TK:
+ 	      if (flag_assert)
+ 		{
+ 		  BUILD_OPERATOR (kw->token);
+ 		  return kw->token;
+ 		}
+ 	      else
+ 		break;
+ 
  	      /* Some keyword we want to retain information on the location
  		 they where found.  */
  	    case CASE_TK:
***************
*** 1617,1623 ****
  	    case CATCH_TK:
  	    case THROW_TK:
  	    case INSTANCEOF_TK:
- 	    case ASSERT_TK:
  	      BUILD_OPERATOR (kw->token);
  
  	    default:
--- 1626,1631 ----
Index: parse-scan.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse-scan.y,v
retrieving revision 1.23
diff -c -r1.23 parse-scan.y
*** parse-scan.y	11 Jun 2002 17:31:11 -0000	1.23
--- parse-scan.y	29 Sep 2002 01:56:43 -0000
***************
*** 135,140 ****
--- 135,142 ----
  }
  
  %{
+ extern int flag_assert;
+ 
  #include "lex.c"
  %}
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]