summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/enum.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/enum.cpp')
-rw-r--r--test/SemaCXX/enum.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
new file mode 100644
index 0000000..9668c84
--- /dev/null
+++ b/test/SemaCXX/enum.cpp
@@ -0,0 +1,38 @@
+// 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 {
+ A = 0,
+ B = 1
+} Foo;
+
+
+void bar() {
+ Foo myvar = A;
+ myvar = B;
+}
+
+/// 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) {
+ return q->bar(); // expected-error{{return type of called function ('enum s1::e1') is incomplete}}
+}
+
+enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
OpenPOWER on IntegriCloud