freebsd-dev/test/SemaCXX/enum.cpp

38 lines
729 B
C++
Raw Normal View History

2009-06-02 17:58:47 +00:00
// RUN: clang-cc -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);
}
// <rdar://problem/6502934>
typedef enum Foo {
2009-10-14 18:03:49 +00:00
A = 0,
B = 1
2009-06-02 17:58:47 +00:00
} Foo;
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
void bar() {
2009-10-14 18:03:49 +00:00
Foo myvar = A;
myvar = B;
2009-06-02 17:58:47 +00:00
}
/// PR3688
struct s1 {
enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}} expected-note{{forward declaration of 'enum s1::e1'}}
};
enum e1 { YES, NO };
static enum e1 badfunc(struct s1 *q) {
2009-10-14 18:03:49 +00:00
return q->bar(); // expected-error{{calling function with incomplete return type 'enum s1::e1'}}
2009-06-02 17:58:47 +00:00
}
enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}