PR c++/88825 - ICE with bogus function return type deduction.
authorMarek Polacek <polacek@redhat.com>
Mon, 14 Jan 2019 22:01:24 +0000 (22:01 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 14 Jan 2019 22:01:24 +0000 (22:01 +0000)
* typeck.c (can_do_nrvo_p): Check error_mark_node.

* g++.dg/cpp1y/auto-fn55.C: New test.

From-SVN: r267926

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

index 3c1a02f025e2521282d775bbd685bccc03aa2d27..a99ddb5313dca1a0a6439e7a4f506fe382dbdf6b 100644 (file)
@@ -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  <tom@honermann.net>
 
        Implement P0482R5, char8_t: A type for UTF-8 characters and strings
index 88e2cd6ab9bcff2367f3d9e3d4556088de06b119..fc61991de350b88307fe6790f08df39504b3aaae 100644 (file)
@@ -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);
index 13bb87208a04d45598ee816c638d3aa09b473fc0..20c212c267aaca5f67161b93cebd96c336617340 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-14  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88825 - ICE with bogus function return type deduction.
+       * g++.dg/cpp1y/auto-fn55.C: New test.
+
 2019-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        * 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 (file)
index 0000000..aea2740
--- /dev/null
@@ -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" }
+}