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]

Warnings fixes, java subdir


This converts java/lex.c to use do_float_handler, which silences a
pile of warnings about variables clobbered by longjmp.

It also corrects dependencies so java/parse.c isn't rebuilt if you
change java/lex.c (the proper dependency is parse.o -> lex.c).

zw

	* Makefile.in (PARSE_C, PARSE_SCAN_C): Move dependencies on
	lex.c, lex.h, and PARSE_H to...
	(parse.o, parse-scan.o): ...here, respectively.

	* lex.c: Split out code that may trigger SIGFPE from yylex()
	to its own function.
	* lex.h (JAVA_FLOAT_RANGE_ERROR): Don't set value.

===================================================================
Index: java/Makefile.in
--- java/Makefile.in	2000/01/09 14:30:28	1.46
+++ java/Makefile.in	2000/02/01 21:25:31
@@ -217,12 +217,11 @@ PARSE_C = $(PARSE_DIR)/parse.c
 PARSE_SCAN_C = $(PARSE_DIR)/parse-scan.c
 PARSE_H = $(srcdir)/parse.h
 
-$(PARSE_C):  $(srcdir)/parse.y $(srcdir)/lex.c $(PARSE_H) $(srcdir)/lex.h
+$(PARSE_C): $(srcdir)/parse.y
 	$(SET_BISON); \
 	cd $(PARSE_DIR) && $$bison -t $(BISONFLAGS) $(JAVABISONFLAGS) \
 	    -o parse.c $(PARSE_RELDIR)/parse.y
-$(PARSE_SCAN_C):  $(srcdir)/parse-scan.y $(srcdir)/lex.c $(PARSE_H) \
-	  $(srcdir)/lex.h
+$(PARSE_SCAN_C): $(srcdir)/parse-scan.y
 	$(SET_BISON); \
 	cd $(PARSE_DIR) && $$bison -t $(BISONFLAGS) -o parse-scan.c \
 	    $(PARSE_RELDIR)/parse-scan.y
@@ -262,7 +261,8 @@ clean:  mostlyclean
 force:
 
 parse.o : $(PARSE_C) jcf-reader.c $(CONFIG_H) $(srcdir)/../system.h \
-  $(srcdir)/../function.h $(JAVA_TREE_H)
+  $(srcdir)/../function.h $(JAVA_TREE_H) $(srcdir)/lex.c $(PARSE_H) \
+  $(srcdir)/lex.h
 jcf-dump.o : $(CONFIG_H) $(srcdir)/../system.h $(JAVA_TREE_H) jcf-dump.c \
   jcf-reader.c jcf.h javaop.h javaop.def
 gjavah.o : $(CONFIG_H) $(srcdir)/../system.h $(JAVA_TREE_H) gjavah.c \
@@ -300,7 +300,8 @@ lang.o : lang.c $(CONFIG_H) $(JAVA_TREE_
   $(srcdir)/../toplev.h $(srcdir)/../system.h $(RTL_H) $(EXPR_H)
 mangle.o : mangle.c $(CONFIG_H) jcf.h $(JAVA_TREE_H) $(srcdir)/../system.h \
   $(srcdir)/../toplev.h
-parse-scan.o : $(CONFIG_H) $(srcdir)/../system.h $(srcdir)/../toplev.h
+parse-scan.o : $(CONFIG_H) $(srcdir)/../system.h $(srcdir)/../toplev.h \
+  $(srcdir)/lex.c $(PARSE_H) $(srcdir)/lex.h
 typeck.o : typeck.c $(CONFIG_H) $(JAVA_TREE_H) jcf.h convert.h \
   $(srcdir)/../toplev.h $(srcdir)/../system.h
 verify.o : verify.c $(CONFIG_H) $(JAVA_TREE_H) jcf.h javaop.h java-opcodes.h \
===================================================================
Index: java/lex.c
--- java/lex.c	2000/01/21 20:57:00	1.35
+++ java/lex.c	2000/02/01 21:25:31
@@ -517,6 +517,44 @@ java_parse_escape_sequence ()
     }
 }
 
