]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR modula2/114443 missing quote cause ICE
authorGaius Mulley <gaiusmod2@gmail.com>
Sat, 23 Mar 2024 15:49:23 +0000 (15:49 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Sat, 23 Mar 2024 15:49:23 +0000 (15:49 +0000)
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>
gcc/m2/m2.flex
gcc/testsuite/gm2/pim/fail/missingquote.mod [new file with mode: 0644]

index f8f5ce64ad3628dd231c76c5afd6bc26d41ab656..e8ee383878e4dc2b845ce9efd68cd8a568ee0f5c 100644 (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;
                            }
 
diff --git a/gcc/testsuite/gm2/pim/fail/missingquote.mod b/gcc/testsuite/gm2/pim/fail/missingquote.mod
new file mode 100644 (file)
index 0000000..e78f0e3
--- /dev/null
@@ -0,0 +1,8 @@
+MODULE missingquote ;
+
+CONST
+   MyConst = 'foobar
+
+BEGIN
+
+END missingquote.