This is the mail archive of the gcc-bugs@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]

Re: C: Gcc 2.95 gets a fatal signal 11 with -pedantic


> Gcc 2.95 gets a fatal signal 11 when it tries to compile the program:
> 
> __extension__ nonsense_keyword
> int main () 
> {
>   return 0;
> }

Thanks for your bug report. Here is a patch (I just noticed that I
should have modified c-parse.in; will do before I submit, and also
re-generate everything else).

Regards,
Martin

2000-01-16  Martin v. Löwis  <loewis@informatik.hu-berlin.de>

	* c-parse.in (SAVE_WARN_FLAGS): Create an INTEGER_CST.
	(RESTORE_WARN_FLAGS): Unpack it.
	(extdef, unary_expr, decl, component_decl): Convert semantic value
	to ttype.
	* c-common.c (split_specs_attrs): Expect an INTEGER_CST.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.c,v
retrieving revision 1.85
diff -u -p -r1.85 c-common.c
--- c-common.c	2000/01/13 00:37:06	1.85
+++ c-common.c	2000/01/16 22:35:08
@@ -1079,6 +1079,15 @@ split_specs_attrs (specs_attrs, declspec
 {
   tree t, s, a, next, specs, attrs;
 
+  /* This can happen after an __extension__ in pedantic mode.  */
+  if (specs_attrs != NULL_TREE 
+      && TREE_CODE (specs_attrs) == INTEGER_CST)
+    {
+      *declspecs = NULL_TREE;
+      *prefix_attributes = NULL_TREE;
+      return;
+    }
+
   /* This can happen in c++ (eg: decl: typespec initdecls ';').  */
   if (specs_attrs != NULL_TREE
       && TREE_CODE (specs_attrs) != TREE_LIST)
Index: c-parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-parse.y,v
retrieving revision 1.29
diff -u -p -r1.29 c-parse.y
--- c-parse.y	2000/01/12 22:47:12	1.29
+++ c-parse.y	2000/01/16 22:35:12
@@ -206,9 +206,11 @@ static int undeclared_variable_notice;
 
 /* For __extension__, save/restore the warning flags which are
    controlled by __extension__.  */
-#define SAVE_WARN_FLAGS() (pedantic | (warn_pointer_arith << 1))
-#define RESTORE_WARN_FLAGS(val) \
+#define SAVE_WARN_FLAGS()	\
+	build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
+#define RESTORE_WARN_FLAGS(tval) \
   do {                                     \
+    int val = TREE_INT_CST_LOW (tval);     \
     pedantic = val & 1;                    \
     warn_pointer_arith = (val >> 1) & 1;   \
   } while (0)
@@ -267,7 +269,7 @@ extdef:
 		  else
 		    error ("argument of `asm' is not a constant string"); }
 	| extension extdef
-		{ RESTORE_WARN_FLAGS ($1); }
+		{ RESTORE_WARN_FLAGS ($<ttype>1); }
 	;
 
 datadef:
@@ -404,7 +406,7 @@ unary_expr:
 	/* __extension__ turns off -pedantic for following primary.  */
 	| extension cast_expr	  %prec UNARY
 		{ $$ = $2;
-		  RESTORE_WARN_FLAGS ($1); }
+		  RESTORE_WARN_FLAGS ($<ttype>1); }
 	| unop cast_expr  %prec UNARY
 		{ $$ = build_unary_op ($1, $2, 0);
 		  overflow_warning ($$); }
@@ -861,7 +863,7 @@ decl:
 	| declmods ';'
 		{ pedwarn ("empty declaration"); }
 	| extension decl
-		{ RESTORE_WARN_FLAGS ($1); }
+		{ RESTORE_WARN_FLAGS ($<ttype>1); }
 	;
 
 /* Declspecs which contain at least one type specifier or typedef name.
@@ -1439,7 +1441,7 @@ component_decl:
 		{ $$ = NULL_TREE; }
 	| extension component_decl
 		{ $$ = $2;
-		  RESTORE_WARN_FLAGS ($1); }
+		  RESTORE_WARN_FLAGS ($<ttype>1); }
 	;
 
 components:

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