summaryrefslogtreecommitdiff
path: root/test/SemaCXX/type-definition-in-specifier.cpp
diff options
context:
space:
mode:
authorSerge Pavlov <sepavloff@gmail.com>2014-06-25 17:09:41 +0000
committerSerge Pavlov <sepavloff@gmail.com>2014-06-25 17:09:41 +0000
commit525f68c5da062214c9bca4d85b9febf8d8ebef5b (patch)
tree7fc0531c1115848f1c980bd2a7773df895e2a921 /test/SemaCXX/type-definition-in-specifier.cpp
parentee276c176ee1e682a793c8b6da4ca5895622ac00 (diff)
downloadclang-525f68c5da062214c9bca4d85b9febf8d8ebef5b.tar.gz
clang-525f68c5da062214c9bca4d85b9febf8d8ebef5b.tar.bz2
clang-525f68c5da062214c9bca4d85b9febf8d8ebef5b.tar.xz
Fix treatment of types defined in function prototype
Types defined in function prototype are diagnosed earlier in C++ compilation. They are put into declaration context where the prototype is introduced. Later on, when FunctionDecl object is created, these types are moved into the function context. This patch fixes PR19018 and PR18963. Differential Revision: http://reviews.llvm.org/D4145 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/type-definition-in-specifier.cpp')
-rw-r--r--test/SemaCXX/type-definition-in-specifier.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/SemaCXX/type-definition-in-specifier.cpp b/test/SemaCXX/type-definition-in-specifier.cpp
index bda91d93ce..43443a00e4 100644
--- a/test/SemaCXX/type-definition-in-specifier.cpp
+++ b/test/SemaCXX/type-definition-in-specifier.cpp
@@ -23,3 +23,44 @@ void f0() {
struct S5 { int x; } f1() { return S5(); } // expected-error{{result type}}
void f2(struct S6 { int x; } p); // expected-error{{parameter type}}
+
+struct pr19018 {
+ short foo6 (enum bar0 {qq} bar3); // expected-error{{cannot be defined in a parameter type}}
+};
+
+void pr19018_1 (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}}
+void pr19018_1a (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}}
+e19018_1 x2; // expected-error{{unknown type name 'e19018_1'}}
+
+void pr19018_2 (enum {qq} x); // expected-error{{cannot be defined in a parameter type}}
+void pr19018_3 (struct s19018_2 {int qq;} x); // expected-error{{cannot be defined in a parameter type}}
+void pr19018_4 (struct {int qq;} x); // expected-error{{cannot be defined in a parameter type}}
+void pr19018_5 (struct { void qq(); } x); // expected-error{{cannot be defined in a parameter type}}
+void pr19018_5 (struct s19018_2 { void qq(); } x); // expected-error{{cannot be defined in a parameter type}}
+
+struct pr19018a {
+ static int xx;
+ void func1(enum t19018 {qq} x); // expected-error{{cannot be defined in a parameter type}}
+ void func2(enum t19018 {qq} x); // expected-error{{cannot be defined in a parameter type}}
+ void func3(enum {qq} x); // expected-error{{cannot be defined in a parameter type}}
+ void func4(struct t19018 {int qq;} x); // expected-error{{cannot be defined in a parameter type}}
+ void func5(struct {int qq;} x); // expected-error{{cannot be defined in a parameter type}}
+ void func6(struct { void qq(); } x); // expected-error{{cannot be defined in a parameter type}}
+ void func7(struct t19018 { void qq(); } x); // expected-error{{cannot be defined in a parameter type}}
+ void func8(struct { int qq() { return xx; }; } x); // expected-error{{cannot be defined in a parameter type}}
+ void func9(struct t19018 { int qq() { return xx; }; } x); // expected-error{{cannot be defined in a parameter type}}
+};
+
+struct s19018b {
+ void func1 (enum en_2 {qq} x); // expected-error{{cannot be defined in a parameter type}}
+ en_2 x1; // expected-error{{unknown type name 'en_2'}}
+ void func2 (enum en_3 {qq} x); // expected-error{{cannot be defined in a parameter type}}
+ enum en_3 x2; // expected-error{{ISO C++ forbids forward references to 'enum' types}} \
+ // expected-error{{field has incomplete type 'enum en_3'}} \
+ // expected-note{{forward declaration of 'en_3'}}
+};
+
+struct pr18963 {
+ short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}}
+ long foo5 (float foo6 = foo4); // expected-error{{use of undeclared identifier 'foo4'}}
+};