From ef98d365adbe44502de2af37e773cc474f4767c6 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 20 May 2016 16:24:58 +0000 Subject: [PATCH] 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 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 PR c++/70572 * g++.dg/cpp1y/auto-fn31.C: New. From-SVN: r236522 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/auto-fn31.C | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/auto-fn31.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dcd660f627c..06c38c67a9b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-05-20 Paolo Carlini + + 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 PR c++/71075 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7eabf53847f..7a69711bdb1 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 % 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 25edf4a571e..cb9363b9a88 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-20 Paolo Carlini + + PR c++/70572 + * g++.dg/cpp1y/auto-fn31.C: New. + 2016-05-20 H.J. Lu 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 00000000000..c99c59571e9 --- /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" } +} -- 2.11.4.GIT