Fix a loophole with static local variables.
This commit is contained in:
		
							parent
							
								
									039572060e
								
							
						
					
					
						commit
						512cbc73a0
					
				| @ -2127,6 +2127,9 @@ static void declloc(int tokid) | |||||||
| 
 | 
 | ||||||
|     slength = fix_char_size(&decl); |     slength = fix_char_size(&decl); | ||||||
| 
 | 
 | ||||||
|  |     if (fstatic && type->ident == iREFARRAY) | ||||||
|  |       error(165); | ||||||
|  | 
 | ||||||
|     if (type->ident == iARRAY || fstatic) { |     if (type->ident == iARRAY || fstatic) { | ||||||
|       if (!parse_local_array_initializer(type, &cur_lit, &slength)) |       if (!parse_local_array_initializer(type, &cur_lit, &slength)) | ||||||
|         return; |         return; | ||||||
|  | |||||||
| @ -208,6 +208,7 @@ static const char *errmsg[] = { | |||||||
| /*162*/  "cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?\n", | /*162*/  "cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?\n", | ||||||
| /*163*/  "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n", | /*163*/  "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n", | ||||||
| /*164*/  "allocated array type '%s' doesn't match original type '%s'\n", | /*164*/  "allocated array type '%s' doesn't match original type '%s'\n", | ||||||
|  | /*165*/  "cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name?\n", | ||||||
| #else | #else | ||||||
|   "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", |   "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", | ||||||
|   "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", |   "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ public OnPluginStart() | |||||||
|   int v = 10; |   int v = 10; | ||||||
|   int invalid1[v]; |   int invalid1[v]; | ||||||
|   int[] invalid2 = {1}; |   int[] invalid2 = {1}; | ||||||
|  |   static int[] invalid3 = {1}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void invalid_arg1(int invalid[]) | void invalid_arg1(int invalid[]) | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| (1) : error 162: cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name? | (1) : error 162: cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name? | ||||||
| (6) : error 161: brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new int[size]' syntax? | (6) : error 161: brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new int[size]' syntax? | ||||||
| (7) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given | (7) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given | ||||||
| (10) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x') | (8) : error 165: cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name? | ||||||
| (14) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given | (11) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x') | ||||||
|  | (15) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user