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]

Patch: java -vs- `strictfp'


This patch adds minimal `strictfp' support to gcj.  By minimal I mean
that gcj will now recognize strictfp as a keyword and reject programs
that use it as an identifier.  However, strictfp isn't integrated into
the parser or the rest of the compiler.

This patch also fixes some long-standing bugs in gcc/java/Make-lang.in
related to rebuilding keyword.h.

I've been running this patch for a week now with no ill effects.  It
does make us pass one more Jacks test.

Ok to commit?

2000-11-20  Tom Tromey  <tromey@cygnus.com>

	* lex.c (yylex): Added STRICT_TK case.
	* parse.y (STRICT_TK): Added.
	* parse-scan.y (STRICT_TK): Added.
	* Make-lang.in ($(srcdir)/java/keyword.h): Added missing `\' and
	`;'.  Use 4, not 3, with -k option.  Correctly rename resulting
	file.
	* keyword.h: Rebuilt.
	* keyword.gperf (strictfp): Added.

Tom

Index: lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lex.c,v
retrieving revision 1.52
diff -u -r1.52 lex.c
--- lex.c	2000/11/07 22:50:06	1.52
+++ lex.c	2000/11/20 21:28:44
@@ -1491,7 +1539,7 @@
 	    case PUBLIC_TK:       case PROTECTED_TK: case STATIC_TK:
 	    case ABSTRACT_TK:     case FINAL_TK:     case NATIVE_TK:
 	    case SYNCHRONIZED_TK: case TRANSIENT_TK: case VOLATILE_TK:
-	    case PRIVATE_TK:
+	    case PRIVATE_TK:      case STRICT_TK:
 	      SET_MODIFIER_CTX (kw->token);
 	      return MODIFIER_TK;
 	    case FLOAT_TK:
Index: parse-scan.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse-scan.y,v
retrieving revision 1.18
diff -u -r1.18 parse-scan.y
--- parse-scan.y	2000/08/08 03:33:36	1.18
+++ parse-scan.y	2000/11/20 21:28:46
@@ -140,6 +140,7 @@
 %token   STATIC_TK       FINAL_TK           SYNCHRONIZED_TK
 %token   VOLATILE_TK     TRANSIENT_TK       NATIVE_TK
 %token   PAD_TK          ABSTRACT_TK        MODIFIER_TK
+%token   STRICT_TK
 
 /* Keep those two in order, too */
 %token   DECR_TK INCR_TK
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.224
diff -u -r1.224 parse.y
--- parse.y	2000/11/13 13:23:37	1.224
+++ parse.y	2000/11/20 21:28:59
@@ -463,6 +463,7 @@
 %token   STATIC_TK       FINAL_TK           SYNCHRONIZED_TK
 %token   VOLATILE_TK     TRANSIENT_TK       NATIVE_TK
 %token   PAD_TK          ABSTRACT_TK        MODIFIER_TK
+%token   STRICT_TK
 
 /* Keep those two in order, too */
 %token   DECR_TK INCR_TK
Index: Make-lang.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/Make-lang.in,v
retrieving revision 1.42
diff -u -r1.42 Make-lang.in
--- Make-lang.in	2000/11/05 10:35:33	1.42
+++ Make-lang.in	2000/11/20 21:28:59
@@ -89,12 +89,12 @@
 
 $(srcdir)/java/keyword.h: $(srcdir)/java/keyword.gperf
 	(cd $(srcdir)/java || exit 1; \
-	gperf -L C -F ', 0' -p -t -j1 -i 1 -g -o -N java_keyword -k1,3,$$ \
-		keyword.gperf > k$$$$.h || {
+	gperf -L C -F ', 0' -p -t -j1 -i 1 -g -o -N java_keyword -k1,4,$$ \
+		keyword.gperf > k$$$$.h || { \
 	echo "Please update gperf from ftp://ftp.gnu.org/pub/gnu/gperf/" >&2; \
 	rm -f k$$$$.h; \
-	exit 1; } \
-	mv -f k$$$$.h keyword.gperf)
+	exit 1; } ; \
+	mv -f k$$$$.h keyword.h)
 
 # Executables built by this Makefile:
 JAVA_OBJS = java/parse.o java/class.o java/decl.o java/expr.o \
