[CUDA] Allow trivial constructors as initializer for __shared__ variables.
Differential Revision: http://reviews.llvm.org/D12739 llvm-svn: 247307
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user