blob: 9668c84693d3cdb5808b820fc9ed5aa687ffcab0 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor93afb0d2008-12-12 07:27:10 +00002enum E {
3 Val1,
4 Val2
5};
6
7int& enumerator_type(int);
8float& enumerator_type(E);
9
10void f() {
11 E e = Val1;
12 float& fr = enumerator_type(Val2);
13}
Douglas Gregor66b947f2009-01-16 19:38:23 +000014
15// <rdar://problem/6502934>
16typedef enum Foo {
17 A = 0,
18 B = 1
19} Foo;
20
21
22void bar() {
23 Foo myvar = A;
24 myvar = B;
25}
Douglas Gregor80711a22009-03-06 18:34:03 +000026
27/// PR3688
28struct s1 {
Eli Friedmane7c6f7a2009-03-22 22:00:50 +000029 enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}} expected-note{{forward declaration of 'enum s1::e1'}}
Douglas Gregor80711a22009-03-06 18:34:03 +000030};
31
32enum e1 { YES, NO };
33
34static enum e1 badfunc(struct s1 *q) {
Eli Friedmane7c6f7a2009-03-22 22:00:50 +000035 return q->bar(); // expected-error{{return type of called function ('enum s1::e1') is incomplete}}
Douglas Gregor80711a22009-03-06 18:34:03 +000036}
37
38enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}