AST: Address of dllimport variables isn't constant
The address of dllimport variables isn't something that can be
meaningfully used in a constexpr context and isn't suitable for
evaluation at load-time. They require loads from memory to properly
evaluate.
This fixes PR19955.
Differential Revision: http://reviews.llvm.org/D4250
llvm-svn: 211568
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c77d5e8..d25ecd0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -4390,6 +4390,9 @@
Result.set(VD, Frame->Index);
return true;
}
+ // The address of __declspec(dllimport) variables aren't constant.
+ if (VD->hasAttr<DLLImportAttr>())
+ return ZeroInitialization(E);
return Success(VD);
}