cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Missing support in SmPL for wide char character constants and string literals
@ 2019-10-02 21:05 Michael Stefaniuc
  2019-10-03  5:45 ` Julia Lawall
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Michael Stefaniuc @ 2019-10-02 21:05 UTC (permalink / raw)
  To: Coccinelle

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]

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

[-- Attachment #2: 0001-Add-test-for-wide-char-character-constants-and-strin.patch --]
[-- Type: text/x-patch, Size: 1753 bytes --]

From 5e96aa0f530f1bac644b0a38fff512b22c2d52a3 Mon Sep 17 00:00:00 2001
From: Michael Stefaniuc <mstefani@mykolab.com>
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 <mstefani@mykolab.com>
---
 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


[-- Attachment #3: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-02 21:05 [Cocci] Missing support in SmPL for wide char character constants and string literals Michael Stefaniuc
@ 2019-10-03  5:45 ` Julia Lawall
  2019-10-03  9:16   ` Markus Elfring
  2019-10-03 20:09   ` Michael Stefaniuc
  2019-10-03  8:17 ` Markus Elfring
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Julia Lawall @ 2019-10-03  5:45 UTC (permalink / raw)
  To: Michael Stefaniuc; +Cc: Coccinelle



On Wed, 2 Oct 2019, Michael Stefaniuc wrote:

> 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""

What is the type of these things?

julia

>
> 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
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-02 21:05 [Cocci] Missing support in SmPL for wide char character constants and string literals Michael Stefaniuc
  2019-10-03  5:45 ` Julia Lawall
@ 2019-10-03  8:17 ` Markus Elfring
  2019-10-04 19:37   ` Michael Stefaniuc
  2019-10-03 10:48 ` Markus Elfring
  2019-10-04 22:07 ` Julia Lawall
  3 siblings, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2019-10-03  8:17 UTC (permalink / raw)
  To: Michael Stefaniuc; +Cc: cocci

> A test case is attached as a patch for the coccinelle tests.

* Can the specification “#include <wchar.h>” become relevant for
  your source code example?
  https://en.cppreference.com/w/c/string/multibyte#Types

* Are you looking for better support of current programming language versions?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-03  5:45 ` Julia Lawall
@ 2019-10-03  9:16   ` Markus Elfring
  2019-10-03 20:09   ` Michael Stefaniuc
  1 sibling, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2019-10-03  9:16 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

> > 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""
>
> What is the type of these things?

I suggest to take another look at known information sources.
https://en.cppreference.com/w/c/language/arithmetic_types#Character_types
https://en.cppreference.com/w/c/language/character_constant
https://en.cppreference.com/w/c/language/string_literal


How should literal prefixes be handled by the semantic patch language?

Will any additional metavariable types become helpful for this use case?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-02 21:05 [Cocci] Missing support in SmPL for wide char character constants and string literals Michael Stefaniuc
  2019-10-03  5:45 ` Julia Lawall
  2019-10-03  8:17 ` Markus Elfring
@ 2019-10-03 10:48 ` Markus Elfring
  2019-10-04 22:07 ` Julia Lawall
  3 siblings, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2019-10-03 10:48 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

> minus: parse error:

How do you think about results from a smaller test case?

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-c unicode1.c
…
parse error
 = File "unicode1.c", line 4, column 14, charpos = 49
  around = ''\0'',
  whole content = char16_t z = u'\0';
badcount: 4
bad: #include <uchar.h>
bad: void xy(void)
bad: {
BAD:!!!!! char16_t z = u'\0';
bad: }
…
char16_t: present in 1 parsing errors
example:
       void xy(void)
       {
       char16_t z = u'\0';
       }
u: present in 1 parsing errors
example:
       void xy(void)
       {
       char16_t z = u'\0';
       }
…


How are the chances for support of Unicode data processing
by the semantic patch language?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-03  5:45 ` Julia Lawall
  2019-10-03  9:16   ` Markus Elfring
@ 2019-10-03 20:09   ` Michael Stefaniuc
  1 sibling, 0 replies; 9+ messages in thread
From: Michael Stefaniuc @ 2019-10-03 20:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

On 10/3/19 7:45 AM, Julia Lawall wrote:
> 
> 
> On Wed, 2 Oct 2019, Michael Stefaniuc wrote:
> 
>> 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""
> 
> What is the type of these things?
The test patch has the types in it, but here they are again:
u8"" ==> char[]
u"" ==> char16_t[]
U"" ==> char32_t[]
L"" ==> wchar_t[] (which depends on the compilation flags, 32bit
normally but 16bit with mingw and Wine)


bye
	michael


>>
>> 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
>>

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-03  8:17 ` Markus Elfring
@ 2019-10-04 19:37   ` Michael Stefaniuc
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Stefaniuc @ 2019-10-04 19:37 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

On 10/3/19 10:17 AM, Markus Elfring wrote:
>> A test case is attached as a patch for the coccinelle tests.
> 
> * Can the specification “#include <wchar.h>” become relevant for
>   your source code example?
Did you try it out yourself?

>   https://en.cppreference.com/w/c/string/multibyte#Types
Yes, that says that the char16_t and char32_t are defined in uchar.h.


bye
     michael
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-02 21:05 [Cocci] Missing support in SmPL for wide char character constants and string literals Michael Stefaniuc
                   ` (2 preceding siblings ...)
  2019-10-03 10:48 ` Markus Elfring
@ 2019-10-04 22:07 ` Julia Lawall
  2019-10-05 20:33   ` Michael Stefaniuc
  3 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2019-10-04 22:07 UTC (permalink / raw)
  To: Michael Stefaniuc; +Cc: Coccinelle



On Wed, 2 Oct 2019, Michael Stefaniuc wrote:

> 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""

The constants are now working.  Nothing has been done to add the
corresponding types.

julia

>
> 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
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Cocci] Missing support in SmPL for wide char character constants and string literals
  2019-10-04 22:07 ` Julia Lawall
@ 2019-10-05 20:33   ` Michael Stefaniuc
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Stefaniuc @ 2019-10-05 20:33 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

On 10/5/19 12:07 AM, Julia Lawall wrote:
> 
> 
> On Wed, 2 Oct 2019, Michael Stefaniuc wrote:
> 
>> 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""
> 
> The constants are now working.  Nothing has been done to add the
> corresponding types.
Many thanks Julia, tested and it works nicely.

I don't need the types, I've added them only for completeness.
In Wine we just need L"" and WCHAR and I typedef the later.


bye
	michael


>> 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
>>

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-05 20:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 21:05 [Cocci] Missing support in SmPL for wide char character constants and string literals Michael Stefaniuc
2019-10-03  5:45 ` Julia Lawall
2019-10-03  9:16   ` Markus Elfring
2019-10-03 20:09   ` Michael Stefaniuc
2019-10-03  8:17 ` Markus Elfring
2019-10-04 19:37   ` Michael Stefaniuc
2019-10-03 10:48 ` Markus Elfring
2019-10-04 22:07 ` Julia Lawall
2019-10-05 20:33   ` Michael Stefaniuc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).