Fix off by one in m2.flex when the line number is set via cpp.
gcc/m2/ChangeLog:
PR modula2/110019
* gm2-compiler/SymbolKey.mod (SearchAndDo): Reformatted.
(ForeachNodeDo): Reformatted.
* gm2-compiler/SymbolTable.mod (AddListify): Join list
with "," or "and" if more than one word is in the list.
* m2.flex: Remove -1 from atoi(yytext) line number.
gcc/testsuite/ChangeLog:
PR modula2/110019
* gm2/cpp/fail/cpp-fail.exp: New test.
* gm2/cpp/fail/foocpp.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
PROCEDURE ForeachNodeDo (t: SymbolTree; P: PerformOperation) ;
BEGIN
- SearchAndDo(t^.Left, P)
+ SearchAndDo (t^.Left, P)
END ForeachNodeDo ;
IF t#NIL
THEN
WITH t^ DO
- SearchAndDo(Right, P) ;
- P(KeySym) ;
- SearchAndDo(Left, P)
+ SearchAndDo (Right, P) ;
+ P (KeySym) ;
+ SearchAndDo (Left, P)
END
END
END SearchAndDo ;
PROCEDURE AddListify (sym: CARDINAL) ;
BEGIN
INC (ListifyWordCount) ;
- IF ListifyWordCount = ListifyTotal
+ (* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d\n",
+ ListifyWordCount, ListifyTotal) ; *)
+ IF ListifyWordCount > 1
THEN
- ListifySentance := ConCat (ListifySentance, Mark (InitString (" and ")))
- ELSIF ListifyWordCount > 1
- THEN
- ListifySentance := ConCat (ListifySentance, Mark (InitString (", ")))
+ IF ListifyWordCount = ListifyTotal
+ THEN
+ ListifySentance := ConCat (ListifySentance, Mark (InitString (" and ")))
+ ELSE
+ ListifySentance := ConCat (ListifySentance, Mark (InitString (", ")))
+ END
END ;
ListifySentance := ConCat (ListifySentance,
Mark (InitStringCharStar (KeyToCharStar (GetSymName (sym)))))
^\#.* { consumeLine(); /* printf("found: %s\n", currentLine->linebuf); */ BEGIN LINE0; }
\n\#.* { consumeLine(); /* printf("found: %s\n", currentLine->linebuf); */ BEGIN LINE0; }
<LINE0>\#[ \t]* { updatepos(); }
-<LINE0>[0-9]+[ \t]*\" { updatepos(); lineno=atoi(yytext)-1; BEGIN LINE1; }
+<LINE0>[0-9]+[ \t]*\" { updatepos(); lineno=atoi(yytext); BEGIN LINE1; }
<LINE0>\n { m2flex_M2Error("missing initial quote after #line directive"); resetpos(); BEGIN INITIAL; }
<LINE0>[^\n]
<LINE1>[^\"\n]+ { m2flex_M2Error("missing final quote after #line directive"); resetpos(); BEGIN INITIAL; }
--- /dev/null
+# Expect driver script for GCC Regression Tests
+# Copyright (C) 2003-2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was written by Gaius Mulley (gaius.mulley@southwales.ac.uk)
+# for GNU Modula-2.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# load support procs
+load_lib gm2-torture.exp
+
+gm2_init_pim "${srcdir}/gm2/pim/fail" -fcpp
+
+foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/foocpp.mod]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $testcase] then {
+ continue
+ }
+
+ gm2-torture-fail $testcase
+}
--- /dev/null
+MODULE foo;
+
+BEGIN
+ i := 0;
+END foo.