summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/expr/sizeof2.C
blob: ca14ff79f72e1d64a643a18a53892a5ba8790816 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;