PR modula2/114443 missing quote cause ICE

This patch inserts a missing quotation at the end of a line
if required (after an appropiate error message is generated).

gcc/m2/ChangeLog:

	PR modula2/114443
	* m2.flex: Call AddTokCharStar with a stringtok if
	end of line is reached without a closing quote.

gcc/testsuite/ChangeLog:

	PR modula2/114443
	* gm2/pim/fail/missingquote.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
Gaius Mulley 2024-03-23 15:49:23 +00:00
parent 80a0cb3745
commit c8a343f9f8
2 changed files with 10 additions and 0 deletions

View File

@ -188,12 +188,14 @@ extern void yylex (void);
\"[^\"\n]*\" { updatepos(); M2LexBuf_AddTokCharStar(M2Reserved_stringtok, yytext); return; }
\"[^\"\n]*$ { updatepos();
m2flex_M2Error("missing terminating quote, \"");
M2LexBuf_AddTokCharStar(M2Reserved_stringtok, yytext);
resetpos(); return;
}
'[^'\n]*' { updatepos(); M2LexBuf_AddTokCharStar(M2Reserved_stringtok, yytext); return; }
'[^'\n]*$ { updatepos();
m2flex_M2Error("missing terminating quote, '");
M2LexBuf_AddTokCharStar(M2Reserved_stringtok, yytext);
resetpos(); return;
}

View File

@ -0,0 +1,8 @@
MODULE missingquote ;
CONST
MyConst = 'foobar
BEGIN
END missingquote.