Fix for ICE with -g on testcase with incomplete types.
authorJim Wilson <jim.wilson@linaro.org>
Wed, 28 Oct 2015 20:02:01 +0000 (20:02 +0000)
committerJim Wilson <wilson@gcc.gnu.org>
Wed, 28 Oct 2015 20:02:01 +0000 (13:02 -0700)
gcc/c/
PR debug/66068
* c-typeck.c (c_build_qualified_type): Clear C_TYPE_INCOMPLETE_VARS
after calling build_qualified_type.
gcc/testsuite/
PR debug/66068
* gcc.dg/debug/pr66068.c: New test.

From-SVN: r229505

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

index 78597bec2683636be35575053f39e28b5e88c2f7..d203f9d5bef6ed6068e64f706062514c17f1c2e4 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-26  Jim Wilson  <jim.wilson@linaro.org>
+
+       PR debug/66068
+       * c-typeck.c (c_build_qualified_type): Clear C_TYPE_INCOMPLETE_VARS
+       after calling build_qualified_type.
+
 2015-10-27  Cesar Philippidis  <cesar@codesourcery.com>
            Thomas Schwinge  <thomas@codesourcery.com>
            James Norris  <jnorris@codesourcery.com>
index 64ea1c272f893e15aea2c629ebf7db0711686a1d..1b0b9e2a6d700dd9907a58eb4c6a48c882c85e1e 100644 (file)
@@ -13126,7 +13126,13 @@ c_build_qualified_type (tree type, int type_quals)
       type_quals &= ~TYPE_QUAL_RESTRICT;
     }
 
-  return build_qualified_type (type, type_quals);
+  tree var_type = build_qualified_type (type, type_quals);
+  /* A variant type does not inherit the list of incomplete vars from the
+     type main variant.  */
+  if (TREE_CODE (var_type) == RECORD_TYPE
+      || TREE_CODE (var_type) == UNION_TYPE)
+    C_TYPE_INCOMPLETE_VARS (var_type) = 0;
+  return var_type;
 }
 
 /* Build a VA_ARG_EXPR for the C parser.  */
index 05cad86be4455e7fb3f2e5e3b5265d1ce6e06d89..711fbb55c2e238b39ec370efd6bd4d82e3f8edfa 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-26  Jim Wilson  <jim.wilson@linaro.org>
+
+       PR debug/66068
+       * gcc.dg/debug/pr66068.c: New test.
+
 2015-01-28  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/67933
diff --git a/gcc/testsuite/gcc.dg/debug/pr66068.c b/gcc/testsuite/gcc.dg/debug/pr66068.c
new file mode 100644 (file)
index 0000000..d9cd905
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+struct S a;
+const struct S b;
+struct S
+{
+};
+
+union U c;
+const union U d;
+union U
+{
+};