spew.c (yyerror): Cope if yylval.ttype is NULL.
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 28 Nov 2000 10:23:03 +0000 (10:23 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 28 Nov 2000 10:23:03 +0000 (10:23 +0000)
cp:
* spew.c (yyerror): Cope if yylval.ttype is NULL.
testsuite:
* g++.old-deja/g++.other/parse2.C: New test.

From-SVN: r37816

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

index 7f18e81350ce5181a38fd6f5ba16913931cd01b0..9d486f6a59cc473b76780221e9d24a2236f160da 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * spew.c (yyerror): Cope if yylval.ttype is NULL.
+
 2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * decl.c (grokdeclarator): Diagnose undefined template contexts.
index 070cf2fef98d504456990a1fb9dda1ff9396642c..38d8bd00bdcae207ad4d2fd6d1cac234fffb1a64 100644 (file)
@@ -1398,9 +1398,13 @@ yyerror (msgid)
           || last_token == CPP_INT
           || last_token == CPP_FLOAT)
     error ("%s before numeric constant", string);
-  else if (last_token == CPP_NAME
-          && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
-    error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
+  else if (last_token == CPP_NAME)
+    {
+      if (yylval.ttype && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
+        error ("%s before `%s'", string, IDENTIFIER_POINTER (yylval.ttype));
+      else
+        error ("%s before `%c'", string, yychar);
+    }
   else
-    error ("%s before '%s' token", string, NAME(last_token));
+    error ("%s before `%s' token", string, NAME (last_token));
 }
index f827bf055e24eef1d18732a3a65af3d9f2cc3a66..06f689b708377d3ceb0e1bb4d83501ec89009be6 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.other/parse2.C: New test.
+
 2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.pt/incomplete1.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/parse2.C b/gcc/testsuite/g++.old-deja/g++.other/parse2.C
new file mode 100644 (file)
index 0000000..6ecc6e5
--- /dev/null
@@ -0,0 +1,11 @@
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 24 Nov 2000 <nathan@codesourcery.com>
+
+// Bug 531: We ICEd trying to give a parse error.
+
+struct X
+{
+  bool operator (const X &) const;  // ERROR - parse error
+};