blob: c7748c31ba0cf92290ebb0789535da870119a7b2 [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) {
35 // FIXME: the message below should probably give context information
36 // in those types.
37 return q->bar(); // expected-error{{incompatible type returning 'enum e1', expected 'enum e1'}}
38}
39
40enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}