diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-04-12 19:43:36 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-04-12 19:43:36 +0000 |
commit | a1a87adf59f880f6ab64a160bd521efeb3ae2e54 (patch) | |
tree | 1efb54acb5372c485f92f88479d6d7c6ecd80080 /clang/lib/AST/ASTContext.cpp | |
parent | 49bd58f1ebe28d97e4949e9c757bc5dfd8b2d72f (diff) | |
download | bcm5719-llvm-a1a87adf59f880f6ab64a160bd521efeb3ae2e54.tar.gz bcm5719-llvm-a1a87adf59f880f6ab64a160bd521efeb3ae2e54.zip |
PR19957: [OpenCL] Incorrectly accepts implicit address space conversion with ternary operator.
Generates addrspacecast instead of bitcast for ternary operator when necessary, and diagnose ternary operator with incompatible second and third operands.
https://llvm.org/bugs/show_bug.cgi?id=19957
Differential Revision: http://reviews.llvm.org/D17412
llvm-svn: 266111
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c295f599a37..370155873c0 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -7617,6 +7617,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, Qualifiers LQuals = LHSCan.getLocalQualifiers(); Qualifiers RQuals = RHSCan.getLocalQualifiers(); if (LQuals != RQuals) { + if (getLangOpts().OpenCL) { + if (LHS.getUnqualifiedType() != RHS.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() || |