summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test/stringliteralvar.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-01-27 16:45:22 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-01-27 23:24:42 +0100
commitaa2064c5c5f23f6f4b7bc44e12345b37f66995bc (patch)
treea5073b6d0b0c5846575671975341f0e0b393d98d /compilerplugins/clang/test/stringliteralvar.cxx
parent686582b4890f458b6b8ee0e1ab19d9ad64793c85 (diff)
Improve loplugin:stringliteralvar
...to also consider O[U]String ctors taking pointer and length Change-Id: Iea5041634bfbf5054a1317701e30b56f72e940fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110025 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/test/stringliteralvar.cxx')
-rw-r--r--compilerplugins/clang/test/stringliteralvar.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/stringliteralvar.cxx b/compilerplugins/clang/test/stringliteralvar.cxx
index 25a85f90a5a3..de67de5c7679 100644
--- a/compilerplugins/clang/test/stringliteralvar.cxx
+++ b/compilerplugins/clang/test/stringliteralvar.cxx
@@ -12,6 +12,7 @@
#include <vector>
#include <rtl/ustring.hxx>
+#include <sal/macros.h>
// expected-error@+1 {{change type of variable 'literal1' from constant character array ('const char [4]') to OStringLiteral [loplugin:stringliteralvar]}}
char const literal1[] = "foo";
@@ -78,4 +79,12 @@ void f8()
(void)sizeof literal;
}
+void f9()
+{
+ // expected-error@+1 {{change type of variable 'literal' from constant character array ('const sal_Unicode [3]') to OUStringLiteral [loplugin:stringliteralvar]}}
+ static sal_Unicode const literal[] = { 'f', 'o', 'o' };
+ // expected-note@+1 {{first passed into a 'rtl::OUString' constructor here [loplugin:stringliteralvar]}}
+ f(OUString(literal, SAL_N_ELEMENTS(literal)));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */