[PATCH] D16951: [MS ABI] dllimport'd class cannot have constexpr ctors
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 7 13:39:10 PST 2016
majnemer added inline comments.
================
Comment at: test/SemaCXX/dllimport.cpp:1262
@@ -1261,1 +1261,3 @@
+struct __declspec(dllimport) PR26506_test1 {
+ virtual ~PR26506_test1() {}
----------------
thakis wrote:
> cl.exe seems to accept this – do you know how they do that? Do they just silently ignore the constexpr?
They silently ignore the constexpr:
struct __declspec(dllimport) PR26506_test1 {
virtual ~PR26506_test1() {}
constexpr PR26506_test1() = default;
};
constexpr PR26506_test1 x;
They report:
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
t.cpp
t.cpp(5): error C2127: 'x': illegal initialization of 'constexpr' entity with a non-constant expression
================
Comment at: test/SemaCXX/dllimport.cpp:1269
@@ +1268,3 @@
+ virtual ~PR26506_test2() {}
+ constexpr PR26506_test2() {} // expected-error{{constructor cannot be marked constexpr}}
+};
----------------
thakis wrote:
> nit: I feel diagnostics are easier to understand if their text is stand-alone and not spread across diag and its note. That is "dllimported constructors cannot be marked constexpr" "note: dllimported here" or something like this (this also helps with the mythical localization of diagnostics).
I chose this style because it is most consistent with our diagnostic for a `constexpr` constructor for a class with virtual bases.
http://reviews.llvm.org/D16951
More information about the cfe-commits
mailing list