File: check-dup-decls-inside-objc.m

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (67 lines) | stat: -rw-r--r-- 3,377 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -x objective-c++ %s

// Test decls inside Objective-C entities are considered to be duplicates of same-name decls outside of these entities.

@protocol SomeProtocol
struct InProtocol {}; // expected-note {{previous definition is here}}
- (union MethodReturnType { int x; float y; })returningMethod; // expected-note {{previous definition is here}}
#ifdef __cplusplus
// expected-error@-2 {{'MethodReturnType' cannot be defined in a parameter type}}
#endif
@end

@interface Container {
  struct InInterfaceCurliesWithField {} field; // expected-note {{previous definition is here}}
  union InInterfaceCurlies { int x; float y; }; // expected-note {{previous definition is here}}
}
enum InInterface { kX = 0, }; // expected-note {{previous definition is here}}
#ifdef __cplusplus
enum class InInterfaceScoped { kXScoped = 0, }; // expected-note {{previous definition is here}}
#endif
@end

@interface Container(Category)
union InCategory { int x; float y; }; // expected-note {{previous definition is here}}
@end

@interface Container() {
  enum InExtensionCurliesWithField: int { kY = 1, } extensionField; // expected-note {{previous definition is here}}
  struct InExtensionCurlies {}; // expected-note {{previous definition is here}}
}
union InExtension { int x; float y; }; // expected-note {{previous definition is here}}
@end

@implementation Container {
  union InImplementationCurliesWithField { int x; float y; } implField; // expected-note {{previous definition is here}}
  enum InImplementationCurlies { kZ = 2, }; // expected-note {{previous definition is here}}
}
struct InImplementation {}; // expected-note {{previous definition is here}}
@end

@implementation Container(Category)
enum InCategoryImplementation { kW = 3, }; // expected-note {{previous definition is here}}
@end


struct InProtocol { int a; }; // expected-error {{redefinition of 'InProtocol'}}
union MethodReturnType { int a; long b; }; // expected-error {{redefinition of 'MethodReturnType'}}

struct InInterfaceCurliesWithField { int a; }; // expected-error {{redefinition of 'InInterfaceCurliesWithField'}}
union InInterfaceCurlies { int a; long b; }; // expected-error {{redefinition of 'InInterfaceCurlies'}}
enum InInterface { kA = 10, }; // expected-error {{redefinition of 'InInterface'}}
#ifdef __cplusplus
enum class InInterfaceScoped { kAScoped = 10, }; // expected-error {{redefinition of 'InInterfaceScoped'}}
#endif

union InCategory { int a; long b; }; // expected-error {{redefinition of 'InCategory'}}

enum InExtensionCurliesWithField: int { kB = 11, }; // expected-error {{redefinition of 'InExtensionCurliesWithField'}}
struct InExtensionCurlies { int a; }; // expected-error {{redefinition of 'InExtensionCurlies'}}
union InExtension { int a; long b; }; // expected-error {{redefinition of 'InExtension'}}

union InImplementationCurliesWithField { int a; long b; }; // expected-error {{redefinition of 'InImplementationCurliesWithField'}}
enum InImplementationCurlies { kC = 12, }; // expected-error {{redefinition of 'InImplementationCurlies'}}
struct InImplementation { int a; }; // expected-error {{redefinition of 'InImplementation'}}

enum InCategoryImplementation { kD = 13, }; // expected-error {{redefinition of 'InCategoryImplementation'}}