Skip to content
Snippets Groups Projects
Commit 5224fe7e authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[tests] test that we don't accept Generics on a VLA type

parent 81f0ff97
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@
STDOPT: #"-cpp-extra-args=-DINCOMPLETE_TYPE"
STDOPT: #"-cpp-extra-args=-DINCOMPATIBLE_QUALIFIED_TYPE"
STDOPT: #"-cpp-extra-args=-DFUNCTION_TYPE"
STDOPT: #"-cpp-extra-args=-DVLA"
EXIT: 0
STDOPT:
*/
......@@ -63,6 +64,11 @@ int main() {
#endif
#ifdef INCOMPATIBLE_QUALIFIED_TYPE
int a = _Generic("abc", char const *: 0);
#endif
#ifdef VLA
int x = 42;
int y[x];
int a = _Generic(y, int[x]: 0, default: 1);
#endif
int ok1 = _Generic("abc", char*: 0);
int ok2 = _Generic(1.0, float: 1, double: 0);
......
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:36:
[kernel] generic.c:37:
_Generic requires at least one generic association:
Location: line 36, between columns 10 and 25, before or at token: ;
34 int main() {
35 #ifdef NONE
36 int a = _Generic("abc");
Location: line 37, between columns 10 and 25, before or at token: ;
35 int main() {
36 #ifdef NONE
37 int a = _Generic("abc");
^^^^^^^^^^^^^^^
37 #endif
38 #ifdef TOO_MANY_DEFAULTS
38 #endif
39 #ifdef TOO_MANY_DEFAULTS
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
/* Generated by Frama-C */
int foo(int i)
{
int __retres;
__retres = 0;
return __retres;
}
void void_foo(int i)
{
return;
}
float cbrtf(float x);
int main(void)
{
int __retres;
float tmp;
int ok1 = 0;
int ok2 = 0;
int ok3 = 0;
int ok4 = 0;
tmp = cbrtf(0.0f);
double c = (double)tmp;
int ok5 = 0;
__retres = 0;
return __retres;
}
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:39: User Error:
[kernel] generic.c:40: User Error:
multiple default clauses in _Generic selection
37 #endif
38 #ifdef TOO_MANY_DEFAULTS
39 int a = _Generic("abc", default: 1, default: 1);
38 #endif
39 #ifdef TOO_MANY_DEFAULTS
40 int a = _Generic("abc", default: 1, default: 1);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40 #endif
41 #ifdef TOO_MANY_COMPATIBLE
41 #endif
42 #ifdef TOO_MANY_COMPATIBLE
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:43: User Error:
[kernel] generic.c:44: User Error:
multiple compatible types in _Generic selection:
'my_uint' and 'unsigned int'
41 #ifdef TOO_MANY_COMPATIBLE
42 // compatibility via typedef
43 int a = _Generic(42, my_uint: 1, unsigned int: 2);
42 #ifdef TOO_MANY_COMPATIBLE
43 // compatibility via typedef
44 int a = _Generic(42, my_uint: 1, unsigned int: 2);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44 #endif
45 #ifdef TOO_MANY_COMPATIBLE2
45 #endif
46 #ifdef TOO_MANY_COMPATIBLE2
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:47: User Error:
[kernel] generic.c:48: User Error:
multiple compatible types in _Generic selection:
'void (*)()' and 'void (*)(void)'
45 #ifdef TOO_MANY_COMPATIBLE2
46 // compatibility modulo implicit arguments
46 #ifdef TOO_MANY_COMPATIBLE2
47 // compatibility modulo implicit arguments
47 int a = _Generic(0,
48 void (*)(): 0,
49 void (*)(void): 0);
48 int a = _Generic(0,
49 void (*)(): 0,
50 void (*)(void): 0);
50 #endif
51 #ifdef TOO_MANY_COMPATIBLE3
51 #endif
52 #ifdef TOO_MANY_COMPATIBLE3
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:54: User Error:
[kernel] generic.c:55: User Error:
controlling expression compatible with more than one association type in _Generic selection:
controlling expression: '(void (*)())0' (type: void (*)());
compatible types: void (*)(void), void (*)(int )
52 // implicit arguments compatible between first and second selector,
53 // but the selectors themselves are not compatible between them
53 // implicit arguments compatible between first and second selector,
54 // but the selectors themselves are not compatible between them
54 int a = _Generic((void (*)()) 0,
55 void (*)(int): 0,
56 void (*)(void): 0);
55 int a = _Generic((void (*)()) 0,
56 void (*)(int): 0,
57 void (*)(void): 0);
57 #endif
58 #ifdef INCOMPLETE_TYPE
58 #endif
59 #ifdef INCOMPLETE_TYPE
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:59: User Error:
[kernel] generic.c:60: User Error:
generic association with incomplete type 'void'
57 #endif
58 #ifdef INCOMPLETE_TYPE
59 int a = _Generic(42, void: 1, default: 2);
58 #endif
59 #ifdef INCOMPLETE_TYPE
60 int a = _Generic(42, void: 1, default: 2);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60 #endif
61 #ifdef FUNCTION_TYPE
61 #endif
62 #ifdef FUNCTION_TYPE
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:65: User Error:
[kernel] generic.c:66: User Error:
no compatible types and no default type in _Generic selection:
controlling expression: '"abc"' (type: char *);
candidate types: char const *
63 #endif
64 #ifdef INCOMPATIBLE_QUALIFIED_TYPE
65 int a = _Generic("abc", char const *: 0);
64 #endif
65 #ifdef INCOMPATIBLE_QUALIFIED_TYPE
66 int a = _Generic("abc", char const *: 0);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 #endif
67 int ok1 = _Generic("abc", char*: 0);
67 #endif
68 #ifdef VLA
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:62:
[kernel] generic.c:63:
syntax error:
Location: line 62, column 27, before or at token: int
60 #endif
61 #ifdef FUNCTION_TYPE
62 int a = _Generic(1, void(int): 1);
Location: line 63, column 27, before or at token: int
61 #endif
62 #ifdef FUNCTION_TYPE
63 int a = _Generic(1, void(int): 1);
^
63 #endif
64 #ifdef INCOMPATIBLE_QUALIFIED_TYPE
64 #endif
65 #ifdef INCOMPATIBLE_QUALIFIED_TYPE
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
/* Generated by Frama-C */
int foo(int i)
{
int __retres;
__retres = 0;
return __retres;
}
void void_foo(int i)
{
return;
}
float cbrtf(float x);
int main(void)
{
int __retres;
float tmp;
int ok1 = 0;
int ok2 = 0;
int ok3 = 0;
int ok4 = 0;
tmp = cbrtf(0.0f);
double c = (double)tmp;
int ok5 = 0;
__retres = 0;
return __retres;
}
[kernel] generic.c:71: User Error:
generic association with variably modified type 'int [x]'
69 int x = 42;
70 int y[x];
71 int a = _Generic(y, int[x]: 0, default: 1);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72 #endif
73 int ok1 = _Generic("abc", char*: 0);
[kernel] Frama-C aborted: invalid user input.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment