xref: /aosp_15_r20/external/clang/test/CXX/conv/conv.prom/p4.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
2*67e74705SXin Li // expected-no-diagnostics
3*67e74705SXin Li 
4*67e74705SXin Li enum X : short { A, B };
5*67e74705SXin Li extern decltype(+A) x;
6*67e74705SXin Li extern int x;
7*67e74705SXin Li 
8*67e74705SXin Li enum Y : long { C, D };
9*67e74705SXin Li extern decltype(+C) y;
10*67e74705SXin Li extern long y;
11*67e74705SXin Li 
12*67e74705SXin Li // An enum with a fixed underlying type has an integral promotion to that type,
13*67e74705SXin Li // and to its promoted type.
14*67e74705SXin Li enum B : bool { false_, true_ };
15*67e74705SXin Li template<bool> struct T {};
16*67e74705SXin Li T<false_> f;
17*67e74705SXin Li T<true_> t;
18*67e74705SXin Li // FIXME: DR1407 will make this ill-formed
19*67e74705SXin Li T<+true_> q; // desired-error {{conversion from 'int' to 'bool'}}
20*67e74705SXin Li 
21*67e74705SXin Li enum B2 : bool {
22*67e74705SXin Li   a = false,
23*67e74705SXin Li   b = true,
24*67e74705SXin Li   c = false_,
25*67e74705SXin Li   d = true_,
26*67e74705SXin Li   // FIXME: DR1407 will make this ill-formed
27*67e74705SXin Li   e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
28*67e74705SXin Li };
29