[PATCH] Fix PR c/35436: ICE with -Wformat

Volker Reichelt v.reichelt@netcologne.de
Thu Apr 17 08:24:00 GMT 2008


On  1 Apr, Joseph S. Myers wrote:
> On Tue, 1 Apr 2008, Volker Reichelt wrote:
> 
>> The following patch fixes an ICE with format checking. We currently
>> crash if the format "%L" is checked and the "locus" type is invalid.
>> Fixed by ignoring invalid locus types.
>> 
>> Bootstrapped and regtested on i686-pc-linux-gnu.
>> Ok for mainline?
> 
> OK.


Is this OK for the 4.3 and 4.2 branch, too?
I bootstrapped and regtested the patch there, too.

Regards,
Volker


2008-04-01  Volker Reichelt  <v.reichelt@netcologne.de>

	PR c/35436
	* c-format.c (init_dynamic_gfc_info): Ignore invalid locus type.

===================================================================
--- gcc/c-format.c	2008-03-20 17:13:53 +0100
+++ gcc/c-format.c	2008-03-30 16:13:38 +0200
@@ -2455,7 +2455,8 @@ init_dynamic_gfc_info (void)
 	  locus = identifier_global_value (locus);
 	  if (locus)
 	    {
-	      if (TREE_CODE (locus) != TYPE_DECL)
+	      if (TREE_CODE (locus) != TYPE_DECL
+		  || TREE_TYPE (locus) == error_mark_node)
 		{
		  error ("%<locus%> is not defined as a type");
 		  locus = 0;
===================================================================

2008-04-01  Volker Reichelt  <v.reichelt@netcologne.de>

	PR c/35436
	* gcc.dg/format/gcc_gfc-2.c: New test.

===================================================================
--- gcc/testsuite/gcc.dg/format/gcc_gfc-2.c    2003-09-23 19:59:22 +0200
+++ gcc/testsuite/gcc.dg/format/gcc_gfc-2.c    2008-03-30 16:40:39 +0200
@@ -0,0 +1,13 @@
+/* PR c/35436 */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+typedef void locus[1]; /* { dg-error "array of void" } */
+
+void foo(const char*, ...)
+  __attribute__((__format__(__gcc_gfc__, 1, 2))); /* { dg-error "locus" } */
+
+void bar()
+{
+  foo("%L", 0); /* { dg-warning "format" }  */
+}
===================================================================



More information about the Gcc-patches mailing list