]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58582 ([c++11] ICE defining and instantiating deleted template function)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 3 May 2014 22:44:22 +0000 (22:44 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 3 May 2014 22:44:22 +0000 (22:44 +0000)
/cp
2014-05-03  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58582
* decl.c (grokfndecl): Check duplicate_decls return value for
error_mark_node.
* pt.c (instantiate_decl): A deleted function is defined.

/testsuite
2014-05-03  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58582
* g++.dg/cpp0x/deleted4.C: New.
* g++.dg/cpp0x/deleted5.C: Likewise.
* g++.dg/cpp0x/deleted6.C: Likewise.

From-SVN: r210043

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

index d15fed166cf32cc4e92d9ccbc1275eeda5b2b6b6..374cd0f6a5e9e32519d8df04fe308049fbebac4e 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58582
+       * decl.c (grokfndecl): Check duplicate_decls return value for
+       error_mark_node.
+       * pt.c (instantiate_decl): A deleted function is defined.
+
 2014-05-02  Jason Merrill  <jason@redhat.com>
 
        * decl2.c (vague_linkage_p): Local statics have vague linkage.
index 202db35d3c85504e4fa72df5941047d4023448b4..ffaff5c52c84eb3e5ad8cfec11fab678cd64ef5d 100644 (file)
@@ -7822,6 +7822,8 @@ grokfndecl (tree ctype,
                     decl, ctype);
              return NULL_TREE;
            }
+         if (ok == error_mark_node)
+           return NULL_TREE;
          return old_decl;
        }
     }
index 1584eb9045deb34aef3533e0834563aa88967f67..7e7f6d89f0dcfe28d98be2df8d6066df08e62756 100644 (file)
@@ -19620,7 +19620,8 @@ instantiate_decl (tree d, int defer_ok,
 
   if (TREE_CODE (d) == FUNCTION_DECL)
     pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE
-                      || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern));
+                      || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern)
+                      || DECL_DELETED_FN (code_pattern));
   else
     pattern_defined = ! DECL_IN_AGGR_P (code_pattern);
 
@@ -19862,14 +19863,17 @@ instantiate_decl (tree d, int defer_ok,
                       tf_warning_or_error, tmpl,
                       /*integral_constant_expression_p=*/false);
 
-         /* Set the current input_location to the end of the function
-            so that finish_function knows where we are.  */
-         input_location
-           = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus;
-
-         /* Remember if we saw an infinite loop in the template.  */
-         current_function_infinite_loop
-           = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop;
+         if (DECL_STRUCT_FUNCTION (code_pattern))
+           {
+             /* Set the current input_location to the end of the function
+                so that finish_function knows where we are.  */
+             input_location
+               = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus;
+
+             /* Remember if we saw an infinite loop in the template.  */
+             current_function_infinite_loop
+               = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop;
+           }
        }
 
       /* We don't need the local specializations any more.  */
index 06e3fa4e380244515777fe4ac305a4f39c54c026..3b613d9c7cbc2cef1a6d2e9106c514ddf01efa86 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58582
+       * g++.dg/cpp0x/deleted4.C: New.
+       * g++.dg/cpp0x/deleted5.C: Likewise.
+       * g++.dg/cpp0x/deleted6.C: Likewise.
+
 2014-05-03  Dominique d'Humieres <dominiq@lps.ens.fr>
 
        PR fortran/61025
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted4.C b/gcc/testsuite/g++.dg/cpp0x/deleted4.C
new file mode 100644 (file)
index 0000000..22439d4
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/58582
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<int> void foo() = delete;
+};
+
+template<int> void A::foo() { int i; } // { dg-error "redefinition" }
+
+template void A::foo<0>();
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted5.C b/gcc/testsuite/g++.dg/cpp0x/deleted5.C
new file mode 100644 (file)
index 0000000..51010ef
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/58582
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<int> void foo() = delete;
+};
+
+template<int> void A::foo() {} // { dg-error "redefinition" }
+
+template void A::foo<0>();
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted6.C b/gcc/testsuite/g++.dg/cpp0x/deleted6.C
new file mode 100644 (file)
index 0000000..af25b50
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/58582
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<int> void foo() = delete;
+};
+
+template void A::foo<0>();