1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s
2 template<typename T
> int force_same(T
, T
);
5 // [...] If the underlying type is not fixed, the type of each enumerator is
6 // the type of its initializing value:
7 // - If an initializer is specified for an enumerator, the initializing
8 // value has the same type as the expression.
12 Bullet1Val1IsChar
= sizeof(force_same(Bullet1Val1
, char(0))),
13 Bullet1Val2IsUnsigned
= sizeof(force_same(Bullet1Val2
, unsigned(0)))
16 // - If no initializer is specified for the first enumerator, the
17 // initializing value has an unspecified integral type.
20 Bullet2ValIsInt
= sizeof(force_same(Bullet2Val
, int(0)))
23 // - Otherwise the type of the initializing value is the same as the type
24 // of the initializing value of the preceding enumerator unless the
25 // incremented value is not representable in that type, in which case the
26 // type is an unspecified integral type sufficient to contain the
27 // incremented value. If no such type exists, the program is ill-formed.
31 Bullet3aVal2IsInt
= sizeof(force_same(Bullet3aVal2
, int(0))),
32 Bullet3aVal3
= 2147483647,
33 Bullet3aVal3IsInt
= sizeof(force_same(Bullet3aVal3
, int(0))),
35 Bullet3aVal4IsUnsigned
= sizeof(force_same(Bullet3aVal4
, 0ul))
41 Bullet3bVal2IsInt
= sizeof(force_same(Bullet3bVal2
, 0u)),
42 Bullet3bVal3
= 2147483647u,
43 Bullet3bVal3IsInt
= sizeof(force_same(Bullet3bVal3
, 0u)),
45 Bullet3bVal4IsUnsigned
= sizeof(force_same(Bullet3bVal4
, 0ul))
49 Bullet3cVal1
= 0xFFFFFFFFFFFFFFFEull
,
51 Bullet3cVal3
// expected-warning{{not representable}}
54 // Following the closing brace of an enum-specifier, each enumerator has the
55 // type of its enumeration.
56 int array0
[sizeof(force_same(Bullet3bVal3
, Bullet3b(0)))? 1 : -1];