summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-06-10 00:55:51 +0000
committerHans Wennborg <hans@hanshq.net>2014-06-10 00:55:51 +0000
commit28125b7374a15e096cd2ffc26706ec4d8fced29a (patch)
treede9a959e23a4eead563abb880aa1daa7f6e8b551 /lib/Sema/SemaTemplateInstantiateDecl.cpp
parent5ecb6106a89514b83481e6a3abe4de2d76591a99 (diff)
Improve checking for dynamic initializers of dllimport fields in template instantiation
We would previously assert if the initializer was dependent. I also think that checking isConstantInitializer is more correct here than checkInitIsICE. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210505 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 2fa28a33a1..bce2fd552e 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3671,12 +3671,6 @@ void Sema::InstantiateVariableInitializer(
// We already have an initializer in the class.
return;
- if (Var->hasAttr<DLLImportAttr>() &&
- !(OldVar->getInit() && OldVar->checkInitIsICE())) {
- // Do not dynamically initialize dllimport variables.
- return;
- }
-
if (OldVar->getInit()) {
if (Var->isStaticDataMember() && !OldVar->isOutOfLine())
PushExpressionEvaluationContext(Sema::ConstantEvaluated, OldVar);
@@ -3689,9 +3683,15 @@ void Sema::InstantiateVariableInitializer(
OldVar->getInitStyle() == VarDecl::CallInit);
if (!Init.isInvalid()) {
bool TypeMayContainAuto = true;
- if (Init.get()) {
+ Expr *InitExpr = Init.get();
+
+ if (Var->hasAttr<DLLImportAttr>() && InitExpr &&
+ !InitExpr->isConstantInitializer(getASTContext(), false)) {
+ // Do not dynamically initialize dllimport variables.
+ return;
+ } else if (InitExpr) {
bool DirectInit = OldVar->isDirectInit();
- AddInitializerToDecl(Var, Init.get(), DirectInit, TypeMayContainAuto);
+ AddInitializerToDecl(Var, InitExpr, DirectInit, TypeMayContainAuto);
} else
ActOnUninitializedDecl(Var, TypeMayContainAuto);
} else {