Skip to content
Snippets Groups Projects
Commit 73eb6812 authored by Andre Maroneze's avatar Andre Maroneze
Browse files

add test and update test oracles

parent 8ba130d4
No related branches found
No related tags found
No related merge requests found
Showing
with 170 additions and 15 deletions
......@@ -3,7 +3,6 @@
STDOPT: #"-cpp-extra-args=-DALIGNAS"
STDOPT: #"-cpp-extra-args=-DALIGNOF"
STDOPT: #"-cpp-extra-args=-DCOMPLEX"
STDOPT: #"-cpp-extra-args=-DGENERIC"
STDOPT: #"-cpp-extra-args=-DIMAGINARY"
*/
......@@ -22,10 +21,6 @@ int main(void) {
double _Complex c = 1;
#endif
#ifdef GENERIC
int generic = _Generic('0', char: 1, int: 2, default: 0);
#endif
#ifdef IMAGINARY
//Note: GCC/Clang do not yet support _Imaginary
double _Imaginary im = 0;
......
/* run.config
EXIT: 1
STDOPT:
STDOPT: #"-c11 -cpp-extra-args=-DNONE"
STDOPT: #"-c11 -cpp-extra-args=-DTOO_MANY_DEFAULTS"
STDOPT: #"-c11 -cpp-extra-args=-DTOO_MANY_COMPATIBLE"
STDOPT: #"-c11 -cpp-extra-args=-DTOO_MANY_COMPATIBLE2"
STDOPT: #"-c11 -cpp-extra-args=-DTOO_MANY_COMPATIBLE3"
STDOPT: #"-c11 -cpp-extra-args=-DINCOMPLETE_TYPE"
STDOPT: #"-c11 -cpp-extra-args=-DINCOMPATIBLE_QUALIFIED_TYPE"
STDOPT: #"-c11 -cpp-extra-args=-DFUNCTION_TYPE"
EXIT: 0
STDOPT: #"-c11"
*/
// Some tests inspired by llvm/clang/test/Sema/generic-selection.c
typedef unsigned int my_uint;
// Example from the C11 standard
double cbrt(double x);
float cbrtf(float x);
long double cbrtl(long double x);
#define cbrt(X) _Generic((X), \
long double: cbrtl, \
default: cbrt, \
float: cbrtf \
)(X)
int main() {
#ifdef NONE
int a = _Generic("abc");
#endif
#ifdef TOO_MANY_DEFAULTS
int a = _Generic("abc", default: 1, default: 1);
#endif
#ifdef TOO_MANY_COMPATIBLE
// compatibility via typedef
int a = _Generic(42, my_uint: 1, unsigned int: 2);
#endif
#ifdef TOO_MANY_COMPATIBLE2
// compatibility modulo implicit arguments
int a = _Generic(0,
void (*)(): 0,
void (*)(void): 0);
#endif
#ifdef TOO_MANY_COMPATIBLE3
// implicit arguments compatible between first and second selector,
// but the selectors themselves are not compatible between them
int a = _Generic((void (*)()) 0,
void (*)(int): 0,
void (*)(void): 0);
#endif
#ifdef INCOMPLETE_TYPE
int a = _Generic(42, void: 1, default: 2);
#endif
#ifdef FUNCTION_TYPE
int a = _Generic(1, void(int): 1);
#endif
#ifdef INCOMPATIBLE_QUALIFIED_TYPE
int a = _Generic("abc", char const *: 0);
#endif
int ok1 = _Generic("abc", char*: 0);
int ok2 = _Generic(1.0, float: 1, double: 0);
int ok3 = _Generic(1L, short: 1, unsigned int: 2, int: 3, long: 0, unsigned long: 5);
void p(int);
int ok4 = _Generic(p, void(*)(int): 0, void(*)(long): 1);
double c = cbrt(0.0f);
return 0;
}
[kernel] Parsing c11-keywords.c (with preprocessing)
[kernel] c11-keywords.c:12: Failure:
[kernel] c11-keywords.c:11: Failure:
_Alignas is currently unsupported by Frama-C.
[kernel] User Error: stopping on file "c11-keywords.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
......
[kernel] Parsing c11-keywords.c (with preprocessing)
[kernel] c11-keywords.c:18: Failure:
[kernel] c11-keywords.c:17: Failure:
_Alignof is currently unsupported by Frama-C.
[kernel] User Error: stopping on file "c11-keywords.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
......
[kernel] Parsing c11-keywords.c (with preprocessing)
[kernel] c11-keywords.c:22: Failure:
[kernel] c11-keywords.c:21: Failure:
_Complex is currently unsupported by Frama-C.
[kernel] User Error: stopping on file "c11-keywords.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
......
[kernel] Parsing c11-keywords.c (with preprocessing)
[kernel] c11-keywords.c:26: Failure:
_Generic is currently unsupported by Frama-C.
_Imaginary is currently unsupported by Frama-C.
[kernel] User Error: stopping on file "c11-keywords.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing c11-keywords.c (with preprocessing)
[kernel] c11-keywords.c:31: Failure:
_Imaginary is currently unsupported by Frama-C.
[kernel] User Error: stopping on file "c11-keywords.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel:parser:conditional-feature] Warning:
_Generic is a C11 keyword, use -c11 option to enable it
[kernel] generic.c:63:
syntax error:
Location: line 63, between columns 25 and 28, before or at token: char
61 int a = _Generic("abc", char const *: 0);
62 #endif
63 int ok1 = _Generic("abc", char*: 0);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64 int ok2 = _Generic(1.0, float: 1, double: 0);
65 int ok3 = _Generic(1L, short: 1, unsigned int: 2, int: 3, long: 0, unsigned long: 5);
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:32:
syntax error:
Location: line 32, between columns 23 and 24, before or at token: )
30 int main() {
31 #ifdef NONE
32 int a = _Generic("abc");
^^^^^^^^^^^^^^^^^^^^^^^^^^
33 #endif
34 #ifdef TOO_MANY_DEFAULTS
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:35: User Error:
multiple default clauses in _Generic selection
[kernel] User Error: stopping on file "generic.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:39: User Error:
multiple compatible types in _Generic selection:
'my_uint' and 'unsigned int'
[kernel] User Error: stopping on file "generic.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:43: User Error:
multiple compatible types in _Generic selection:
'void (*)()' and 'void (*)(void)'
[kernel] User Error: stopping on file "generic.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:50: User Error:
controlling expression compatible with more than one association type in _Generic selection:
controlling expression: '(void (*)())0' (type: void (*)());
compatible types: void (*)(int ), void (*)(void)
[kernel] User Error: stopping on file "generic.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:55: User Error:
generic association with incomplete type 'void'
[kernel] User Error: stopping on file "generic.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:61: User Error:
no compatible types and no default type in _Generic selection:
controlling expression: '"abc"' (type: char *);
candidate types: char const *
[kernel] User Error: stopping on file "generic.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
[kernel] generic.c:58:
syntax error:
Location: line 58, between columns 26 and 27, before or at token: int
56 #endif
57 #ifdef FUNCTION_TYPE
58 int a = _Generic(1, void(int): 1);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59 #endif
60 #ifdef INCOMPATIBLE_QUALIFIED_TYPE
[kernel] Frama-C aborted: invalid user input.
[kernel] Parsing generic.c (with preprocessing)
/* Generated by Frama-C */
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;
__retres = 0;
return __retres;
}
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