History

instruduce C2x _Static_assert syntaxe

matthias committed 6 years ago

Commit 704b6021 parent cb041f13 files · +25 −9Browse files

Unified · Split

3 files
  1. tccgen.c +9 −0
  2. tests/tests2/60_errors_and_warnings.c +4 −0
  3. tests/tests2/60_errors_and_warnings.expect +12 −9
tccgen.c+9−0
@@ -7818,12 +7818,21 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 7817 unmodified lines
7818 next();7818 next();
7819 skip('(');7819 skip('(');
7820 c = expr_const();7820 c = expr_const();
7821
7822 if (tok == ')') {
7823 if (!c)
7824 tcc_error("_Static_assert fail");
7825 next();
7826 goto static_assert_out;
7827 }
7828
7821 skip(',');7829 skip(',');
7822 parse_mult_str(&error_str, "string constant");7830 parse_mult_str(&error_str, "string constant");
7823 if (c == 0)7831 if (c == 0)
7824 tcc_error("%s", error_str.data);7832 tcc_error("%s", error_str.data);
7825 cstr_free(&error_str);7833 cstr_free(&error_str);
7826 skip(')');7834 skip(')');
7835 static_assert_out:
7827 skip(';');7836 skip(';');
7828 continue;7837 continue;
7829 }7838 }
tests/tests2/60_errors_and_warnings.c+4−0
@@ -190,6 +190,10 @@ void * _Alignas(16) p1; · 189 unmodified lines
190 _Static_assert(1, "1"" is 1");190 _Static_assert(1, "1"" is 1");
191 _Static_assert(0, "0"" is 0");191 _Static_assert(0, "0"" is 0");
192 192
193#elif defined test_static_assert_c2x
194 _Static_assert(1);
195 _Static_assert(0);
196
193#elif defined test_void_array197#elif defined test_void_array
194 void t[3];198 void t[3];
195 199
tests/tests2/60_errors_and_warnings.expect+12−9
@@ -94,22 +94,25 @@ · 93 unmodified lines
94[test_static_assert_2]94[test_static_assert_2]
9560_errors_and_warnings.c:191: error: 0 is 09560_errors_and_warnings.c:191: error: 0 is 0
96 96
97[test_static_assert_c2x]
9860_errors_and_warnings.c:195: error: _Static_assert fail
99
97[test_void_array]100[test_void_array]
9860_errors_and_warnings.c:194: error: declaration of an array of incomplete type elements10160_errors_and_warnings.c:198: error: declaration of an array of incomplete type elements
99 102
100[test_incomplete_enum_array]103[test_incomplete_enum_array]
10160_errors_and_warnings.c:197: error: declaration of an array of incomplete type elements10460_errors_and_warnings.c:201: error: declaration of an array of incomplete type elements
102 105
103[test_incomplete_struct_array]106[test_incomplete_struct_array]
10460_errors_and_warnings.c:200: error: declaration of an array of incomplete type elements10760_errors_and_warnings.c:204: error: declaration of an array of incomplete type elements
105 108
106[test_const_fun_array]109[test_const_fun_array]
10760_errors_and_warnings.c:204: error: declaration of an array of functions11060_errors_and_warnings.c:208: error: declaration of an array of functions
108 111
109[test_incomplete_array_array]112[test_incomplete_array_array]
110 113
111[test_extern_array]114[test_extern_array]
11260_errors_and_warnings.c:220: error: incompatible types for redefinition of 'x'11560_errors_and_warnings.c:224: error: incompatible types for redefinition of 'x'
113 116
114[test_func_1]117[test_func_1]
115hello: a = 123118hello: a = 123
@@ -118,17 +121,17 @@ hello: a = 123 · 2 unmodified lines
118hello: a = 123121hello: a = 123
119 122
120[test_func_3]123[test_func_3]
12160_errors_and_warnings.c:250: warning: static storage ignored for redefinition of 'hello'12460_errors_and_warnings.c:254: warning: static storage ignored for redefinition of 'hello'
122hello: a = 123125hello: a = 123
123 126
124[test_func_4]127[test_func_4]
125hello: a = 123128hello: a = 123
126 129
127[test_func_5]130[test_func_5]
12860_errors_and_warnings.c:250: error: incompatible types for redefinition of 'hello'13160_errors_and_warnings.c:254: error: incompatible types for redefinition of 'hello'
129 132
130[test_func_6]133[test_func_6]
13160_errors_and_warnings.c:238: error: function without file scope cannot be static13460_errors_and_warnings.c:242: error: function without file scope cannot be static
132 135
133[test_var_1]136[test_var_1]
134main : 1 ; 1137main : 1 ; 1
@@ -141,6 +144,6 @@ main : 2 ; 2 · 6 unmodified lines
141bar : 3 ; 3144bar : 3 ; 3
142 145
143[test_var_3]146[test_var_3]
14460_errors_and_warnings.c:282: error: incompatible types for redefinition of 'xxx'14760_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx'
145 148
146[test_var_4]149[test_var_4]

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t