Index: keyword.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/keyword.h,v
retrieving revision 1.5
diff -u -r1.5 keyword.h
--- keyword.h	1999/08/25 13:59:27	1.5
+++ keyword.h	2000/11/20 21:28:59
@@ -1,5 +1,5 @@
-/* C code produced by gperf version 2.7.1 (19981006 egcs) */
-/* Command-line: gperf -L C -F , 0 -p -t -j1 -i 1 -g -o -N java_keyword -k1,3,$ keyword.gperf  */
+/* C code produced by gperf version 2.7 */
+/* Command-line: gperf -L C -F , 0 -p -t -j1 -i 1 -g -o -N java_keyword -k1,4,$ keyword.gperf  */
 /* Keyword definition for the GNU compiler for the Java(TM) language.
    Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
@@ -35,12 +35,12 @@
 #endif
 struct java_keyword *java_keyword	PARAMS ((const char *, unsigned int));
 
-#define TOTAL_KEYWORDS 50
+#define TOTAL_KEYWORDS 51
 #define MIN_WORD_LENGTH 2
 #define MAX_WORD_LENGTH 12
-#define MIN_HASH_VALUE 6
-#define MAX_HASH_VALUE 86
-/* maximum key range = 81, duplicates = 0 */
+#define MIN_HASH_VALUE 7
+#define MAX_HASH_VALUE 95
+/* maximum key range = 89, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -52,40 +52,41 @@
 {
   static unsigned char asso_values[] =
     {
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 18, 37, 38,
-      27,  1, 30,  3, 12,  8, 87,  2, 11, 87,
-       8,  1,  5, 87, 24,  1,  1, 30,  2, 36,
-      87,  1, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
-      87, 87, 87, 87, 87, 87
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96,  9, 17,  3,
+       1,  1, 20, 13, 15, 29, 96, 21,  1, 96,
+      35, 39,  1, 96, 15,  6,  2,  1, 41, 17,
+      96,  7, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
+      96, 96, 96, 96, 96, 96
     };
   register int hval = len;
 
   switch (hval)
     {
       default:
+      case 4:
+        hval += asso_values[(unsigned char)str[3]];
       case 3:
-        hval += asso_values[(unsigned char)str[2]];
       case 2:
       case 1:
         hval += asso_values[(unsigned char)str[0]];
@@ -104,70 +105,71 @@
 {
   static struct java_keyword wordlist[] =
     {
-      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
-      {"try", TRY_TK},
+      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
       {"else", ELSE_TK},
-      {"short", SHORT_TK},
-      {"goto", GOTO_TK},
+      {"true", TRUE_TK},
+      {"case", CASE_TK},
+      {"", 0},
+      {"public", PUBLIC_TK},
+      {"try", TRY_TK},
+      {"protected", PROTECTED_TK},
+      {"continue", CONTINUE_TK},
       {"extends", EXTENDS_TK},
-      {"", 0}, {"", 0},
-      {"int", INT_TK},
+      {"const", CONST_TK},
+      {"static", STATIC_TK},
       {"this", THIS_TK},
+      {"default", DEFAULT_TK},
+      {"class", CLASS_TK},
+      {"abstract", ABSTRACT_TK},
+      {"synchronized", SYNCHRONIZED_TK},
+      {"byte", BYTE_TK},
+      {"while", WHILE_TK},
+      {"double", DOUBLE_TK},
+      {"catch", CATCH_TK},
+      {"super", SUPER_TK},
+      {"short", SHORT_TK},
+      {"switch", SWITCH_TK},
+      {"package", PACKAGE_TK},
+      {"long", LONG_TK},
+      {"false", FALSE_TK},
       {"", 0},
-      {"native", NATIVE_TK},
-      {"", 0}, {"", 0},
+      {"int", INT_TK},
+      {"final", FINAL_TK},
+      {"float", FLOAT_TK},
+      {"char", CHAR_TK},
+      {"for", FOR_TK},
+      {"", 0},
       {"interface", INTERFACE_TK},
-      {"import", IMPORT_TK},
-      {"private", PRIVATE_TK},
-      {"volatile", VOLATILE_TK},
+      {"null", NULL_TK},
+      {"do", DO_TK},
+      {"finally", FINALLY_TK},
+      {"strictfp", STRICT_TK},
       {"", 0},
       {"implements", IMPLEMENTS_TK},
-      {"", 0},
-      {"long", LONG_TK},
-      {"switch", SWITCH_TK},
-      {"abstract", ABSTRACT_TK},
+      {"void", VOID_TK},
       {"transient", TRANSIENT_TK},
-      {"do", DO_TK},
       {"", 0},
+      {"private", PRIVATE_TK},
+      {"if", IF_TK},
+      {"break", BREAK_TK},
       {"throws", THROWS_TK},
       {"", 0},
-      {"null", NULL_TK},
-      {"super", SUPER_TK},
-      {"true", TRUE_TK},
-      {"float", FLOAT_TK},
+      {"new", NEW_TK},
       {"", 0},
       {"return", RETURN_TK},
-      {"if", IF_TK},
-      {"void", VOID_TK},
-      {"protected", PROTECTED_TK},
-      {"byte", BYTE_TK},
-      {"case", CASE_TK},
-      {"break", BREAK_TK},
-      {"finally", FINALLY_TK},
-      {"false", FALSE_TK},
-      {"synchronized", SYNCHRONIZED_TK},
-      {"instanceof", INSTANCEOF_TK},
-      {"while", WHILE_TK},
-      {"package", PACKAGE_TK},
-      {"const", CONST_TK},
+      {"", 0},
+      {"volatile", VOLATILE_TK},
       {"boolean", BOOLEAN_TK},
-      {"final", FINAL_TK},
-      {"continue", CONTINUE_TK},
-      {"catch", CATCH_TK},
-      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
-      {"class", CLASS_TK},
-      {"static", STATIC_TK},
-      {"double", DOUBLE_TK},
-      {"default", DEFAULT_TK},
+      {"instanceof", INSTANCEOF_TK},
+      {"", 0},
       {"throw", THROW_TK},
+      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
+      {"native", NATIVE_TK},
+      {"", 0}, {"", 0}, {"", 0}, {"", 0},
+      {"import", IMPORT_TK},
       {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
-      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
-      {"for", FOR_TK},
-      {"", 0},
-      {"new", NEW_TK},
-      {"char", CHAR_TK},
-      {"", 0},
-      {"public", PUBLIC_TK}
+      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
+      {"goto", GOTO_TK}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
Index: keyword.gperf
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/keyword.gperf,v
retrieving revision 1.4
diff -u -r1.4 keyword.gperf
--- keyword.gperf	1999/08/25 13:59:26	1.4
+++ keyword.gperf	2000/11/20 21:28:59
@@ -82,6 +82,7 @@
 goto, GOTO_TK
 package, PACKAGE_TK
 this, THIS_TK
+strictfp, STRICT_TK
 # true, false and null aren't keyword. But we match them easily this way
 true, TRUE_TK
 false, FALSE_TK

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