re PR c++/79654 (ICE on invalid c++ code in register_dtor_fn in cp/decl.c:7877)
authorJakub Jelinek <jakub@redhat.com>
Tue, 21 Feb 2017 18:00:35 +0000 (19:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 Feb 2017 18:00:35 +0000 (19:00 +0100)
PR c++/79654
* decl.c (cp_finish_decomp): Don't set decl's type to error_mark_node
on error.
* pt.c (tsubst_decomp_names): Return error_mark_node if the first
decl after the decomposition artificial decl has error_mark_node.
* decl2.c (prune_vars_needing_no_initialization): Use error_operand_p
instead of just == error_mark_node comparison.

* g++.dg/cpp1z/decomp26.C: New test.

Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>
From-SVN: r245639

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/decomp26.C [new file with mode: 0644]

index a63eb4be2a58197219c3c29e9816d1ccc0e665a1..82225414bf7d9452cc511181e83d05d84a29769c 100644 (file)
@@ -1,3 +1,14 @@
+2017-02-21  Jakub Jelinek  <jakub@redhat.com>
+           Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/79654
+       * decl.c (cp_finish_decomp): Don't set decl's type to error_mark_node
+       on error.
+       * pt.c (tsubst_decomp_names): Return error_mark_node if the first
+       decl after the decomposition artificial decl has error_mark_node.
+       * decl2.c (prune_vars_needing_no_initialization): Use error_operand_p
+       instead of just == error_mark_node comparison.
+
 2017-02-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/79589
index 5ab9a20c829cc9fc7fc49013c378049762c633f4..fa1d645e1efd979260f3a9052193c245196507ba 100644 (file)
@@ -7386,7 +7386,6 @@ cp_finish_decomp (tree decl, tree first, unsigned int count)
            }
          first = DECL_CHAIN (first);
        }
-      TREE_TYPE (decl) = error_mark_node;
       if (DECL_P (decl) && DECL_NAMESPACE_SCOPE_P (decl))
        SET_DECL_ASSEMBLER_NAME (decl, get_identifier ("<decomp>"));
       return;
index d2e57ffe917aaa866fbdea4d3f8a0a5738de1540..b50fadf050db0e34616c420f6a715f8c0fc1e20f 100644 (file)
@@ -3879,7 +3879,7 @@ prune_vars_needing_no_initialization (tree *vars)
       tree init = TREE_PURPOSE (t);
 
       /* Deal gracefully with error.  */
-      if (decl == error_mark_node)
+      if (error_operand_p (decl))
        {
          var = &TREE_CHAIN (t);
          continue;
index 2cac24f071450c769aab8716895fac71be6a41af..c29e691b44c75547560f4244cf66f6d342ca4a1f 100644 (file)
@@ -15610,6 +15610,11 @@ tsubst_decomp_names (tree decl, tree pattern_decl, tree args,
        && DECL_NAME (decl2);
        decl2 = DECL_CHAIN (decl2))
     {
+      if (TREE_TYPE (decl2) == error_mark_node && *cnt == 0)
+       {
+         gcc_assert (errorcount);
+         return error_mark_node;
+       }
       (*cnt)++;
       gcc_assert (DECL_HAS_VALUE_EXPR_P (decl2));
       tree v = DECL_VALUE_EXPR (decl2);
index abefa2db56adceca2ddae915048645ce4d9e3999..1262b2eaa79700bb78d324cf5b7d35de32d28915 100644 (file)
@@ -1,5 +1,8 @@
 2017-02-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/79654
+       * g++.dg/cpp1z/decomp26.C: New test.
+
        PR sanitizer/79589
        * g++.dg/ubsan/pr79589.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp26.C b/gcc/testsuite/g++.dg/cpp1z/decomp26.C
new file mode 100644 (file)
index 0000000..f413920
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/79654
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template<typename T> T &make();        // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .+1 }
+auto [d1, d2] = make<int>();   // { dg-error "cannot decompose non-array non-class type" }