diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2015-12-22 15:14:54 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2015-12-22 15:14:54 +0000 |
commit | 76fd1052fd60ef227ad249bc16e714e9b4b7460c (patch) | |
tree | 624f934fd320303d3c73d6c932d133c608436814 /clang/lib/Sema | |
parent | a1080103853620317ee313ec28bf64cd206c22f2 (diff) | |
download | bcm5719-llvm-76fd1052fd60ef227ad249bc16e714e9b4b7460c.tar.gz bcm5719-llvm-76fd1052fd60ef227ad249bc16e714e9b4b7460c.zip |
[OpenCL] Fix atomic Builtins check for address spaces of non-atomic pointer
If there are two pointers passed to an atomic Builtin,
Clang doesn't allow the second (non-atomic) one to be qualified
with an address space.
Remove this restriction by recording the address space of passed pointers
in atomics type diagnostics.
llvm-svn: 256243
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index d5c80c9e201..949e8742f90 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1801,8 +1801,17 @@ ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult, Ty = ByValType; else if (Form == Arithmetic) Ty = Context.getPointerDiffType(); - else - Ty = Context.getPointerType(ValType.getUnqualifiedType()); + else { + Expr *ValArg = TheCall->getArg(i); + unsigned AS = 0; + // Keep address space of non-atomic pointer type. + if (const PointerType *PtrTy = + ValArg->getType()->getAs<PointerType>()) { + AS = PtrTy->getPointeeType().getAddressSpace(); + } + Ty = Context.getPointerType( + Context.getAddrSpaceQualType(ValType.getUnqualifiedType(), AS)); + } break; case 2: // The third argument to compare_exchange / GNU exchange is a |