diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2019-07-18 09:12:49 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2019-07-18 09:12:49 +0000 |
commit | 36d9e8358aa2e24abc280af4811eac5d5c65557f (patch) | |
tree | 07947dbc7ef26c49fb85997dbc967cf2601bdb50 /clang/lib/Sema/SemaDecl.cpp | |
parent | f26706fa1c15090774868fd9d259c7882e553319 (diff) | |
download | bcm5719-llvm-36d9e8358aa2e24abc280af4811eac5d5c65557f.tar.gz bcm5719-llvm-36d9e8358aa2e24abc280af4811eac5d5c65557f.zip |
[OpenCL][PR42033] Fix addr space deduction with template parameters
If dependent types appear in pointers or references we allow addr
space deduction because the addr space in template argument will
belong to the pointee and not the pointer or reference itself.
We also don't diagnose addr space on a function return type after
template instantiation. If any addr space for the return type was
provided on a template parameter this will be diagnosed during the
parsing of template definition.
Differential Revision: https://reviews.llvm.org/D62584
llvm-svn: 366417
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index cc91ec59468..72b4f6bbcda 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7491,7 +7491,10 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { return; } } - } else if (T.getAddressSpace() != LangAS::opencl_private) { + } else if (T.getAddressSpace() != LangAS::opencl_private && + // If we are parsing a template we didn't deduce an addr + // space yet. + T.getAddressSpace() != LangAS::Default) { // Do not allow other address spaces on automatic variable. Diag(NewVD->getLocation(), diag::err_as_qualified_auto_decl) << 1; NewVD->setInvalidDecl(); |