aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/builtin-functions.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2024-12-09 12:34:25 +0100
committerGitHub <noreply@github.com>2024-12-09 12:34:25 +0100
commit00b50c917bf5e5abaded4f314b767b086069d1ee (patch)
tree360b0acf8c2eae0a8c1a4445ba7c0880556e3c40 /clang/test/AST/ByteCode/builtin-functions.cpp
parentbbd99d903ec956b5cc87c544854337da8db2d2bf (diff)
downloadllvm-00b50c917bf5e5abaded4f314b767b086069d1ee.zip
llvm-00b50c917bf5e5abaded4f314b767b086069d1ee.tar.gz
llvm-00b50c917bf5e5abaded4f314b767b086069d1ee.tar.bz2
[clang][bytecode] Handle __builtin_wcslen (#119187)
Handle different char widths in builtin_strlen.
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r--clang/test/AST/ByteCode/builtin-functions.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp
index e2121a5..4c21496 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -15,6 +15,10 @@
#error "huh?"
#endif
+extern "C" {
+ typedef decltype(sizeof(int)) size_t;
+ extern size_t wcslen(const wchar_t *p);
+}
namespace strcmp {
constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -93,6 +97,14 @@ constexpr const char *a = "foo\0quux";
constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
constexpr int bad = __builtin_strlen(d); // both-error {{constant expression}} \
// both-note {{one-past-the-end}}
+
+ constexpr int wn = __builtin_wcslen(L"hello");
+ static_assert(wn == 5);
+ constexpr int wm = wcslen(L"hello"); // both-error {{constant expression}} \
+ // both-note {{non-constexpr function 'wcslen' cannot be used in a constant expression}}
+
+ int arr[3]; // both-note {{here}}
+ int wk = arr[wcslen(L"hello")]; // both-warning {{array index 5}}
}
namespace nan {