blob: 1aba107a69dad15dd12b2d7bd0645ac6e3da1c02 [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 {
Mike Stump1eb44332009-09-09 15:08:12 +000017 A = 0,
18 B = 1
Douglas Gregor66b947f2009-01-16 19:38:23 +000019} Foo;
Mike Stump1eb44332009-09-09 15:08:12 +000020
Douglas Gregor66b947f2009-01-16 19:38:23 +000021void bar() {
Mike Stump1eb44332009-09-09 15:08:12 +000022 Foo myvar = A;
23 myvar = B;
Douglas Gregor66b947f2009-01-16 19:38:23 +000024}
Douglas Gregor80711a22009-03-06 18:34:03 +000025
26/// PR3688
27struct s1 {
John McCall50234372009-12-04 00:07:04 +000028 enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}}
Douglas Gregor80711a22009-03-06 18:34:03 +000029};
30
31enum e1 { YES, NO };
32
33static enum e1 badfunc(struct s1 *q) {
John McCall50234372009-12-04 00:07:04 +000034 return q->bar();
Douglas Gregor80711a22009-03-06 18:34:03 +000035}
36
37enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}