mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	read_rtlil: warn on assigns after switches in case rules
This commit is contained in:
		
							parent
							
								
									4b3c03dabc
								
							
						
					
					
						commit
						4a057b3c44
					
				
					 3 changed files with 16 additions and 0 deletions
				
			
		| 
						 | 
					@ -31,6 +31,11 @@ void rtlil_frontend_yyerror(char const *s)
 | 
				
			||||||
	YOSYS_NAMESPACE_PREFIX log_error("Parser error in line %d: %s\n", rtlil_frontend_yyget_lineno(), s);
 | 
						YOSYS_NAMESPACE_PREFIX log_error("Parser error in line %d: %s\n", rtlil_frontend_yyget_lineno(), s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void rtlil_frontend_yywarning(char const *s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						YOSYS_NAMESPACE_PREFIX log_warning("In line %d: %s\n", rtlil_frontend_yyget_lineno(), s);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
YOSYS_NAMESPACE_BEGIN
 | 
					YOSYS_NAMESPACE_BEGIN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct RTLILFrontend : public Frontend {
 | 
					struct RTLILFrontend : public Frontend {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,6 +42,7 @@ YOSYS_NAMESPACE_END
 | 
				
			||||||
extern int rtlil_frontend_yydebug;
 | 
					extern int rtlil_frontend_yydebug;
 | 
				
			||||||
int rtlil_frontend_yylex(void);
 | 
					int rtlil_frontend_yylex(void);
 | 
				
			||||||
void rtlil_frontend_yyerror(char const *s);
 | 
					void rtlil_frontend_yyerror(char const *s);
 | 
				
			||||||
 | 
					void rtlil_frontend_yywarning(char const *s);
 | 
				
			||||||
void rtlil_frontend_yyrestart(FILE *f);
 | 
					void rtlil_frontend_yyrestart(FILE *f);
 | 
				
			||||||
int rtlil_frontend_yyparse(void);
 | 
					int rtlil_frontend_yyparse(void);
 | 
				
			||||||
int rtlil_frontend_yylex_destroy(void);
 | 
					int rtlil_frontend_yylex_destroy(void);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -344,6 +344,16 @@ assign_stmt:
 | 
				
			||||||
	TOK_ASSIGN sigspec sigspec EOL {
 | 
						TOK_ASSIGN sigspec sigspec EOL {
 | 
				
			||||||
		if (attrbuf.size() != 0)
 | 
							if (attrbuf.size() != 0)
 | 
				
			||||||
			rtlil_frontend_yyerror("dangling attribute");
 | 
								rtlil_frontend_yyerror("dangling attribute");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// See https://github.com/YosysHQ/yosys/pull/4765 for discussion on this
 | 
				
			||||||
 | 
							// warning
 | 
				
			||||||
 | 
							if (!switch_stack.back()->empty()) {
 | 
				
			||||||
 | 
								rtlil_frontend_yywarning(
 | 
				
			||||||
 | 
									"case rule assign statements after switch statements may cause unexpected behaviour. "
 | 
				
			||||||
 | 
									"The assign statement is reordered to come before all switch statements."
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case_stack.back()->actions.push_back(RTLIL::SigSig(*$2, *$3));
 | 
							case_stack.back()->actions.push_back(RTLIL::SigSig(*$2, *$3));
 | 
				
			||||||
		delete $2;
 | 
							delete $2;
 | 
				
			||||||
		delete $3;
 | 
							delete $3;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue