1*29444f04SVolodymyr Sapsai// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*29444f04SVolodymyr Sapsai// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -x objective-c++ %s 3*29444f04SVolodymyr Sapsai 4*29444f04SVolodymyr Sapsai// Test decls inside Objective-C entities are considered to be duplicates of same-name decls outside of these entities. 5*29444f04SVolodymyr Sapsai 6*29444f04SVolodymyr Sapsai@protocol SomeProtocol 7*29444f04SVolodymyr Sapsaistruct InProtocol {}; // expected-note {{previous definition is here}} 8*29444f04SVolodymyr Sapsai- (union MethodReturnType { int x; float y; })returningMethod; // expected-note {{previous definition is here}} 9*29444f04SVolodymyr Sapsai#ifdef __cplusplus 10*29444f04SVolodymyr Sapsai// expected-error@-2 {{'MethodReturnType' cannot be defined in a parameter type}} 11*29444f04SVolodymyr Sapsai#endif 12*29444f04SVolodymyr Sapsai@end 13*29444f04SVolodymyr Sapsai 14*29444f04SVolodymyr Sapsai@interface Container { 15*29444f04SVolodymyr Sapsai struct InInterfaceCurliesWithField {} field; // expected-note {{previous definition is here}} 16*29444f04SVolodymyr Sapsai union InInterfaceCurlies { int x; float y; }; // expected-note {{previous definition is here}} 17*29444f04SVolodymyr Sapsai} 18*29444f04SVolodymyr Sapsaienum InInterface { kX = 0, }; // expected-note {{previous definition is here}} 19*29444f04SVolodymyr Sapsai#ifdef __cplusplus 20*29444f04SVolodymyr Sapsaienum class InInterfaceScoped { kXScoped = 0, }; // expected-note {{previous definition is here}} 21*29444f04SVolodymyr Sapsai#endif 22*29444f04SVolodymyr Sapsai@end 23*29444f04SVolodymyr Sapsai 24*29444f04SVolodymyr Sapsai@interface Container(Category) 25*29444f04SVolodymyr Sapsaiunion InCategory { int x; float y; }; // expected-note {{previous definition is here}} 26*29444f04SVolodymyr Sapsai@end 27*29444f04SVolodymyr Sapsai 28*29444f04SVolodymyr Sapsai@interface Container() { 29*29444f04SVolodymyr Sapsai enum InExtensionCurliesWithField: int { kY = 1, } extensionField; // expected-note {{previous definition is here}} 30*29444f04SVolodymyr Sapsai struct InExtensionCurlies {}; // expected-note {{previous definition is here}} 31*29444f04SVolodymyr Sapsai} 32*29444f04SVolodymyr Sapsaiunion InExtension { int x; float y; }; // expected-note {{previous definition is here}} 33*29444f04SVolodymyr Sapsai@end 34*29444f04SVolodymyr Sapsai 35*29444f04SVolodymyr Sapsai@implementation Container { 36*29444f04SVolodymyr Sapsai union InImplementationCurliesWithField { int x; float y; } implField; // expected-note {{previous definition is here}} 37*29444f04SVolodymyr Sapsai enum InImplementationCurlies { kZ = 2, }; // expected-note {{previous definition is here}} 38*29444f04SVolodymyr Sapsai} 39*29444f04SVolodymyr Sapsaistruct InImplementation {}; // expected-note {{previous definition is here}} 40*29444f04SVolodymyr Sapsai@end 41*29444f04SVolodymyr Sapsai 42*29444f04SVolodymyr Sapsai@implementation Container(Category) 43*29444f04SVolodymyr Sapsaienum InCategoryImplementation { kW = 3, }; // expected-note {{previous definition is here}} 44*29444f04SVolodymyr Sapsai@end 45*29444f04SVolodymyr Sapsai 46*29444f04SVolodymyr Sapsai 47*29444f04SVolodymyr Sapsaistruct InProtocol { int a; }; // expected-error {{redefinition of 'InProtocol'}} 48*29444f04SVolodymyr Sapsaiunion MethodReturnType { int a; long b; }; // expected-error {{redefinition of 'MethodReturnType'}} 49*29444f04SVolodymyr Sapsai 50*29444f04SVolodymyr Sapsaistruct InInterfaceCurliesWithField { int a; }; // expected-error {{redefinition of 'InInterfaceCurliesWithField'}} 51*29444f04SVolodymyr Sapsaiunion InInterfaceCurlies { int a; long b; }; // expected-error {{redefinition of 'InInterfaceCurlies'}} 52*29444f04SVolodymyr Sapsaienum InInterface { kA = 10, }; // expected-error {{redefinition of 'InInterface'}} 53*29444f04SVolodymyr Sapsai#ifdef __cplusplus 54*29444f04SVolodymyr Sapsaienum class InInterfaceScoped { kAScoped = 10, }; // expected-error {{redefinition of 'InInterfaceScoped'}} 55*29444f04SVolodymyr Sapsai#endif 56*29444f04SVolodymyr Sapsai 57*29444f04SVolodymyr Sapsaiunion InCategory { int a; long b; }; // expected-error {{redefinition of 'InCategory'}} 58*29444f04SVolodymyr Sapsai 59*29444f04SVolodymyr Sapsaienum InExtensionCurliesWithField: int { kB = 11, }; // expected-error {{redefinition of 'InExtensionCurliesWithField'}} 60*29444f04SVolodymyr Sapsaistruct InExtensionCurlies { int a; }; // expected-error {{redefinition of 'InExtensionCurlies'}} 61*29444f04SVolodymyr Sapsaiunion InExtension { int a; long b; }; // expected-error {{redefinition of 'InExtension'}} 62*29444f04SVolodymyr Sapsai 63*29444f04SVolodymyr Sapsaiunion InImplementationCurliesWithField { int a; long b; }; // expected-error {{redefinition of 'InImplementationCurliesWithField'}} 64*29444f04SVolodymyr Sapsaienum InImplementationCurlies { kC = 12, }; // expected-error {{redefinition of 'InImplementationCurlies'}} 65*29444f04SVolodymyr Sapsaistruct InImplementation { int a; }; // expected-error {{redefinition of 'InImplementation'}} 66*29444f04SVolodymyr Sapsai 67*29444f04SVolodymyr Sapsaienum InCategoryImplementation { kD = 13, }; // expected-error {{redefinition of 'InCategoryImplementation'}} 68