[C PATCH] Fix ICE due to clearing of C_TYPE_INCOMPLETE_VARS (PR c/71685)

Jakub Jelinek jakub@redhat.com
Tue Jun 28 19:07:00 GMT 2016


Hi!

The following testcase ICEs because C_TYPE_INCOMPLETE_VARS is cleared even
on the main type, while it should be cleared only on the variant types.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk/6.2?

2016-06-28  Jakub Jelinek  <jakub@redhat.com>

	PR c/71685
	* c-typeck.c (c_build_qualified_type): Don't clear
	C_TYPE_INCOMPLETE_VARS for the main variant.

	* gcc.dg/pr71685.c: New test.

--- gcc/c/c-typeck.c.jj	2016-06-21 08:51:40.000000000 +0200
+++ gcc/c/c-typeck.c	2016-06-28 17:53:19.282187787 +0200
@@ -13669,7 +13669,8 @@ c_build_qualified_type (tree type, int t
 		   : build_qualified_type (type, type_quals));
   /* A variant type does not inherit the list of incomplete vars from the
      type main variant.  */
-  if (RECORD_OR_UNION_TYPE_P (var_type))
+  if (RECORD_OR_UNION_TYPE_P (var_type)
+      && TYPE_MAIN_VARIANT (var_type) != var_type)
     C_TYPE_INCOMPLETE_VARS (var_type) = 0;
   return var_type;
 }
--- gcc/testsuite/gcc.dg/pr71685.c.jj	2016-06-28 17:43:07.885806691 +0200
+++ gcc/testsuite/gcc.dg/pr71685.c	2016-06-28 17:42:50.000000000 +0200
@@ -0,0 +1,6 @@
+/* PR c/71685 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu11" } */
+
+extern struct S v, s;
+struct S { int t; int p[]; } v = { 4, 0 };

	Jakub



More information about the Gcc-patches mailing list