re PR c++/48115 (internal compiler error: in type_has_nontrivial_copy_init, at cp...
authorJason Merrill <jason@redhat.com>
Wed, 16 Mar 2011 20:03:46 +0000 (16:03 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 16 Mar 2011 20:03:46 +0000 (16:03 -0400)
PR c++/48115
* call.c (convert_arg_to_ellipsis): Handle incomplete type.

From-SVN: r171066

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/incomplete6.C [new file with mode: 0644]

index 8a4082941d932b65d9c5d430bd7152875e041f91..336c22e808c928bb3b0c3a4a4fe840af2d14f930 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-16  Jason Merrill  <jason@redhat.com>
+
+       PR c++/48115
+       * call.c (convert_arg_to_ellipsis): Handle incomplete type.
+
 2011-03-16  Jason Merrill  <jason@redhat.com>
 
        * parser.c (cp_parser_abort_tentative_parse): Make sure we haven't
index 388f46cdf49f68ba99f2d4498708aa45fee8071c..f75c2485e31476ea8419698e4b33e87483de5a4b 100644 (file)
@@ -5671,6 +5671,10 @@ convert_arg_to_ellipsis (tree arg)
   arg_type = TREE_TYPE (arg);
 
   if (arg != error_mark_node
+      /* In a template (or ill-formed code), we can have an incomplete type
+        even after require_complete_type, in which case we don't know
+        whether it has trivial copy or not.  */
+      && COMPLETE_TYPE_P (arg_type)
       && (type_has_nontrivial_copy_init (arg_type)
          || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (arg_type)))
     {
index 72f30d8215a944be05ea8de1c0c717cf60c261c7..ca82c7409c7547f40ef8bfa87c04801fd4277edd 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-16  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/template/incomplete6.C: New.
+
 2011-03-16  Jeff Law <law@redhat.com>
 
        * gcc.dg/tree-ssa/vrp55.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/incomplete6.C b/gcc/testsuite/g++.dg/template/incomplete6.C
new file mode 100644 (file)
index 0000000..7138b6a
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/48115
+
+template<typename> struct templ { };
+
+template<typename T> T declval();
+
+typedef int (*F2)(...);
+
+template<int> struct Int { };
+
+template<typename F, typename T>
+struct S
+{
+    template<typename A>
+        Int<sizeof( declval<F>()(T()) )>
+        f(A);
+};
+
+int main()
+{
+    S<F2, templ<int> >().f(0);
+}