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 | 7860 | #endif |
| 7861 | 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 | 7864 | /* if old style function prototype, we accept a |
| 7863 | 7865 | declaration list */ |
| 7864 | 7866 | sym = type.ref; |
| @@ -216,14 +216,15 @@ int x[3]; · 215 unmodified lines | ||
| 216 | 216 | || defined test_func_2 \ |
| 217 | 217 | || defined test_func_3 \ |
| 218 | 218 | || defined test_func_4 \ |
| 219 | − || defined test_func_5 | |
| 219 | + || defined test_func_5 \ | |
| 220 | + || defined test_func_6 | |
| 220 | 221 | #if defined test_func_1 |
| 221 | 222 | int hello(int); |
| 222 | 223 | #elif defined test_func_4 |
| 223 | 224 | static int hello(int); |
| 224 | 225 | #endif |
| 225 | 226 | int main () { |
| 226 | −#if defined test_func_5 | |
| 227 | +#if defined test_func_6 | |
| 227 | 228 | static |
| 228 | 229 | #endif |
| 229 | 230 | int hello(int); |
| @@ -111,14 +111,17 @@ hello: a = 123 · 110 unmodified lines | ||
| 111 | 111 | hello: a = 123 |
| 112 | 112 | |
| 113 | 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 | 115 | hello: a = 123 |
| 116 | 116 | |
| 117 | 117 | [test_func_4] |
| 118 | 118 | hello: a = 123 |
| 119 | 119 | |
| 120 | 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 | 126 | [test_var_1] |
| 124 | 127 | main : 1 ; 1 |
| @@ -131,6 +134,6 @@ main : 2 ; 2 · 6 unmodified lines | ||
| 131 | 134 | bar : 3 ; 3 |
| 132 | 135 | |
| 133 | 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 | 139 | [test_var_4] |