2008-12-12 15:27:10 +08:00
|
|
|
// RUN: clang -fsyntax-only -verify %s
|
|
|
|
enum E {
|
|
|
|
Val1,
|
|
|
|
Val2
|
|
|
|
};
|
|
|
|
|
|
|
|
int& enumerator_type(int);
|
|
|
|
float& enumerator_type(E);
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
E e = Val1;
|
|
|
|
float& fr = enumerator_type(Val2);
|
|
|
|
}
|
2009-01-17 03:38:23 +08:00
|
|
|
|
|
|
|
// <rdar://problem/6502934>
|
|
|
|
typedef enum Foo {
|
|
|
|
A = 0,
|
|
|
|
B = 1
|
|
|
|
} Foo;
|
|
|
|
|
|
|
|
|
|
|
|
void bar() {
|
|
|
|
Foo myvar = A;
|
|
|
|
myvar = B;
|
|
|
|
}
|
2009-03-07 02:34:03 +08:00
|
|
|
|
|
|
|
/// PR3688
|
|
|
|
struct s1 {
|
|
|
|
enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum e1 { YES, NO };
|
|
|
|
|
|
|
|
static enum e1 badfunc(struct s1 *q) {
|
2009-03-19 12:25:59 +08:00
|
|
|
return q->bar(); // expected-error{{incompatible type returning 'enum s1::e1', expected 'enum e1'}}
|
2009-03-07 02:34:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
|