mirror of
https://github.com/frida/tinycc
synced 2024-11-28 02:29:38 +03:00
instruduce C2x _Static_assert syntaxe
This commit is contained in:
parent
cb041f11f6
commit
704b602184
9
tccgen.c
9
tccgen.c
@ -7818,12 +7818,21 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym)
|
||||
next();
|
||||
skip('(');
|
||||
c = expr_const();
|
||||
|
||||
if (tok == ')') {
|
||||
if (!c)
|
||||
tcc_error("_Static_assert fail");
|
||||
next();
|
||||
goto static_assert_out;
|
||||
}
|
||||
|
||||
skip(',');
|
||||
parse_mult_str(&error_str, "string constant");
|
||||
if (c == 0)
|
||||
tcc_error("%s", error_str.data);
|
||||
cstr_free(&error_str);
|
||||
skip(')');
|
||||
static_assert_out:
|
||||
skip(';');
|
||||
continue;
|
||||
}
|
||||
|
@ -190,6 +190,10 @@ void * _Alignas(16) p1;
|
||||
_Static_assert(1, "1"" is 1");
|
||||
_Static_assert(0, "0"" is 0");
|
||||
|
||||
#elif defined test_static_assert_c2x
|
||||
_Static_assert(1);
|
||||
_Static_assert(0);
|
||||
|
||||
#elif defined test_void_array
|
||||
void t[3];
|
||||
|
||||
|
@ -94,22 +94,25 @@
|
||||
[test_static_assert_2]
|
||||
60_errors_and_warnings.c:191: error: 0 is 0
|
||||
|
||||
[test_static_assert_c2x]
|
||||
60_errors_and_warnings.c:195: error: _Static_assert fail
|
||||
|
||||
[test_void_array]
|
||||
60_errors_and_warnings.c:194: error: declaration of an array of incomplete type elements
|
||||
60_errors_and_warnings.c:198: error: declaration of an array of incomplete type elements
|
||||
|
||||
[test_incomplete_enum_array]
|
||||
60_errors_and_warnings.c:197: error: declaration of an array of incomplete type elements
|
||||
60_errors_and_warnings.c:201: error: declaration of an array of incomplete type elements
|
||||
|
||||
[test_incomplete_struct_array]
|
||||
60_errors_and_warnings.c:200: error: declaration of an array of incomplete type elements
|
||||
60_errors_and_warnings.c:204: error: declaration of an array of incomplete type elements
|
||||
|
||||
[test_const_fun_array]
|
||||
60_errors_and_warnings.c:204: error: declaration of an array of functions
|
||||
60_errors_and_warnings.c:208: error: declaration of an array of functions
|
||||
|
||||
[test_incomplete_array_array]
|
||||
|
||||
[test_extern_array]
|
||||
60_errors_and_warnings.c:220: error: incompatible types for redefinition of 'x'
|
||||
60_errors_and_warnings.c:224: error: incompatible types for redefinition of 'x'
|
||||
|
||||
[test_func_1]
|
||||
hello: a = 123
|
||||
@ -118,17 +121,17 @@ hello: a = 123
|
||||
hello: a = 123
|
||||
|
||||
[test_func_3]
|
||||
60_errors_and_warnings.c:250: warning: static storage ignored for redefinition of 'hello'
|
||||
60_errors_and_warnings.c:254: warning: static storage ignored for redefinition of 'hello'
|
||||
hello: a = 123
|
||||
|
||||
[test_func_4]
|
||||
hello: a = 123
|
||||
|
||||
[test_func_5]
|
||||
60_errors_and_warnings.c:250: error: incompatible types for redefinition of 'hello'
|
||||
60_errors_and_warnings.c:254: error: incompatible types for redefinition of 'hello'
|
||||
|
||||
[test_func_6]
|
||||
60_errors_and_warnings.c:238: error: function without file scope cannot be static
|
||||
60_errors_and_warnings.c:242: error: function without file scope cannot be static
|
||||
|
||||
[test_var_1]
|
||||
main : 1 ; 1
|
||||
@ -141,6 +144,6 @@ main : 2 ; 2
|
||||
bar : 3 ; 3
|
||||
|
||||
[test_var_3]
|
||||
60_errors_and_warnings.c:282: error: incompatible types for redefinition of 'xxx'
|
||||
60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx'
|
||||
|
||||
[test_var_4]
|
||||
|
Loading…
Reference in New Issue
Block a user