re PR c++/92447 (ICE in poplevel, at cp/decl.c:585)
authorJakub Jelinek <jakub@redhat.com>
Mon, 11 Nov 2019 21:31:29 +0000 (22:31 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 11 Nov 2019 21:31:29 +0000 (22:31 +0100)
PR c++/92447
* decl.c (finish_function): Move ctype initialization before
DECL_DELETED_FN handling.

* g++.dg/cpp0x/pr92447.C: New test.

From-SVN: r278068

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr92447.C [new file with mode: 0644]

index 81811a41a3863d750c3c4cbbdc55e5265fec0f05..a5bc9d452ce77d2ff1c1372e170fd675f8bf2f54 100644 (file)
@@ -1,5 +1,9 @@
 2019-11-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/92447
+       * decl.c (finish_function): Move ctype initialization before
+       DECL_DELETED_FN handling.
+
        * semantics.c (finish_translation_unit): Diagnose declare target
        without corresponding end declare target.
 
index 5c5a85e3221e6886f8f7dbc42ea2220b4ca849de..caa04afe805bff3e16a46af5161a9b5cf8bf3868 100644 (file)
@@ -16803,6 +16803,10 @@ finish_function (bool inline_p)
        }
     }
 
+  /* Remember that we were in class scope.  */
+  if (current_class_name)
+    ctype = current_class_type;
+
   if (DECL_DELETED_FN (fndecl))
     {
       DECL_INITIAL (fndecl) = error_mark_node;
@@ -16861,10 +16865,6 @@ finish_function (bool inline_p)
       current_function_return_value = NULL_TREE;
     }
 
-  /* Remember that we were in class scope.  */
-  if (current_class_name)
-    ctype = current_class_type;
-
   /* Must mark the RESULT_DECL as being in this function.  */
   DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
 
index 138afb2d5a9c91c2c304876c2511baa2619fad69..872495bbae7cda29058e757292313249f40e380b 100644 (file)
@@ -1,5 +1,8 @@
 2019-11-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/92447
+       * g++.dg/cpp0x/pr92447.C: New test.
+
        * c-c++-common/gomp/declare-target-5.c: New test.
 
 2019-11-11  Richard Sandiford  <richard.sandiford@arm.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr92447.C b/gcc/testsuite/g++.dg/cpp0x/pr92447.C
new file mode 100644 (file)
index 0000000..f332e80
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/92447
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+void
+foo ()
+{
+  struct S { S &operator=(S &&x) = default; const T s{}; };
+}
+
+void bar ()
+{
+  foo<int>();
+}