From: Jason Merrill Date: Fri, 9 Apr 2010 15:20:58 +0000 (-0400) Subject: re PR c++/42623 ([C++0x] Function template default arguments: Invalid expressions... X-Git-Tag: releases/gcc-4.6.0~7980 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb6addf4a64fca93edee920a0014b73afd80adb1;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 74eb521187c6..2b3338e2c9a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2010-04-09 Jason Merrill + 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 32dc21e93af0..5772b833df00 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 51895eeccd3d..ea156f67b0d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-09 Jason Merrill + + PR c++/42623 + * g++.dg/template/sizeof13.C: New. + 2010-04-09 Kai Tietz * 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 000000000000..2f4a26e509d5 --- /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) involves applying sizeof to +// an incomplete class, so it is removed by SFINAE. +// { dg-do link } + +struct undef; + +template struct A { A(int); }; +template void f(A); + +template struct B { B(int) { } }; +template void f(B) { } + +int main() +{ + f(0); +}