+/* Isolate the code which may raise an arithmetic exception in its
+   own function.  */
+
+#ifndef JC1_LITE
+struct jpa_args
+{
+  YYSTYPE *java_lval;
+  char *literal_token;
+  int fflag;
+  int number_beginning;
+};
+
+static void java_perform_atof	PARAMS ((PTR));
+
+static void
+java_perform_atof (av)
+     PTR av;
+{
+  struct jpa_args *a = (struct jpa_args *)av;
+  YYSTYPE *java_lval = a->java_lval;
+  int number_beginning = a->number_beginning;
+  REAL_VALUE_TYPE value;
+  tree type = (a->fflag ? FLOAT_TYPE_NODE : DOUBLE_TYPE_NODE);
+
+  SET_REAL_VALUE_ATOF (value,
+		       REAL_VALUE_ATOF (a->literal_token, TYPE_MODE (type)));
+
+  if (REAL_VALUE_ISINF (value)
+      || REAL_VALUE_ISNAN (value))
+    {
+      JAVA_FLOAT_RANGE_ERROR ((a->fflag ? "float" : "double"));
+      value = DCONST0;
+    }
+
+  SET_LVAL_NODE_TYPE (build_real (type, value), type);
+}
+#endif
+
 static int yylex		PARAMS ((YYSTYPE *));
 
 static int
@@ -762,12 +800,9 @@ java_lex (java_lval)
 		}
 	      else
 		{
-		  jmp_buf handler;
-		  REAL_VALUE_TYPE value;
 #ifndef JC1_LITE
-		  tree type = (fflag ? FLOAT_TYPE_NODE : DOUBLE_TYPE_NODE);
+		  struct jpa_args a;
 #endif
-
 		  if (stage != 4) /* Don't push back fF/dD */
 		    java_unget_unicode ();
 		  
@@ -778,28 +813,16 @@ java_lex (java_lval)
 		  literal_token [literal_index] = '\0';
 		  JAVA_LEX_LIT (literal_token, radix);
 
-		  if (setjmp (handler))
-		    {
-		      JAVA_FLOAT_RANGE_ERROR ((fflag ? "float" : "double"));
-		      value = DCONST0;
-		    }
-		  else
-		    {
-		      SET_FLOAT_HANDLER (handler);
-		      SET_REAL_VALUE_ATOF 
-		        (value, REAL_VALUE_ATOF (literal_token, 
-						 TYPE_MODE (type)));
-
-		      if (REAL_VALUE_ISINF (value))
-			JAVA_FLOAT_RANGE_ERROR ((fflag ? "float" : "double"));
-
-		      if (REAL_VALUE_ISNAN (value))
-			JAVA_FLOAT_RANGE_ERROR ((fflag ? "float" : "double"));
-
-		      SET_LVAL_NODE_TYPE (build_real (type, value), type);
-		      SET_FLOAT_HANDLER (NULL_PTR);
-		      return FP_LIT_TK;
-		    }
+#ifndef JC1_LITE
+		  a.literal_token = literal_token;
+		  a.fflag = fflag;
+		  a.java_lval = java_lval;
+		  a.number_beginning = number_beginning;
+		  if (do_float_handler (java_perform_atof, (PTR) &a))
+		    return FP_LIT_TK;
+
+		  JAVA_FLOAT_RANGE_ERROR ((fflag ? "float" : "double"));
+#endif
 		}
 	    }
 	} /* JAVA_ASCCI_FPCHAR (c) */
===================================================================
Index: java/lex.h
--- java/lex.h	2000/01/21 20:57:00	1.14
+++ java/lex.h	2000/02/01 21:25:31
@@ -180,7 +180,6 @@ extern void set_float_handler PARAMS ((j
     sprintf (msg, "Floating pointer literal exceeds range of `%s'", (m)); \
     java_lex_error (msg, 0);						  \
     ctxp->c_line->current = i;						  \
-    value = dconst0;							  \
   }
 #define JAVA_INTEGRAL_RANGE_ERROR(m)		\
   {						\

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