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 dcd660f..06c38c6 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 7eabf53..7a69711 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 25edf4a..cb9363b 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" }
+}