blob: 156dfd62088462068ad8f224a4d8597547e689f3 [file] [log] [blame]
Douglas Gregor93afb0d2008-12-12 07:27:10 +00001// RUN: clang -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 {
29 enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}}
30};
31
32enum e1 { YES, NO };
33
34static enum e1 badfunc(struct s1 *q) {
Douglas Gregor24c46b32009-03-19 04:25:59 +000035 return q->bar(); // expected-error{{incompatible type returning 'enum s1::e1', expected 'enum e1'}}
Douglas Gregor80711a22009-03-06 18:34:03 +000036}
37
38enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}