]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/71516 (ICE on invalid C++ code (invalid use of forward declared type) on...
authorJakub Jelinek <jakub@redhat.com>
Tue, 14 Jun 2016 14:33:11 +0000 (16:33 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 14 Jun 2016 14:33:11 +0000 (16:33 +0200)
PR c++/71516
* decl.c (complete_vars): Handle gracefully type == error_mark_node.

* g++.dg/init/pr71516.C: New test.

From-SVN: r237445

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/pr71516.C [new file with mode: 0644]

index 64acdc814580ae0ddea70ce902504db99755a4c5..d006305bdc00bb942eda69f3fbbc37c1473396a6 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71516
+       * decl.c (complete_vars): Handle gracefully type == error_mark_node.
+
 2016-06-14  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * typeck2.c (digest_init_r): Use EXPR_LOC_OR_LOC on init.
index 415689f535fdc908b8bf2be8961b608865b8c17f..20e7307ddad7bd5444201467b512ee8e0e9dfff4 100644 (file)
@@ -15029,8 +15029,9 @@ complete_vars (tree type)
          tree var = iv->decl;
          tree type = TREE_TYPE (var);
 
-         if (TYPE_MAIN_VARIANT (strip_array_types (type))
-             == iv->incomplete_type)
+         if (type != error_mark_node
+             && (TYPE_MAIN_VARIANT (strip_array_types (type))
+                 == iv->incomplete_type))
            {
              /* Complete the type of the variable.  The VAR_DECL itself
                 will be laid out in expand_expr.  */
index 3addc24998ffc788d9fd28ee69702b355ba4a57a..0e3c9cd7738a90dc4cef4d10c476365e981068cc 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71516
+       * g++.dg/init/pr71516.C: New test.
+
 2016-06-14  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.dg/init/array46.C: New.
diff --git a/gcc/testsuite/g++.dg/init/pr71516.C b/gcc/testsuite/g++.dg/init/pr71516.C
new file mode 100644 (file)
index 0000000..0b9aec4
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/71516
+// { dg-do compile }
+
+struct A;      // { dg-message "forward declaration of" }
+struct B
+{ 
+  static A a;
+};
+A B::a = A();  // { dg-error "has initializer but incomplete type|invalid use of incomplete type" }
+struct A {};
This page took 0.122162 seconds and 5 git commands to generate.