From 3453f7d41097362a18670fde05a252702fdb2bf9 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 15 Apr 2009 21:54:48 +0000 Subject: [PATCH] Fix decl type merges when they have __string/__weak attributes. llvm-svn: 69229 --- clang/lib/AST/ASTContext.cpp | 6 +++--- .../test/SemaObjC/objc2-merge-gc-attribue-decl.m | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f0c2d2be4847..63d88b2ec732 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2937,8 +2937,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { if (LHSCan.getCVRQualifiers() != RHSCan.getCVRQualifiers()) return QualType(); - Type::TypeClass LHSClass = LHSCan->getTypeClass(); - Type::TypeClass RHSClass = RHSCan->getTypeClass(); + Type::TypeClass LHSClass = LHSCan.getUnqualifiedType()->getTypeClass(); + Type::TypeClass RHSClass = RHSCan.getUnqualifiedType()->getTypeClass(); // We want to consider the two function types to be the same for these // comparisons, just force one to the other. @@ -2963,7 +2963,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { if (LHSClass != RHSClass) { const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType(); const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType(); - + // 'id' and 'Class' act sort of like void* for ObjC interfaces if (LHSIface && (isObjCIdStructType(RHS) || isObjCClassStructType(RHS))) return LHS; diff --git a/clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m b/clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m new file mode 100644 index 000000000000..cdcd05873904 --- /dev/null +++ b/clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m @@ -0,0 +1,16 @@ +// RUN: clang-cc -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s + +@interface INTF @end + +extern INTF* p2; +extern __strong INTF* p2; + +extern __strong id p1; +extern id p1; + +extern id CFRunLoopGetMain(); +extern __strong id CFRunLoopGetMain(); + +extern __strong INTF* p3; +extern id p3; +