History

Readd lost error on local static function decls

see testcase: block scope decls for functions can't use static (allowed is only extern or none). This got lost in commit 85690480.

Michael Matz committed 6 years ago

Commit b476a5f1 parent 6cb68c33 files · +11 −5Browse files

Unified · Split

3 files
  1. tccgen.c +2 −0
  2. tests/tests2/60_errors_and_warnings.c +3 −2
  3. tests/tests2/60_errors_and_warnings.expect +6 −3
tccgen.c+2−0
@@ -7859,6 +7859,8 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 7858 unmodified lines
78597859 }
78607860 #endif
78617861 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");
78627864 /* if old style function prototype, we accept a
78637865 declaration list */
78647866 sym = type.ref;
tests/tests2/60_errors_and_warnings.c+3−2
@@ -216,14 +216,15 @@ int x[3]; · 215 unmodified lines
216216 || defined test_func_2 \
217217 || defined test_func_3 \
218218 || defined test_func_4 \
219− || defined test_func_5
219+ || defined test_func_5 \
220+ || defined test_func_6
220221 #if defined test_func_1
221222 int hello(int);
222223 #elif defined test_func_4
223224 static int hello(int);
224225 #endif
225226 int main () {
226−#if defined test_func_5
227+#if defined test_func_6
227228 static
228229 #endif
229230 int hello(int);
tests/tests2/60_errors_and_warnings.expect+6−3
@@ -111,14 +111,17 @@ hello: a = 123 · 110 unmodified lines
111111 hello: a = 123
112112
113113 [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'
115115 hello: a = 123
116116
117117 [test_func_4]
118118 hello: a = 123
119119
120120 [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
122125
123126 [test_var_1]
124127 main : 1 ; 1
@@ -131,6 +134,6 @@ main : 2 ; 2 · 6 unmodified lines
131134 bar : 3 ; 3
132135
133136 [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'
135138
136139 [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