diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-02-16 15:04:59 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-02-16 16:29:41 +0100 |
commit | 4c13e89d8ef6f1eed1952fbca7ae1476d0ccff65 (patch) | |
tree | fcea60e73c6b624cc3c9bc49d84abfe74b2dbba1 /compilerplugins/clang | |
parent | 4605dfa29649864638187940de4d1064ff056ac8 (diff) |
Fix compilerplugins/clang/test/consttobool.cxx
...after <https://github.com/llvm/llvm-project/commit/
9ce6dc9872be4081fb98f6161c28581e1cbbe7dc> "CWG1423: don't permit implicit
conversion of nullptr_t to bool." (Direct-initialization from std::nullptr_t to
bool is allowed in C++17, but it appears that will be dropped from C++20, see
<https://github.com/cplusplus/draft/commit/
df3e38121431afd9adcf7dce725a670a235463ea> "CWG1781 Converting from nullptr_t to
bool in overload resolution", at which point the new check for initialization of
S::b and the res.isNullPointer() branch in ConstToBool::VisitImplicitCastExpr,
compilerplugins/clang/consttobool.cxx, will probably become moot.)
Change-Id: I99773d13d514d5ba5296843592b740ea949b2b1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88784
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/test/consttobool.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/compilerplugins/clang/test/consttobool.cxx b/compilerplugins/clang/test/consttobool.cxx index 684a9739b2ab..28184825556e 100644 --- a/compilerplugins/clang/test/consttobool.cxx +++ b/compilerplugins/clang/test/consttobool.cxx @@ -25,6 +25,16 @@ enum E int const c1 = 1; constexpr int c2 = 2; +struct S +{ + S() + // expected-error-re@+1 {{implicit conversion of constant {{nullptr|0}} of type 'nullptr_t' to 'bool'; use 'false' instead [loplugin:consttobool]}} + : b(nullptr) + { + } + bool b; +}; + int main() { bool b; @@ -32,8 +42,6 @@ int main() b = 0; // expected-error@+1 {{implicit conversion of constant 1 of type 'sal_Bool' (aka 'unsigned char') to 'bool'; use 'true' instead [loplugin:consttobool]}} b = sal_True; - // expected-error-re@+1 {{implicit conversion of constant {{nullptr|0}} of type 'nullptr_t' to 'bool'; use 'false' instead [loplugin:consttobool]}} - b = nullptr; // expected-error@+1 {{implicit conversion of constant 1.000000e+00 of type 'double' to 'bool'; use 'true' instead [loplugin:consttobool]}} b = 1.0; // expected-error@+1 {{implicit conversion of constant 2 of type 'E' to 'bool'; use 'true' instead [loplugin:consttobool]}} |