diff options
author | Jason Merrill <jason@redhat.com> | 2010-04-09 11:20:58 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-04-09 11:20:58 -0400 |
commit | cb6addf4a64fca93edee920a0014b73afd80adb1 (patch) | |
tree | a2bf79f50c99b47d455df41064956fe68fea2b12 | |
parent | 93e9807aa58db6181185ec664e23022ae2ce6725 (diff) | |
download | gcc-cb6addf4a64fca93edee920a0014b73afd80adb1.zip gcc-cb6addf4a64fca93edee920a0014b73afd80adb1.tar.gz gcc-cb6addf4a64fca93edee920a0014b73afd80adb1.tar.bz2 |
re PR c++/42623 ([C++0x] Function template default arguments: Invalid expressions are allowed)
PR c++/42623
* c-common.c (c_sizeof_or_alignof_type): Return error_mark_node
for incomplete type.
From-SVN: r158167
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-common.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/sizeof13.C | 17 |
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 74eb521..2b3338e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/c-common.c b/gcc/c-common.c index 32dc21e..5772b83 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 51895ee..ea156f6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..2f4a26e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof13.C @@ -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); +} |