diff options
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) { |