Silence spurious warning in Verilog lexer when compiling with GCC
authorRupert Swarbrick <rswarbrick@gmail.com>
Fri, 22 May 2020 13:29:42 +0000 (14:29 +0100)
committerRupert Swarbrick <rswarbrick@gmail.com>
Tue, 26 May 2020 16:54:57 +0000 (17:54 +0100)
The chosen value shouldn't have any effect. I considered something
clearly wrong like -1, but there's no checking inside the generated
lexer, and I suspect this will cause even weirder bugs if triggered
than just setting it to INITIAL.

frontends/verilog/verilog_lexer.l

index f6a3ac4db8f8ae5df0ae4ca9a90b3284df92ddb3..65a2e9a78e37a25e8c145d71efaef7a3459ac4a0 100644 (file)
@@ -128,7 +128,9 @@ static bool isUserType(std::string &s)
 %x BASED_CONST
 
 %%
-       int comment_caller;
+       // Initialise comment_caller to something to avoid a "maybe undefined"
+       // warning from GCC.
+       int comment_caller = INITIAL;
 
 <INITIAL,SYNOPSYS_TRANSLATE_OFF>"`file_push "[^\n]* {
        fn_stack.push_back(current_filename);