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
7859 }7859 }
7860#endif7860#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 a7864 /* if old style function prototype, we accept a
7863 declaration list */7865 declaration list */
7864 sym = type.ref;7866 sym = type.ref;
tests/tests2/60_errors_and_warnings.c+3−2
@@ -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_5219 || defined test_func_5 \
220 || defined test_func_6
220#if defined test_func_1221#if defined test_func_1
221int hello(int);222int hello(int);
222#elif defined test_func_4223#elif defined test_func_4
223static int hello(int);224static int hello(int);
224#endif225#endif
225int main () {226int main () {
226#if defined test_func_5227#if defined test_func_6
227 static228 static
228#endif229#endif
229 int hello(int);230 int hello(int);
tests/tests2/60_errors_and_warnings.expect+6−3
@@ -111,14 +111,17 @@ hello: a = 123 · 110 unmodified lines
111hello: a = 123111hello: a = 123
112 112
113[test_func_3]113[test_func_3]
11460_errors_and_warnings.c:241: warning: static storage ignored for redefinition of 'hello'11460_errors_and_warnings.c:242: warning: static storage ignored for redefinition of 'hello'
115hello: a = 123115hello: a = 123
116 116
117[test_func_4]117[test_func_4]
118hello: a = 123118hello: a = 123
119 119
120[test_func_5]120[test_func_5]
12160_errors_and_warnings.c:241: error: incompatible types for redefinition of 'hello'12160_errors_and_warnings.c:242: error: incompatible types for redefinition of 'hello'
122
123[test_func_6]
12460_errors_and_warnings.c:230: error: function without file scope cannot be static
122 125
123[test_var_1]126[test_var_1]
124main : 1 ; 1127main : 1 ; 1
@@ -131,6 +134,6 @@ main : 2 ; 2 · 6 unmodified lines
131bar : 3 ; 3134bar : 3 ; 3
132 135
133[test_var_3]136[test_var_3]
13460_errors_and_warnings.c:273: error: incompatible types for redefinition of 'xxx'13760_errors_and_warnings.c:274: error: incompatible types for redefinition of 'xxx'
135 138
136[test_var_4]139[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