Detect and warn about anachronistic use of begin/end in generate.
Verilog-2001 only allows a single generate item within a generate- endgenerate region, but allowed one to collect generate schemes with begin/end blocks. Verilog-2005 cleaned up that mess, and it is the 2005 syntax that Icarus Verilog implements. This patch detects the anachronistic use of begin/end within the generate region, ignores the begin/end words, and prints a warning that the user is using an obsolete syntax.
This commit is contained in:
parent
b2c9352bb5
commit
ce9fd0147f
9
parse.y
9
parse.y
|
|
@ -2200,6 +2200,15 @@ module_item
|
||||||
K_endcase
|
K_endcase
|
||||||
{ pform_endgenerate(); }
|
{ pform_endgenerate(); }
|
||||||
|
|
||||||
|
/* Handle some anachronistic syntax cases. */
|
||||||
|
| K_generate K_begin module_item_list_opt K_end K_endgenerate
|
||||||
|
{ /* Detect and warn about anachronistic begin/end use */
|
||||||
|
if (generation_flag > GN_VER2001) {
|
||||||
|
warn_count += 1;
|
||||||
|
cerr << @2 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* specify blocks are parsed but ignored. */
|
/* specify blocks are parsed but ignored. */
|
||||||
|
|
||||||
| K_specify K_endspecify
|
| K_specify K_endspecify
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,15 @@ unsigned error_count = 0;
|
||||||
unsigned warn_count = 0;
|
unsigned warn_count = 0;
|
||||||
unsigned long based_size = 0;
|
unsigned long based_size = 0;
|
||||||
|
|
||||||
|
std::ostream& operator << (std::ostream&o, const YYLTYPE&loc)
|
||||||
|
{
|
||||||
|
if (loc.text)
|
||||||
|
o << loc.text << ":";
|
||||||
|
o << loc.first_line;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VLerror(const char*msg)
|
void VLerror(const char*msg)
|
||||||
{
|
{
|
||||||
error_count += 1;
|
error_count += 1;
|
||||||
|
|
@ -39,20 +48,14 @@ void VLerror(const char*msg)
|
||||||
void VLerror(const YYLTYPE&loc, const char*msg)
|
void VLerror(const YYLTYPE&loc, const char*msg)
|
||||||
{
|
{
|
||||||
error_count += 1;
|
error_count += 1;
|
||||||
if (loc.text)
|
cerr << loc << ": " << msg << endl;
|
||||||
cerr << loc.text << ":";
|
|
||||||
|
|
||||||
cerr << loc.first_line << ": " << msg << endl;
|
|
||||||
based_size = 0; /* Clear the base information if we have an error. */
|
based_size = 0; /* Clear the base information if we have an error. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void yywarn(const YYLTYPE&loc, const char*msg)
|
void yywarn(const YYLTYPE&loc, const char*msg)
|
||||||
{
|
{
|
||||||
warn_count += 1;
|
warn_count += 1;
|
||||||
if (loc.text)
|
cerr << loc << ": warning: " << msg << endl;
|
||||||
cerr << loc.text << ":";
|
|
||||||
|
|
||||||
cerr << loc.first_line << ": warning: " << msg << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VLwrap()
|
int VLwrap()
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include <list>
|
# include <list>
|
||||||
|
# include <ostream>
|
||||||
# include "compiler.h"
|
# include "compiler.h"
|
||||||
# include "pform.h"
|
# include "pform.h"
|
||||||
|
|
||||||
|
|
@ -62,6 +63,8 @@ extern void VLerror(const YYLTYPE&loc, const char*msg);
|
||||||
#define yywarn VLwarn
|
#define yywarn VLwarn
|
||||||
extern void VLwarn(const YYLTYPE&loc, const char*msg);
|
extern void VLwarn(const YYLTYPE&loc, const char*msg);
|
||||||
|
|
||||||
|
extern ostream& operator << (ostream&, const YYLTYPE&loc);
|
||||||
|
|
||||||
extern unsigned error_count, warn_count;
|
extern unsigned error_count, warn_count;
|
||||||
extern unsigned long based_size;
|
extern unsigned long based_size;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue