diff --git a/parse.y b/parse.y index de839b334..f63ee1d9b 100644 --- a/parse.y +++ b/parse.y @@ -2200,6 +2200,15 @@ module_item K_endcase { 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. */ | K_specify K_endspecify diff --git a/parse_misc.cc b/parse_misc.cc index 60bd8b02e..546dec7cf 100644 --- a/parse_misc.cc +++ b/parse_misc.cc @@ -30,6 +30,15 @@ unsigned error_count = 0; unsigned warn_count = 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) { error_count += 1; @@ -39,20 +48,14 @@ void VLerror(const char*msg) void VLerror(const YYLTYPE&loc, const char*msg) { error_count += 1; - if (loc.text) - cerr << loc.text << ":"; - - cerr << loc.first_line << ": " << msg << endl; + cerr << loc << ": " << msg << endl; based_size = 0; /* Clear the base information if we have an error. */ } void yywarn(const YYLTYPE&loc, const char*msg) { warn_count += 1; - if (loc.text) - cerr << loc.text << ":"; - - cerr << loc.first_line << ": warning: " << msg << endl; + cerr << loc << ": warning: " << msg << endl; } int VLwrap() diff --git a/parse_misc.h b/parse_misc.h index 3960f1176..1d3e721a5 100644 --- a/parse_misc.h +++ b/parse_misc.h @@ -23,6 +23,7 @@ #endif # include +# include # include "compiler.h" # include "pform.h" @@ -62,6 +63,8 @@ extern void VLerror(const YYLTYPE&loc, const char*msg); #define yywarn VLwarn extern void VLwarn(const YYLTYPE&loc, const char*msg); +extern ostream& operator << (ostream&, const YYLTYPE&loc); + extern unsigned error_count, warn_count; extern unsigned long based_size;