summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2017-03-10 15:23:07 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2017-03-10 15:23:07 +0000
commit81a25e352f9e59ac9e5acb1185bd1bc68d6e783d (patch)
treee334055423dfa329b1bc8c86622efcada6f1b194 /clang/lib/AST/ASTContext.cpp
parent0ef8ee19f8fe2bd295a0980e3265f032cfead5fd (diff)
downloadbcm5719-llvm-81a25e352f9e59ac9e5acb1185bd1bc68d6e783d.tar.gz
bcm5719-llvm-81a25e352f9e59ac9e5acb1185bd1bc68d6e783d.zip
[OpenCL] Fix type compatibility check and generic AS mangling.
1. Reimplemented conditional operator so that it checks compatibility of unqualified pointees of the 2nd and the 3rd operands (C99, OpenCL v2.0 6.5.15). Define QualTypes compatibility for OpenCL as following: - corresponding types are compatible (C99 6.7.3) - CVR-qualifiers are equal (C99 6.7.3) - address spaces are equal (implementation defined) 2. Added generic address space to Itanium mangling. Review: D30037 Patch by Dmitry Borisenkov! llvm-svn: 297468
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b9264051b63..e8f98929de6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8066,15 +8066,6 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
Qualifiers LQuals = LHSCan.getLocalQualifiers();
Qualifiers RQuals = RHSCan.getLocalQualifiers();
if (LQuals != RQuals) {
- if (getLangOpts().OpenCL) {
- if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
- LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
- return QualType();
- if (LQuals.isAddressSpaceSupersetOf(RQuals))
- return LHS;
- if (RQuals.isAddressSpaceSupersetOf(LQuals))
- return RHS;
- }
// If any of these qualifiers are different, we have a type
// mismatch.
if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
@@ -8200,6 +8191,20 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
LHSPointee = LHSPointee.getUnqualifiedType();
RHSPointee = RHSPointee.getUnqualifiedType();
}
+ if (getLangOpts().OpenCL) {
+ Qualifiers LHSPteeQual = LHSPointee.getQualifiers();
+ Qualifiers RHSPteeQual = RHSPointee.getQualifiers();
+ // Blocks can't be an expression in a ternary operator (OpenCL v2.0
+ // 6.12.5) thus the following check is asymmetric.
+ if (!LHSPteeQual.isAddressSpaceSupersetOf(RHSPteeQual))
+ return QualType();
+ LHSPteeQual.removeAddressSpace();
+ RHSPteeQual.removeAddressSpace();
+ LHSPointee =
+ QualType(LHSPointee.getTypePtr(), LHSPteeQual.getAsOpaqueValue());
+ RHSPointee =
+ QualType(RHSPointee.getTypePtr(), RHSPteeQual.getAsOpaqueValue());
+ }
QualType ResultType = mergeTypes(LHSPointee, RHSPointee, OfBlockPointer,
Unqualified);
if (ResultType.isNull()) return QualType();
OpenPOWER on IntegriCloud