Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -10739,7 +10739,8 @@ while (isa(SearchDC) || isa(SearchDC)) SearchDC = SearchDC->getParent(); } - } else if (S->isFunctionPrototypeScope()) { + } + if (S->isFunctionPrototypeScope() && TUK == TUK_Definition) { // If this is an enum declaration in function prototype scope, set its // initial context to the translation unit. // FIXME: [citation needed] Index: test/SemaCXX/type-definition-in-specifier.cpp =================================================================== --- test/SemaCXX/type-definition-in-specifier.cpp +++ test/SemaCXX/type-definition-in-specifier.cpp @@ -23,3 +23,15 @@ 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}} +}; + +struct pr19018a { + 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}} +}; \ No newline at end of file