| 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 |
| 3 |
|
| 4 |
// Test decls inside Objective-C entities are considered to be duplicates of same-name decls outside of these entities. |
| 5 |
|
| 6 |
@protocol SomeProtocol |
| 7 |
struct InProtocol {}; // expected-note {{previous definition is here}} |
| 8 |
- (union MethodReturnType { int x; float y; })returningMethod; // expected-note {{previous definition is here}} |
| 9 |
#ifdef __cplusplus |
| 10 |
// expected-error@-2 {{'MethodReturnType' cannot be defined in a parameter type}} |
| 11 |
#endif |
| 12 |
@end |
| 13 |
|
| 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}} |
| 17 |
} |
| 18 |
enum InInterface { kX = 0, }; // expected-note {{previous definition is here}} |
| 19 |
#ifdef __cplusplus |
| 20 |
enum class InInterfaceScoped { kXScoped = 0, }; // expected-note {{previous definition is here}} |
| 21 |
#endif |
| 22 |
@end |
| 23 |
|
| 24 |
@interface Container(Category) |
| 25 |
union InCategory { int x; float y; }; // expected-note {{previous definition is here}} |
| 26 |
@end |
| 27 |
|
| 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}} |
| 31 |
} |
| 32 |
union InExtension { int x; float y; }; // expected-note {{previous definition is here}} |
| 33 |
@end |
| 34 |
|
| 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}} |
| 38 |
} |
| 39 |
struct InImplementation {}; // expected-note {{previous definition is here}} |
| 40 |
@end |
| 41 |
|
| 42 |
@implementation Container(Category) |
| 43 |
enum InCategoryImplementation { kW = 3, }; // expected-note {{previous definition is here}} |
| 44 |
@end |
| 45 |
|
| 46 |
|
| 47 |
struct InProtocol { int a; }; // expected-error {{redefinition of 'InProtocol'}} |
| 48 |
union MethodReturnType { int a; long b; }; // expected-error {{redefinition of 'MethodReturnType'}} |
| 49 |
|
| 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'}} |
| 53 |
#ifdef __cplusplus |
| 54 |
enum class InInterfaceScoped { kAScoped = 10, }; // expected-error {{redefinition of 'InInterfaceScoped'}} |
| 55 |
#endif |
| 56 |
|
| 57 |
union InCategory { int a; long b; }; // expected-error {{redefinition of 'InCategory'}} |
| 58 |
|
| 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'}} |
| 62 |
|
| 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'}} |
| 66 |
|
| 67 |
enum InCategoryImplementation { kD = 13, }; // expected-error {{redefinition of 'InCategoryImplementation'}} |