]> granicus.if.org Git - clang/commitdiff
Support for objextive-c++ use of property-dot syntax as receiver
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Feb 2011 18:05:59 +0000 (18:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Feb 2011 18:05:59 +0000 (18:05 +0000)
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

include/clang/Sema/Sema.h
lib/Parse/Parser.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExprCXX.cpp
test/SemaObjC/property-dot-receiver.m

index 65b6c860f485c274304605a996a24329d915317e..8c48fc56ceb24ca5d29f0477b4e4bcf66f797da2 100644 (file)
@@ -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,
index 4b2bd0d89cff7f7eae2a9673355cbe05c4b6fab8..820f703068c49d8b40f619bf2dd0445e2255f100 100644 (file)
@@ -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);
index aed950c8fccda95ad93dd5323ce1f23f56209403..a5190961b5304305759e8bc95a99bd44d755fb44 100644 (file)
@@ -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<ObjCInterfaceDecl>(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);
 }
 
index ea1ad51e9d6d0ff4dcc4a82ac1ef63dbd537dc8f..f886e17d5469fadc86e65100cb1a40b1defe4124 100644 (file)
@@ -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)
index 3498dcc02984730677fded155914160a13ec8dc3..733ad4288a83b08cfd605b2a79fff134f66e0107 100644 (file)
@@ -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 {