From: Fariborz Jahanian Date: Tue, 8 Feb 2011 18:05:59 +0000 (+0000) Subject: Support for objextive-c++ use of property-dot syntax as receiver X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e52dfc648ce0b25ef57ae29ef1b4337d80011ef;p=clang Support for objextive-c++ use of property-dot syntax as receiver in liu of a class method getter. // rdar://8962253 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125094 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 65b6c860f4..8c48fc56ce 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -694,6 +694,7 @@ public: ParsedType getTypeName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS = 0, bool isClassName = false, + bool HasTrailingDot = false, ParsedType ObjectType = ParsedType()); TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S); bool DiagnoseUnknownTypeName(const IdentifierInfo &II, diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 4b2bd0d89c..820f703068 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -1061,7 +1061,8 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) { // Determine whether the identifier is a type name. if (ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), - &SS)) { + &SS, false, + NextToken().is(tok::period))) { // This is a typename. Replace the current token in-place with an // annotation type token. Tok.setKind(tok::annot_typename); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index aed950c8fc..a5190961b5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -60,7 +60,7 @@ Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(Decl *Ptr) { /// and then return NULL. ParsedType Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS, - bool isClassName, + bool isClassName, bool HasTrailingDot, ParsedType ObjectTypePtr) { // Determine where we will perform name lookup. DeclContext *LookupCtx = 0; @@ -193,13 +193,15 @@ ParsedType Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, T = getElaboratedType(ETK_None, *SS, T); } else if (ObjCInterfaceDecl *IDecl = dyn_cast(IIDecl)) { - T = Context.getObjCInterfaceType(IDecl); - } else { + if (!HasTrailingDot) + T = Context.getObjCInterfaceType(IDecl); + } + + if (T.isNull()) { // If it's not plausibly a type, suppress diagnostics. Result.suppressDiagnostics(); return ParsedType(); } - return ParsedType::make(T); } diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index ea1ad51e9d..f886e17d54 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -3685,7 +3685,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, if (SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) { ParsedType T = getTypeName(*SecondTypeName.Identifier, SecondTypeName.StartLocation, - S, &SS, true, ObjectTypePtrForLookup); + S, &SS, true, false, ObjectTypePtrForLookup); if (!T && ((SS.isSet() && !computeDeclContext(SS, false)) || (!SS.isSet() && ObjectType->isDependentType()))) { @@ -3741,7 +3741,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, if (FirstTypeName.getKind() == UnqualifiedId::IK_Identifier) { ParsedType T = getTypeName(*FirstTypeName.Identifier, FirstTypeName.StartLocation, - S, &SS, false, ObjectTypePtrForLookup); + S, &SS, false, false, ObjectTypePtrForLookup); if (!T) { Diag(FirstTypeName.StartLocation, diag::err_pseudo_dtor_destructor_non_type) diff --git a/test/SemaObjC/property-dot-receiver.m b/test/SemaObjC/property-dot-receiver.m index 3498dcc029..733ad4288a 100644 --- a/test/SemaObjC/property-dot-receiver.m +++ b/test/SemaObjC/property-dot-receiver.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s // rdar://8962253 @interface Singleton {