diff options
author | Giovanni Bajo <giovannibajo@gcc.gnu.org> | 2004-01-15 23:49:13 +0000 |
---|---|---|
committer | Giovanni Bajo <giovannibajo@gcc.gnu.org> | 2004-01-15 23:49:13 +0000 |
commit | 18eba5570b845f13b8efb8fddb53078db7597523 (patch) | |
tree | beecc091552b929ef6549a3a13d4deadff6db201 | |
parent | e9c4897b2805a915da5685c57e48f5fd16855d29 (diff) | |
download | gcc-18eba5570b845f13b8efb8fddb53078db7597523.zip gcc-18eba5570b845f13b8efb8fddb53078db7597523.tar.gz gcc-18eba5570b845f13b8efb8fddb53078db7597523.tar.bz2 |
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
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/sizeof2.C | 30 |
2 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3655825..c02a91a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org> + + PR c++/9259 + * g++.dg/expr/sizeof2.C: New test. + 2004-01-15 Kazu Hirata <kazu@cs.umass.edu> * 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 0000000..ca14ff7 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/sizeof2.C @@ -0,0 +1,30 @@ +// { dg-do compile } +// Contributed by Wolfgang Bangerth <bangerth at ticam dot utexas dot edu> +// PR c++/9259: Allow non-qualified member calls in sizeof expressions. + +template <bool> struct StaticAssert; +template <> struct StaticAssert<true> {}; + +struct S +{ + static int check (); + static double check2 (); + static const int value = sizeof(check()); + static const int value2 = sizeof(check2()); +}; + +template <class> +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<void>::value == sizeof(int))> t; +StaticAssert<(T<void>::value2 == sizeof(double))> t2; + |