Index: cfe/trunk/lib/AST/ExprConstant.cpp =================================================================== --- cfe/trunk/lib/AST/ExprConstant.cpp +++ cfe/trunk/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()) + return ZeroInitialization(E); return Success(VD); } Index: cfe/trunk/test/CodeGenCXX/PR19955.cpp =================================================================== --- cfe/trunk/test/CodeGenCXX/PR19955.cpp +++ cfe/trunk/test/CodeGenCXX/PR19955.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s | FileCheck %s + +extern int __declspec(dllimport) x; +extern long long y; +// CHECK-DAG: @"\01?y@@3_JA" = global i64 0 +long long y = (long long)&x; + +// CHECK-LABEL: @"\01??__Ey@@YAXXZ" +// CHECK-DAG: @"\01?y@@3_JA" Index: cfe/trunk/test/SemaCXX/PR19955.cpp =================================================================== --- cfe/trunk/test/SemaCXX/PR19955.cpp +++ cfe/trunk/test/SemaCXX/PR19955.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple i686-win32 -verify -std=c++11 %s + +extern int __attribute__((dllimport)) y; +constexpr int *x = &y; // expected-error {{must be initialized by a constant expression}}