1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -x objective-c++ %s
4 // Test decls inside Objective-C entities are considered to be duplicates of same-name decls outside of these entities.
7 struct InProtocol {}; // expected-note {{previous definition is here}}
8 - (union MethodReturnType { int x; float y; })returningMethod; // expected-note {{previous definition is here}}
10 // expected-error@-2 {{'MethodReturnType' cannot be defined in a parameter type}}
14 @interface Container {
15 struct InInterfaceCurliesWithField {} field; // expected-note {{previous definition is here}}
16 union InInterfaceCurlies { int x; float y; }; // expected-note {{previous definition is here}}
18 enum InInterface { kX = 0, }; // expected-note {{previous definition is here}}
20 enum class InInterfaceScoped { kXScoped = 0, }; // expected-note {{previous definition is here}}
24 @interface Container(Category)
25 union InCategory { int x; float y; }; // expected-note {{previous definition is here}}
28 @interface Container() {
29 enum InExtensionCurliesWithField: int { kY = 1, } extensionField; // expected-note {{previous definition is here}}
30 struct InExtensionCurlies {}; // expected-note {{previous definition is here}}
32 union InExtension { int x; float y; }; // expected-note {{previous definition is here}}
35 @implementation Container {
36 union InImplementationCurliesWithField { int x; float y; } implField; // expected-note {{previous definition is here}}
37 enum InImplementationCurlies { kZ = 2, }; // expected-note {{previous definition is here}}
39 struct InImplementation {}; // expected-note {{previous definition is here}}
42 @implementation Container(Category)
43 enum InCategoryImplementation { kW = 3, }; // expected-note {{previous definition is here}}
47 struct InProtocol { int a; }; // expected-error {{redefinition of 'InProtocol'}}
48 union MethodReturnType { int a; long b; }; // expected-error {{redefinition of 'MethodReturnType'}}
50 struct InInterfaceCurliesWithField { int a; }; // expected-error {{redefinition of 'InInterfaceCurliesWithField'}}
51 union InInterfaceCurlies { int a; long b; }; // expected-error {{redefinition of 'InInterfaceCurlies'}}
52 enum InInterface { kA = 10, }; // expected-error {{redefinition of 'InInterface'}}
54 enum class InInterfaceScoped { kAScoped = 10, }; // expected-error {{redefinition of 'InInterfaceScoped'}}
57 union InCategory { int a; long b; }; // expected-error {{redefinition of 'InCategory'}}
59 enum InExtensionCurliesWithField: int { kB = 11, }; // expected-error {{redefinition of 'InExtensionCurliesWithField'}}
60 struct InExtensionCurlies { int a; }; // expected-error {{redefinition of 'InExtensionCurlies'}}
61 union InExtension { int a; long b; }; // expected-error {{redefinition of 'InExtension'}}
63 union InImplementationCurliesWithField { int a; long b; }; // expected-error {{redefinition of 'InImplementationCurliesWithField'}}
64 enum InImplementationCurlies { kC = 12, }; // expected-error {{redefinition of 'InImplementationCurlies'}}
65 struct InImplementation { int a; }; // expected-error {{redefinition of 'InImplementation'}}
67 enum InCategoryImplementation { kD = 13, }; // expected-error {{redefinition of 'InCategoryImplementation'}}