blob: db256812ab807e93bfbddfcadfa8a700c0189afc [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 {
Eli Friedmane7c6f7a2009-03-22 22:00:50 +000028 enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}} expected-note{{forward declaration of 'enum s1::e1'}}
Douglas Gregor80711a22009-03-06 18:34:03 +000029};
30
31enum e1 { YES, NO };
32
33static enum e1 badfunc(struct s1 *q) {
Anders Carlsson8c8d9192009-10-09 23:51:55 +000034 return q->bar(); // expected-error{{calling function with incomplete return type 'enum s1::e1'}}
Douglas Gregor80711a22009-03-06 18:34:03 +000035}
36
37enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}