re PR c++/70572 (ICE on code with decltype (auto) in digest_init_r, at cp/typeck2...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 20 May 2016 16:24:58 +0000 (16:24 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 20 May 2016 16:24:58 +0000 (16:24 +0000)
/cp
2016-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70572
* decl.c (cp_finish_decl): Check do_auto_deduction return value
and return immediately in case of erroneous code.

/testsuite
2016-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70572
* g++.dg/cpp1y/auto-fn31.C: New.

From-SVN: r236522

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/auto-fn31.C [new file with mode: 0644]

index dcd660f627c0d1032a87dacc1553a419072fe8db..06c38c67a9b70d546ed42248376f36f9611819f1 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70572
+       * decl.c (cp_finish_decl): Check do_auto_deduction return value
+       and return immediately in case of erroneous code.
+
 2016-05-19  Marek Polacek  <polacek@redhat.com>
 
        PR c++/71075
index 7eabf53847f07405fe308c03cca0dc1b899c4346..7a69711bdb1973a119ace70ea6b9605c1e884763 100644 (file)
@@ -6609,6 +6609,13 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
                                                    adc_variable_type);
       if (type == error_mark_node)
        return;
+      if (TREE_CODE (type) == FUNCTION_TYPE)
+       {
+         error ("initializer for %<decltype(auto) %D%> has function type "
+                "(did you forget the %<()%> ?)", decl);
+         TREE_TYPE (decl) = error_mark_node;
+         return;
+       }
       cp_apply_type_quals_to_decl (cp_type_quals (type), decl);
     }
 
index 25edf4a571e80bc279316237783af3f8c75140f4..cb9363b9a88ab55b623f41e56d77620461ce93d0 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70572
+       * g++.dg/cpp1y/auto-fn31.C: New.
+
 2016-05-20  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/70738
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn31.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn31.C
new file mode 100644 (file)
index 0000000..c99c595
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/70572
+// { dg-do compile { target c++14 } }
+
+void foo ()
+{
+  decltype (auto) a = foo;  // { dg-error "initializer" }
+}