summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7e03f56f62f..386a5f3c7bd 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4303,11 +4303,24 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
bool allRTypes = true;
// Check return type
- QualType retType = mergeTypes(lbase->getResultType(), rbase->getResultType());
+ QualType LRES = lbase->getResultType();
+ QualType RRES = rbase->getResultType();
+ Qualifiers::GC GC_L = LRES.getObjCGCAttr();
+ Qualifiers::GC GC_R = RRES.getObjCGCAttr();
+ // __weak/__strong attribute on one function/block return type but
+ // not the other is OK.
+ if (GC_L != GC_R) {
+ if (GC_R == Qualifiers::GCNone)
+ RRES = getObjCGCQualType(RRES, GC_L);
+ else if (GC_L == Qualifiers::GCNone)
+ LRES = getObjCGCQualType(LRES, GC_R);
+ }
+
+ QualType retType = mergeTypes(LRES, RRES);
if (retType.isNull()) return QualType();
- if (getCanonicalType(retType) != getCanonicalType(lbase->getResultType()))
+ if (getCanonicalType(retType) != getCanonicalType(LRES))
allLTypes = false;
- if (getCanonicalType(retType) != getCanonicalType(rbase->getResultType()))
+ if (getCanonicalType(retType) != getCanonicalType(RRES))
allRTypes = false;
// FIXME: double check this
bool NoReturn = lbase->getNoReturnAttr() || rbase->getNoReturnAttr();
OpenPOWER on IntegriCloud