File tree Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -780,6 +780,9 @@ Improvements to Clang's diagnostics
780
780
- Clang now diagnoses dangling references to fields of temporary objects. Fixes #GH81589.
781
781
782
782
783
+ - Fixed a bug where Clang hung on an unsupported optional scope specifier ``:: `` when parsing
784
+ Objective-C. Clang now emits a diagnostic message instead of hanging.
785
+
783
786
Improvements to Clang's time-trace
784
787
----------------------------------
785
788
Original file line number Diff line number Diff line change @@ -2251,8 +2251,15 @@ bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(
2251
2251
}
2252
2252
}
2253
2253
2254
- if (SS.isEmpty ())
2254
+ if (SS.isEmpty ()) {
2255
+ if (getLangOpts ().ObjC && !getLangOpts ().CPlusPlus &&
2256
+ Tok.is (tok::coloncolon)) {
2257
+ // ObjectiveC does not allow :: as as a scope token.
2258
+ Diag (ConsumeToken (), diag::err_expected_type);
2259
+ return true ;
2260
+ }
2255
2261
return false ;
2262
+ }
2256
2263
2257
2264
// A C++ scope specifier that isn't followed by a typename.
2258
2265
AnnotateScopeToken (SS, IsNewScope);
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -x objective-c -fsyntax-only -Wno-objc-root-class -verify %s
2
+
3
+ int GV = 42 ;
4
+
5
+ @interface A
6
+ + (int ) getGV ;
7
+ - (instancetype )init : (::A *) foo ; // expected-error {{expected a type}}
8
+ @end
9
+
10
+ @implementation A
11
+ - (void )performSelector : (SEL )selector {}
12
+ - (void )double : (int )firstArg : (int )secondArg colon : (int )thirdArg {}
13
+ - (void )test {
14
+ // The `::` below should not trigger an error.
15
+ [self performSelector: @selector (double::colon: )];
16
+ }
17
+ + (int ) getGV { return ::GV; } // expected-error {{expected a type}}
18
+ - (instancetype )init : (::A *) foo { return self; } // expected-error {{expected a type}}
19
+ @end
Original file line number Diff line number Diff line change
1
+ // Test to make sure the parser does not get stuck on the optional
2
+ // scope specifier on the type B.
3
+ // RUN: %clang_cc1 -fsyntax-only %s
4
+
5
+ class B ;
6
+
7
+ @interface A
8
+ - (void ) init : (::B *) foo ;
9
+ @end
You can’t perform that action at this time.
0 commit comments