]> granicus.if.org Git - clang/commitdiff
Patch to build qualifier on objective-c
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 5 Mar 2010 22:42:55 +0000 (22:42 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 5 Mar 2010 22:42:55 +0000 (22:42 +0000)
pointer types. Fixes radar 7626768.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97847 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/AST/ASTContext.cpp
lib/Sema/SemaType.cpp
test/SemaObjC/check-dup-objc-decls-1.m

index 6767f52f4d8339087feeaab6a77d1408d30ed26e..0838a3d0ebe6b0ab5b7fd3923433a831cd08e778 100644 (file)
@@ -621,7 +621,8 @@ public:
   /// given interface decl and the conforming protocol list.
   QualType getObjCObjectPointerType(QualType OIT,
                                     ObjCProtocolDecl **ProtocolList = 0,
-                                    unsigned NumProtocols = 0);
+                                    unsigned NumProtocols = 0,
+                                    unsigned Quals = 0);
 
   /// getTypeOfType - GCC extension.
   QualType getTypeOfExprType(Expr *e);
index e091bf10b62977265f3189fdc4cbfd6c6ffb5427..d8c1c84858249fc4ec4625b67f3190f6a5d52b84 100644 (file)
@@ -2240,14 +2240,16 @@ static void SortAndUniqueProtocols(ObjCProtocolDecl **Protocols,
 /// the given interface decl and the conforming protocol list.
 QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
                                               ObjCProtocolDecl **Protocols,
-                                              unsigned NumProtocols) {
+                                              unsigned NumProtocols,
+                                              unsigned Quals) {
   llvm::FoldingSetNodeID ID;
   ObjCObjectPointerType::Profile(ID, InterfaceT, Protocols, NumProtocols);
+  Qualifiers Qs = Qualifiers::fromCVRMask(Quals);
 
   void *InsertPos = 0;
   if (ObjCObjectPointerType *QT =
               ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
-    return QualType(QT, 0);
+    return getQualifiedType(QualType(QT, 0), Qs);
 
   // Sort the protocol list alphabetically to canonicalize it.
   QualType Canonical;
@@ -2282,7 +2284,7 @@ QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
 
   Types.push_back(QType);
   ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
-  return QualType(QType, 0);
+  return getQualifiedType(QualType(QType, 0), Qs);
 }
 
 /// getObjCInterfaceType - Return the unique reference to the type for the
index 2fb5c84ac90e230a7e2748a2d97ea6278093d5c3..a79853afdc6b789839b329a017d577f1f84164bd 100644 (file)
@@ -1034,7 +1034,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
         const ObjCInterfaceType *OIT = T->getAs<ObjCInterfaceType>();
         T = Context.getObjCObjectPointerType(T,
                                          (ObjCProtocolDecl **)OIT->qual_begin(),
-                                         OIT->getNumProtocols());
+                                         OIT->getNumProtocols(),
+                                         DeclType.Ptr.TypeQuals);
         break;
       }
       T = BuildPointerType(T, DeclType.Ptr.TypeQuals, DeclType.Loc, Name);
index 1f80293588a64699d34e9e12606b7308c44139e2..8dde777f7437d7d8ac5dba07142a795e2811ada6 100644 (file)
@@ -37,3 +37,8 @@ void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symb
 
 @interface A(Cat)<P> @end // expected-note {{previous definition is here}}
 @interface A(Cat)<Q> @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}}
+
+// rdar 7626768
+@class NSString;
+NSString * TestBaz;  // expected-note {{previous definition is here}}
+NSString * const TestBaz;  // expected-error {{redefinition of 'TestBaz' with a different type}}