summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2018-05-17 16:15:07 +0000
committerJustin Lebar <jlebar@google.com>2018-05-17 16:15:07 +0000
commit5489f85fdad03b81e445c9cd18997ee5c5a6f6f2 (patch)
tree8362d1824e8561ea32b89911d765d65532f4ada2 /clang/lib/AST/Decl.cpp
parenta907bf6a314cb6de39e47006930afc1ddd59d581 (diff)
downloadbcm5719-llvm-5489f85fdad03b81e445c9cd18997ee5c5a6f6f2.tar.gz
bcm5719-llvm-5489f85fdad03b81e445c9cd18997ee5c5a6f6f2.zip
[CUDA] Allow "extern __shared__ Foo foo[]" within anon. namespaces.
Summary: Previously this triggered a -Wundefined-internal warning. But it's not an undefined variable -- any variable of this form is a pointer to the base of GPU core's shared memory. Reviewers: tra Subscribers: sanjoy, rsmith Differential Revision: https://reviews.llvm.org/D46782 llvm-svn: 332621
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 895d50d1013..08718e0a9e8 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2432,6 +2432,23 @@ void VarDecl::setDescribedVarTemplate(VarTemplateDecl *Template) {
getASTContext().setTemplateOrSpecializationInfo(this, Template);
}
+bool VarDecl::isKnownToBeDefined() const {
+ const auto &LangOpts = getASTContext().getLangOpts();
+ // In CUDA mode without relocatable device code, variables of form 'extern
+ // __shared__ Foo foo[]' are pointers to the base of the GPU core's shared
+ // memory pool. These are never undefined variables, even if they appear
+ // inside of an anon namespace or static function.
+ //
+ // With CUDA relocatable device code enabled, these variables don't get
+ // special handling; they're treated like regular extern variables.
+ if (LangOpts.CUDA && !LangOpts.CUDARelocatableDeviceCode &&
+ hasExternalStorage() && hasAttr<CUDASharedAttr>() &&
+ isa<IncompleteArrayType>(getType()))
+ return true;
+
+ return hasDefinition();
+}
+
MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
if (isStaticDataMember())
// FIXME: Remove ?
OpenPOWER on IntegriCloud