xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/enum-bitfield.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc enum E {};
4f4a2713aSLionel Sambuc 
5f4a2713aSLionel Sambuc struct Z {};
6f4a2713aSLionel Sambuc typedef int Integer;
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc struct X {
9f4a2713aSLionel Sambuc   enum E : 1;
10f4a2713aSLionel Sambuc   enum E : Z; // expected-error{{invalid underlying type}}
11f4a2713aSLionel Sambuc   enum E2 : int;
12f4a2713aSLionel Sambuc   enum E3 : Integer;
13f4a2713aSLionel Sambuc };
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc struct Y {
16f4a2713aSLionel Sambuc   enum E : int(2);
17f4a2713aSLionel Sambuc   enum E : Z(); // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'Z'}}
18f4a2713aSLionel Sambuc };
19*0a6a1f1dSLionel Sambuc 
20*0a6a1f1dSLionel Sambuc namespace pr18587 {
21*0a6a1f1dSLionel Sambuc struct A {
22*0a6a1f1dSLionel Sambuc   enum class B {
23*0a6a1f1dSLionel Sambuc     C
24*0a6a1f1dSLionel Sambuc   };
25*0a6a1f1dSLionel Sambuc };
26*0a6a1f1dSLionel Sambuc const int C = 4;
27*0a6a1f1dSLionel Sambuc struct D {
28*0a6a1f1dSLionel Sambuc   A::B : C;
29*0a6a1f1dSLionel Sambuc };
30*0a6a1f1dSLionel Sambuc }
31