spew.c (yylex): Only copy the token's lineno, if it is non-zero.
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 26 Jul 2001 08:15:43 +0000 (08:15 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 26 Jul 2001 08:15:43 +0000 (08:15 +0000)
cp:
* spew.c (yylex): Only copy the token's lineno, if it is
non-zero.
testsuite:
* g++.old-deja/g++.other/lineno5.C: New test.

From-SVN: r44391

gcc/cp/ChangeLog
gcc/cp/spew.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/lineno5.C [new file with mode: 0644]

index 949dd82bbf0566044b839c21335b7307dc6165f0..dd1be64de8e7acd3e5940e128d8116058ab6daf5 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-26  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * spew.c (yylex): Only copy the token's lineno, if it is
+       non-zero.
+
 2001-07-26  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/3624
index 7a92d9d0caf80bed1df62ddf07b8b34a4a0e6867..28b2323ed994f9645ffb2fa22e6c9eda5af159a3 100644 (file)
@@ -833,8 +833,13 @@ yylex ()
     got_object = NULL_TREE;
 
   yychar = yychr;
-  yylval = nth_token (0)->yylval;
-  lineno = nth_token (0)->lineno;
+  {
+    struct token *tok = nth_token (0);
+    
+    yylval = tok->yylval;
+    if (tok->lineno)
+      lineno = tok->lineno;
+  }
 
 #ifdef SPEW_DEBUG    
   if (spew_debug)
index 55f597fe5ec4d2dfd6a010d9c6ba7ee687647124..f2354d4a76e6c288f59ae8ce60d57ea70bcc4d8f 100644 (file)
@@ -1,3 +1,7 @@
+2001-07-26  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.other/lineno5.C: New test.
+
 2001-07-26  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.pt/crash68.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/lineno5.C b/gcc/testsuite/g++.old-deja/g++.other/lineno5.C
new file mode 100644 (file)
index 0000000..dc779ed
--- /dev/null
@@ -0,0 +1,19 @@
+// Build don't link:
+// 
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 25 Jul 2001 <nathan@codesourcery.com>
+
+// Origin: johanb@DoCS.UU.SE
+// Bug 3621. At the end of saved input, we'd set the lineno to
+// zero. This would confusing things no end, if there was a subsequent
+// error.
+
+namespace tmp {
+  typedef int B;
+  B b;
+}
+
+class A {
+  public:
+  int kaka(tmp::B = b);                // ERROR - no b in scope
+};