]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/42623 ([C++0x] Function template default arguments: Invalid expressions...
authorJason Merrill <jason@redhat.com>
Fri, 9 Apr 2010 15:20:58 +0000 (11:20 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 9 Apr 2010 15:20:58 +0000 (11:20 -0400)
PR c++/42623
* c-common.c (c_sizeof_or_alignof_type): Return error_mark_node
for incomplete type.

From-SVN: r158167

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/sizeof13.C [new file with mode: 0644]

index 74eb521187c6a3ed26f7c13fcf6e54d76348bf2f..2b3338e2c9a57c3d4e9fe80fad8135c5e3654c2f 100644 (file)
@@ -1,5 +1,9 @@
 2010-04-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/42623
+       * c-common.c (c_sizeof_or_alignof_type): Return error_mark_node
+       for incomplete type.
+
        PR c++/41788
        * stor-layout.c (finalize_record_size): Don't change TYPE_PACKED
        based on a warning flag.
index 32dc21e93af05c70e1567ff8036c186bc7564317..5772b833df000f842100a54c77e7caed555d3f63 100644 (file)
@@ -4390,7 +4390,7 @@ c_sizeof_or_alignof_type (location_t loc,
       if (complain)
        error_at (loc, "invalid application of %qs to incomplete type %qT ",
                  op_name, type);
-      value = size_zero_node;
+      return error_mark_node;
     }
   else
     {
index 51895eeccd3d044fe23c79412aa8784acc706113..ea156f67b0d01c803017d48c34c1d48dc7ba415d 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/42623
+       * g++.dg/template/sizeof13.C: New.
+
 2010-04-09  Kai Tietz  <kai.tietz@onevision.com>
 
        * g++.dg/other/pr35504.C: Add check for thiscall.
diff --git a/gcc/testsuite/g++.dg/template/sizeof13.C b/gcc/testsuite/g++.dg/template/sizeof13.C
new file mode 100644 (file)
index 0000000..2f4a26e
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/42623
+// We should choose f(B) because f(A<undef>) involves applying sizeof to
+// an incomplete class, so it is removed by SFINAE.
+// { dg-do link }
+
+struct undef;
+
+template <typename U, int N = sizeof(U)> struct A { A(int); };
+template <typename U> void f(A<U>);
+
+template <typename U> struct B { B(int) { } };
+template <typename U> void f(B<U>) { }
+
+int main()
+{
+  f<undef>(0);
+}