From f80aa3999d14e23d8e9cd81719b476c2e64116a0 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 14 Jan 2019 22:01:24 +0000 Subject: [PATCH] PR c++/88825 - ICE with bogus function return type deduction. * typeck.c (can_do_nrvo_p): Check error_mark_node. * g++.dg/cpp1y/auto-fn55.C: New test. From-SVN: r267926 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/auto-fn55.C | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/auto-fn55.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3c1a02f025e..a99ddb5313d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -4,6 +4,9 @@ * decl2.c (maybe_emit_vtables): Check CLASSTYPE_LAZY_DESTRUCTOR. Fix formatting. + PR c++/88825 - ICE with bogus function return type deduction. + * typeck.c (can_do_nrvo_p): Check error_mark_node. + 2019-01-14 Tom Honermann Implement P0482R5, char8_t: A type for UTF-8 characters and strings diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 88e2cd6ab9b..fc61991de35 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -9343,6 +9343,8 @@ is_std_move_p (tree fn) static bool can_do_nrvo_p (tree retval, tree functype) { + if (functype == error_mark_node) + return false; if (retval) STRIP_ANY_LOCATION_WRAPPER (retval); tree result = DECL_RESULT (current_function_decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 13bb87208a0..20c212c267a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-14 Marek Polacek + + PR c++/88825 - ICE with bogus function return type deduction. + * g++.dg/cpp1y/auto-fn55.C: New test. + 2019-01-14 Jakub Jelinek * g++.dg/cpp1z/feat-cxx1z.C: Add tests for diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn55.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn55.C new file mode 100644 index 00000000000..aea2740e1f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn55.C @@ -0,0 +1,8 @@ +// PR c++/88825 +// { dg-do compile { target c++14 } } + +auto f () -> auto * +{ + int t = 0; + return t; // { dg-error "unable to deduce" } +} -- 2.30.2