xref: /llvm-project/clang/test/SemaTemplate/instantiate-enum.cpp (revision 74f02347ca163e6d7bbd737ec8c3511f4185f7ea)
18fbe78f6SDaniel Dunbar // RUN: %clang_cc1 -fsyntax-only %s
2954f6b27SDouglas Gregor 
3954f6b27SDouglas Gregor template<typename T, T I, int J>
4954f6b27SDouglas Gregor struct adder {
5954f6b27SDouglas Gregor   enum {
6954f6b27SDouglas Gregor     value = I + J,
7954f6b27SDouglas Gregor     value2
8954f6b27SDouglas Gregor   };
9954f6b27SDouglas Gregor };
10954f6b27SDouglas Gregor 
11954f6b27SDouglas Gregor int array1[adder<long, 3, 4>::value == 7? 1 : -1];
12aff9c1a0SDouglas Gregor 
13aff9c1a0SDouglas Gregor namespace PR6375 {
14aff9c1a0SDouglas Gregor   template<typename T>
f()15aff9c1a0SDouglas Gregor   void f() {
16aff9c1a0SDouglas Gregor     enum Enum
17aff9c1a0SDouglas Gregor     {
18aff9c1a0SDouglas Gregor       enumerator1 = 0xFFFFFFF,
19aff9c1a0SDouglas Gregor       enumerator2 = enumerator1 - 1
20aff9c1a0SDouglas Gregor     };
21aff9c1a0SDouglas Gregor 
22aff9c1a0SDouglas Gregor     int xb1 = enumerator1;
23aff9c1a0SDouglas Gregor     int xe1 = enumerator2;
24aff9c1a0SDouglas Gregor   }
25aff9c1a0SDouglas Gregor 
26aff9c1a0SDouglas Gregor   template void f<int>();
27aff9c1a0SDouglas Gregor }
28fa1d4e10SPeter Collingbourne 
29fa1d4e10SPeter Collingbourne namespace EnumScoping {
30fa1d4e10SPeter Collingbourne 
31fa1d4e10SPeter Collingbourne template <typename T>
32*74f02347SRichard Smith struct C {
33*74f02347SRichard Smith   struct X {};
34fa1d4e10SPeter Collingbourne   enum {
35fa1d4e10SPeter Collingbourne     value = 42
36fa1d4e10SPeter Collingbourne   };
37fa1d4e10SPeter Collingbourne };
38fa1d4e10SPeter Collingbourne 
f(int i,C<int>::X c)39*74f02347SRichard Smith void f(int i, C<int>::X c) {
40fa1d4e10SPeter Collingbourne   int value;
41fa1d4e10SPeter Collingbourne }
42fa1d4e10SPeter Collingbourne 
43fa1d4e10SPeter Collingbourne }
44