Skip to content

Commit 63c4244

Browse files
committed
Fix parsing :: in method parameter type.
1 parent 139e69b commit 63c4244

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/Parse/Parser.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2222,8 +2222,14 @@ bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(
22222222
}
22232223
}
22242224

2225-
if (SS.isEmpty())
2225+
if (SS.isEmpty()) {
2226+
if (getLangOpts().ObjC && Tok.is(tok::coloncolon)) {
2227+
// ObjectiveC does not allow :: as as a scope token.
2228+
Diag(ConsumeToken(), diag::err_expected_type);
2229+
return true;
2230+
}
22262231
return false;
2232+
}
22272233

22282234
// A C++ scope specifier that isn't followed by a typename.
22292235
AnnotateScopeToken(SS, IsNewScope);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
2+
3+
@interface A
4+
- (instancetype)init:(::A *) foo; // expected-error {{expected a type}}
5+
@end

0 commit comments

Comments
 (0)