Allow "stock static" in addition to "static stock".
This commit is contained in:
		
							parent
							
								
									3e012e7f79
								
							
						
					
					
						commit
						491036a1e6
					
				| @ -1445,12 +1445,25 @@ static void dodecl(const token_t *tok) | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   int fpublic = (tok->id == tPUBLIC); | ||||
|   int fstock = (tok->id == tSTOCK); | ||||
|   int fstatic = (tok->id == tSTATIC); | ||||
| 
 | ||||
|   if (fstatic && matchtoken(tSTOCK)) | ||||
|   int fpublic = FALSE, fstock = FALSE, fstatic = FALSE, fconst = FALSE; | ||||
|   switch (tok->id) { | ||||
|     case tPUBLIC: | ||||
|       fpublic = TRUE; | ||||
|       break; | ||||
|     case tSTOCK: | ||||
|       fstock = TRUE; | ||||
|       if (matchtoken(tSTATIC)) | ||||
|         fstatic = TRUE; | ||||
|       break; | ||||
|     case tSTATIC: | ||||
|       fstatic = TRUE; | ||||
| 
 | ||||
|       // For compatibility, we must include this case. Though "stock" should
 | ||||
|       // come first.
 | ||||
|       if (matchtoken(tSTOCK)) | ||||
|         fstock = TRUE; | ||||
|       break; | ||||
|   } | ||||
| 
 | ||||
|   int flags = DECLFLAG_MAYBE_FUNCTION | DECLFLAG_VARIABLE | DECLFLAG_ENUMROOT; | ||||
|   if (tok->id == tNEW) | ||||
| @ -1462,7 +1475,13 @@ static void dodecl(const token_t *tok) | ||||
|     decl.type.tag = 0; | ||||
|   } | ||||
| 
 | ||||
|   if (!decl.opertok && (tok->id == tNEW || decl.type.has_postdims || !lexpeek('('))) { | ||||
|   // Hacky bag o' hints as to whether this is a variable decl.
 | ||||
|   bool probablyVariable = tok->id == tNEW || | ||||
|                           decl.type.has_postdims || | ||||
|                           !lexpeek('(') || | ||||
|                           ((decl.type.usage & uCONST) == uCONST); | ||||
| 
 | ||||
|   if (!decl.opertok && probablyVariable) { | ||||
|     if (tok->id == tNEW && decl.type.is_new) | ||||
|       error(143); | ||||
|     if (decl.type.tag & STRUCTTAG) { | ||||
|  | ||||
							
								
								
									
										5
									
								
								sourcepawn/compiler/tests/ok-static-stocks-1.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								sourcepawn/compiler/tests/ok-static-stocks-1.sp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| static stock const X = 5; | ||||
| stock static const Y = 6; | ||||
| 
 | ||||
| public main() | ||||
| {} | ||||
							
								
								
									
										7
									
								
								sourcepawn/compiler/tests/ok-static-stocks-2.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								sourcepawn/compiler/tests/ok-static-stocks-2.sp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| static stock const X = 5; | ||||
| stock static const Y = 6; | ||||
| 
 | ||||
| public main() | ||||
| { | ||||
|   return X + Y; | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user