From 11a54c3465a71c027841b83bc7f5f9df647618ff Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 24 Jun 2014 06:40:51 +0000 Subject: AST: Address of dllimport functions isn't constant The address of dllimport functions can be accessed one of two ways: - Through the IAT which is symbolically referred to with a symbol starting with __imp_. - Via the wrapper-function which ends up calling through the __imp_ symbol. The problem with using the wrapper-function is that it's address will not compare as equal in all translation units. Specifically, it will compare unequally with the translation unit which defines the function. This fixes PR19955. llvm-svn: 211570 --- clang/lib/AST/ExprConstant.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index d25ecd043d1..c57a802512b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -4373,8 +4373,11 @@ static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info) { } bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) { - if (const FunctionDecl *FD = dyn_cast(E->getDecl())) + if (const FunctionDecl *FD = dyn_cast(E->getDecl())) { + if (FD->hasAttr()) + return ZeroInitialization(E); return Success(FD); + } if (const VarDecl *VD = dyn_cast(E->getDecl())) return VisitVarDecl(E, VD); return Error(E); -- cgit v1.2.3