re PR c/71685 (Segmentation fault in gcc when compiling the attached file.)
authorJakub Jelinek <jakub@gcc.gnu.org>
Tue, 28 Jun 2016 22:30:04 +0000 (00:30 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 28 Jun 2016 22:30:04 +0000 (00:30 +0200)
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.

From-SVN: r237830

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr71685.c [new file with mode: 0644]

index 403f267b612b0459d84bd5838409211cdfb4370d..df73934ca94a962a18f1ba8dc35f7a5781fca5e2 100644 (file)
@@ -1,4 +1,10 @@
-2016-06-28 Martin Sebor  <msebor@redhat.com>
+2016-06-29  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.
+
+2016-06-28  Martin Sebor  <msebor@redhat.com>
 
        PR c/71552
        * c-typeck.c (output_init_element): Diagnose incompatible types
index 818ad944f3fc2fd5e8573100cb1f67134c04c596..56268fcc843dc031ccdd880285ad12e8171d45ba 100644 (file)
@@ -13676,7 +13676,8 @@ c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
                   : 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;
 }
index 5fb67e13288f346b01de7ed73579c50e4db8b5d7..171e616d04523cd10dbdb6c806309b36c9c64107 100644 (file)
@@ -1,4 +1,9 @@
-2016-06-28 Martin Sebor  <msebor@redhat.com>
+2016-06-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/71685
+       * gcc.dg/pr71685.c: New test.
+
+2016-06-28  Martin Sebor  <msebor@redhat.com>
 
        PR c/71552
        * gcc.dg/init-bad-9.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr71685.c b/gcc/testsuite/gcc.dg/pr71685.c
new file mode 100644 (file)
index 0000000..80e5c8f
--- /dev/null
@@ -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 };