rnk added a comment. Your code won't catch this test case:
static int x; extern inline const bool *f() { static const bool p = !&x; return &p; } Getting this exactly right is going to be a challenge. =/ ================ Comment at: include/clang/Basic/DiagnosticASTKinds.td:151 @@ -150,1 +150,3 @@ "%plural{1:byte|:bytes}1">; +def note_constexpr_microsoft_abi_declrefexpr : Note< + "the constant expression cannot contain a reference to a variable as a Microsoft " ---------------- We should add this test case and decide what to do with it: static int x; inline int **f() { static constexpr int *p = true ? 0 : &x; return &p; } Currently, in your patch, this diagnostic will come out. MSVC compiles this to guarded, dynamic initialization, despite the constexpr. ;_; David thinks we should just give the user the real deal constexpr behavior, even though it's ABI incompatible. ================ Comment at: include/clang/Basic/DiagnosticASTKinds.td:152-153 @@ -151,1 +151,4 @@ +def note_constexpr_microsoft_abi_declrefexpr : Note< + "the constant expression cannot contain a reference to a variable as a Microsoft " + "ABI extension">; ---------------- This isn't an extension, so we should say something else. Maybe: "in the Microsoft ABI static local variables cannot contain references to variables" ================ Comment at: lib/AST/ExprConstant.cpp:9008 @@ -8917,1 +9007,3 @@ + if (Ctx.getTargetInfo().getCXXABI().isMicrosoft()) + InitInfo.useMicrosoftABI(); ---------------- This should be limited in scope to only apply to static locals. We should be able to statically initialize globals. http://reviews.llvm.org/D16465 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits