Hello!
SmPL doesn't support the character constants of the form:
u'c', U'c', L'c'
nor the string literals of the form:
u8"", u"", U"", L""
A test case is attached as a patch for the coccinelle tests.
minus: parse error:
File "tests/wchar.cocci", line 8, column 22, charpos = 106
around = ''',
whole content = - char16_t zero = u'\0';
thanks
bye
michael
>From 5e96aa0f530f1bac644b0a38fff512b22c2d52a3 Mon Sep 17 00:00:00 2001
From: Michael Stefaniuc <[email protected]>
Date: Wed, 2 Oct 2019 22:50:10 +0200
Subject: [PATCH] Add test for wide char character constants and string
literals
Signed-off-by: Michael Stefaniuc <[email protected]>
---
tests/wchar.c | 13 +++++++++++++
tests/wchar.cocci | 29 +++++++++++++++++++++++++++++
tests/wchar.res | 4 ++++
3 files changed, 46 insertions(+)
create mode 100644 tests/wchar.c
create mode 100644 tests/wchar.cocci
create mode 100644 tests/wchar.res
diff --git a/tests/wchar.c b/tests/wchar.c
new file mode 100644
index 00000000..0fde305a
--- /dev/null
+++ b/tests/wchar.c
@@ -0,0 +1,13 @@
+#include <stddef.h>
+#include <uchar.h>
+int main () {
+ char zero = '\0';
+ char16_t zero_utf16 = u'\0';
+ char32_t zero_utf32 = U'\0';
+ wchar_t zeroL = L'\0';
+ char empty[] = "";
+ char empty_utf8[] = u8"";
+ char16_t empty_utf16[] = u"";
+ char32_t empty_utf32[] = U"";
+ wchar_t emptyL[] = L"";
+}
diff --git a/tests/wchar.cocci b/tests/wchar.cocci
new file mode 100644
index 00000000..cdb6cb44
--- /dev/null
+++ b/tests/wchar.cocci
@@ -0,0 +1,29 @@
+@@
+typedef char16_t, char32_t, wchar_t;
+identifier zero;
+@@
+(
+- char zero = '\0';
+|
+- char16_t zero = u'\0';
+|
+- char32_t zero = U'\0';
+|
+- wchar_t zero = L'\0';
+)
+
+
+@@
+identifier empty;
+@@
+(
+- char empty[] = "";
+|
+- char empty[] = u8""
+|
+- char16_t empty[] = u"";
+|
+- char32_t empty[] = U"";
+|
+- wchar_t empty[] = L"";
+)
diff --git a/tests/wchar.res b/tests/wchar.res
new file mode 100644
index 00000000..aa1f2134
--- /dev/null
+++ b/tests/wchar.res
@@ -0,0 +1,4 @@
+#include <stddef.h>
+#include <uchar.h>
+int main () {
+}
--
2.20.1
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci