llvm-project/clang/test/Parser/objc-coloncolon.m
Qiongsi Wu 1418018502
[clang][ObjectiveC] Fix Parsing the :: Optional Scope Specifier (#119908)
The parser hangs when processing types/variables prefixed by `::` as an
optional scope specifier. For example,
```
- (instancetype)init:(::A *) foo;
```

The parser should not hang, and it should emit an error. This PR
implements the error check.

rdar://140885078
2024-12-20 09:47:26 -08:00

20 lines
608 B
Objective-C

// RUN: %clang_cc1 -x objective-c -fsyntax-only -Wno-objc-root-class -verify %s
int GV = 42;
@interface A
+ (int) getGV;
- (instancetype)init:(::A *) foo; // expected-error {{expected a type}}
@end
@implementation A
- (void)performSelector:(SEL)selector {}
- (void)double:(int)firstArg :(int)secondArg colon:(int)thirdArg {}
- (void)test {
// The `::` below should not trigger an error.
[self performSelector:@selector(double::colon:)];
}
+ (int) getGV { return ::GV; } // expected-error {{expected a type}}
- (instancetype)init:(::A *) foo { return self; } // expected-error {{expected a type}}
@end