aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2016-05-20 16:24:58 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2016-05-20 16:24:58 +0000
commitef98d365adbe44502de2af37e773cc474f4767c6 (patch)
tree5d5d0bdbb739ed3a26cf2a1880515d6e8be04119
parentce3a16ff1f59e6dbf9aa128ede0138927cceee38 (diff)
downloadgcc-ef98d365adbe44502de2af37e773cc474f4767c6.zip
gcc-ef98d365adbe44502de2af37e773cc474f4767c6.tar.gz
gcc-ef98d365adbe44502de2af37e773cc474f4767c6.tar.bz2
re PR c++/70572 (ICE on code with decltype (auto) in digest_init_r, at cp/typeck2.c:1103 with -std=c++14)
/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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/auto-fn31.C7
4 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index dcd660f..06c38c6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7eabf53..7a69711 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 25edf4a..cb9363b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..c99c595
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn31.C
@@ -0,0 +1,7 @@
+// PR c++/70572
+// { dg-do compile { target c++14 } }
+
+void foo ()
+{
+ decltype (auto) a = foo; // { dg-error "initializer" }
+}