re PR c++/47544 ([C++0x] linker does not find =default constructor for explicitly...
authorJason Merrill <jason@redhat.com>
Mon, 23 May 2011 15:32:19 +0000 (11:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 23 May 2011 15:32:19 +0000 (11:32 -0400)
PR c++/47544
* pt.c (instantiate_decl): Handle =default.

From-SVN: r174071

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

index a1b0aec802d09b79a2024530f5c439740af61243..f4f04f20f0f462394ed46282fc00061cb5f5ea68 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47544
+       * pt.c (instantiate_decl): Handle =default.
+
        PR c++/48617
        * pt.c (invalid_nontype_parm_type_p): Allow DECLTYPE_TYPE.
 
index 380b21efbca9bd60f40b1345ceb80ac7de540ed3..429973302c761ff69b911dfb560b289ac158321c 100644 (file)
@@ -17432,7 +17432,8 @@ instantiate_decl (tree d, int defer_ok,
     args = gen_args;
 
   if (TREE_CODE (d) == FUNCTION_DECL)
-    pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE);
+    pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE
+                      || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern));
   else
     pattern_defined = ! DECL_IN_AGGR_P (code_pattern);
 
@@ -17627,6 +17628,8 @@ instantiate_decl (tree d, int defer_ok,
       cp_finish_decl (d, init, const_init, NULL_TREE, 0);
       pop_nested_class ();
     }
+  else if (TREE_CODE (d) == FUNCTION_DECL && DECL_DEFAULTED_FN (code_pattern))
+    synthesize_method (d);
   else if (TREE_CODE (d) == FUNCTION_DECL)
     {
       htab_t saved_local_specializations;
index 47f0dac09912412cc4f8742bb5a216acb342bad3..3c18295fa6de1183e07010296594a96d0bbf50d2 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-23  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/defaulted27.C: New.
+
        * g++.dg/cpp0x/decltype27.C: New.
 
 2011-05-23  Richard Guenther  <rguenther@suse.de>
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted27.C b/gcc/testsuite/g++.dg/cpp0x/defaulted27.C
new file mode 100644 (file)
index 0000000..7d9139d
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/47544
+// { dg-options -std=c++0x }
+// { dg-final { scan-assembler "_ZN1sIiEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZN1sIiED2Ev" } }
+
+template <typename T>
+struct s {
+  s();
+  ~s() = default;
+};
+
+extern template struct s<int>;
+
+template <typename T>
+s<T>::s() = default;
+
+template struct s<int>;
+
+s<int> a;