Calling it too early might cause dllimport to get inherited onto the
VarDecl before the initializer got attached. See the test case for an
example where this broke things.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345709
91177308-0d34-0410-b5e6-
96231b3b80d8
D->getLocation(), D->getIdentifier(), DI->getType(),
DI, D->getStorageClass());
- if (Var->isStaticLocal())
- SemaRef.CheckStaticLocalForDllExport(Var);
-
// In ARC, infer 'retaining' for variables of retainable type.
if (SemaRef.getLangOpts().ObjCAutoRefCount &&
SemaRef.inferObjCARCLifetime(Var))
Var->setImplicit(D->isImplicit());
+ if (Var->isStaticLocal())
+ SemaRef.CheckStaticLocalForDllExport(Var);
+
return Var;
}
extern template struct __declspec(dllimport) T<int>;
int bar() { T<int> t; return t.foo(); }
// MO1-DAG: @"?x@?{{1|2}}??foo@?$T@H@pr39496@@Q{{[A-Z]*}}HXZ@4HA" = available_externally dllimport global i32 0, align 4
+
+template <typename T> struct __declspec(dllimport) U {
+ void foo() {
+ // Don't inherit dllimport to src before attaching the initializer.
+ static constexpr char src[] = {"hello"};
+ T arr[sizeof(src)];
+ }
+};
+void baz() { U<int> u; u.foo(); } // No diagnostic.
+
}