From: Giovanni Bajo Date: Thu, 15 Jan 2004 23:49:13 +0000 (+0000) Subject: re PR c++/9259 (Calling a non-qualified member function within a sizeof() expression... X-Git-Tag: releases/gcc-3.4.0~926 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18eba5570b845f13b8efb8fddb53078db7597523;p=thirdparty%2Fgcc.git re PR c++/9259 (Calling a non-qualified member function within a sizeof() expression leads to "invalid use of undefined type") PR c++/9259 * g++.dg/expr/sizeof2.C: New test. From-SVN: r75951 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3655825e7175..c02a91a55130 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-01-15 Giovanni Bajo + + PR c++/9259 + * g++.dg/expr/sizeof2.C: New test. + 2004-01-15 Kazu Hirata * gcc.dg/sibcall-3.c: Replace mn10?00 with mn10300. diff --git a/gcc/testsuite/g++.dg/expr/sizeof2.C b/gcc/testsuite/g++.dg/expr/sizeof2.C new file mode 100644 index 000000000000..ca14ff79f72e --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/sizeof2.C @@ -0,0 +1,30 @@ +// { dg-do compile } +// Contributed by Wolfgang Bangerth +// PR c++/9259: Allow non-qualified member calls in sizeof expressions. + +template struct StaticAssert; +template <> struct StaticAssert {}; + +struct S +{ + static int check (); + static double check2 (); + static const int value = sizeof(check()); + static const int value2 = sizeof(check2()); +}; + +template +struct T +{ + static int check (); + static double check2 (); + static const int value = sizeof(check()); + static const int value2 = sizeof(check2()); +}; + +StaticAssert<(S::value == sizeof(int))> s; +StaticAssert<(S::value2 == sizeof(double))> s2; + +StaticAssert<(T::value == sizeof(int))> t; +StaticAssert<(T::value2 == sizeof(double))> t2; +