diff options
author | Artem Belevich <tra@google.com> | 2015-09-10 17:26:58 +0000 |
---|---|---|
committer | Artem Belevich <tra@google.com> | 2015-09-10 17:26:58 +0000 |
commit | da1851ca58dc72ed781f0c36b6ef9c42ba9acf89 (patch) | |
tree | c243bebd46df4f8275bd5091f9882322fb883236 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 170fd9cb6e3b6654e9b646a262610d73f4efe961 (diff) | |
download | bcm5719-llvm-da1851ca58dc72ed781f0c36b6ef9c42ba9acf89.tar.gz bcm5719-llvm-da1851ca58dc72ed781f0c36b6ef9c42ba9acf89.zip |
[CUDA] Allow trivial constructors as initializer for __shared__ variables.
Differential Revision: http://reviews.llvm.org/D12739
llvm-svn: 247307
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8f0259d502a..bbc01cba633 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2165,8 +2165,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { if (getLangOpts().CPlusPlus && getLangOpts().CUDAIsDevice && D->hasAttr<CUDASharedAttr>()) { if (InitExpr) { - Error(D->getLocation(), - "__shared__ variable cannot have an initialization."); + const auto *C = dyn_cast<CXXConstructExpr>(InitExpr); + if (C == nullptr || !C->getConstructor()->hasTrivialBody()) + Error(D->getLocation(), + "__shared__ variable cannot have an initialization."); } Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy)); } else if (!InitExpr) { |