see testcase: block scope decls for functions can't use static (allowed is only extern or none). This got lost in commit 85690480.
Unified · Split
| @@ -7859,6 +7859,8 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 7858 unmodified lines | |||
| 7859 | } | 7859 | } |
| 7860 | #endif | 7860 | #endif |
| 7861 | if ((type.t & VT_BTYPE) == VT_FUNC) { | 7861 | if ((type.t & VT_BTYPE) == VT_FUNC) { |
| 7862 | if ((type.t & VT_STATIC) && (l == VT_LOCAL)) | ||
| 7863 | tcc_error("function without file scope cannot be static"); | ||
| 7862 | /* if old style function prototype, we accept a | 7864 | /* if old style function prototype, we accept a |
| 7863 | declaration list */ | 7865 | declaration list */ |
| 7864 | sym = type.ref; | 7866 | sym = type.ref; |
| @@ -216,14 +216,15 @@ int x[3]; · 215 unmodified lines | |||
| 216 | || defined test_func_2 \ | 216 | || defined test_func_2 \ |
| 217 | || defined test_func_3 \ | 217 | || defined test_func_3 \ |
| 218 | || defined test_func_4 \ | 218 | || defined test_func_4 \ |
| 219 | || defined test_func_5 | 219 | || defined test_func_5 \ |
| 220 | || defined test_func_6 | ||
| 220 | #if defined test_func_1 | 221 | #if defined test_func_1 |
| 221 | int hello(int); | 222 | int hello(int); |
| 222 | #elif defined test_func_4 | 223 | #elif defined test_func_4 |
| 223 | static int hello(int); | 224 | static int hello(int); |
| 224 | #endif | 225 | #endif |
| 225 | int main () { | 226 | int main () { |
| 226 | #if defined test_func_5 | 227 | #if defined test_func_6 |
| 227 | static | 228 | static |
| 228 | #endif | 229 | #endif |
| 229 | int hello(int); | 230 | int hello(int); |
| @@ -111,14 +111,17 @@ hello: a = 123 · 110 unmodified lines | |||
| 111 | hello: a = 123 | 111 | hello: a = 123 |
| 112 | 112 | ||
| 113 | [test_func_3] | 113 | [test_func_3] |
| 114 | 60_errors_and_warnings.c:241: warning: static storage ignored for redefinition of 'hello' | 114 | 60_errors_and_warnings.c:242: warning: static storage ignored for redefinition of 'hello' |
| 115 | hello: a = 123 | 115 | hello: a = 123 |
| 116 | 116 | ||
| 117 | [test_func_4] | 117 | [test_func_4] |
| 118 | hello: a = 123 | 118 | hello: a = 123 |
| 119 | 119 | ||
| 120 | [test_func_5] | 120 | [test_func_5] |
| 121 | 60_errors_and_warnings.c:241: error: incompatible types for redefinition of 'hello' | 121 | 60_errors_and_warnings.c:242: error: incompatible types for redefinition of 'hello' |
| 122 | |||
| 123 | [test_func_6] | ||
| 124 | 60_errors_and_warnings.c:230: error: function without file scope cannot be static | ||
| 122 | 125 | ||
| 123 | [test_var_1] | 126 | [test_var_1] |
| 124 | main : 1 ; 1 | 127 | main : 1 ; 1 |
| @@ -131,6 +134,6 @@ main : 2 ; 2 · 6 unmodified lines | |||
| 131 | bar : 3 ; 3 | 134 | bar : 3 ; 3 |
| 132 | 135 | ||
| 133 | [test_var_3] | 136 | [test_var_3] |
| 134 | 60_errors_and_warnings.c:273: error: incompatible types for redefinition of 'xxx' | 137 | 60_errors_and_warnings.c:274: error: incompatible types for redefinition of 'xxx' |
| 135 | 138 | ||
| 136 | [test_var_4] | 139 | [test_var_4] |