// 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);
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 {
template <typename T> int C<T>::x = g();
template struct __declspec(dllimport) C<int>;
// MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42
+
+ template <int I> struct D { static int x, y; };
+ template <int I> int D<I>::x = I + 1;
+ template <int I> int D<I>::y = I + f();
+ template struct __declspec(dllimport) D<42>;
+ // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 43
+ // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
}