From 2f3608c33e4b7787fb460981463958df9caf387e Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 28 Nov 2000 10:23:03 +0000 Subject: [PATCH] spew.c (yyerror): Cope if yylval.ttype is NULL. 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 | 4 ++++ gcc/cp/spew.c | 12 ++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.old-deja/g++.other/parse2.C | 11 +++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/parse2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f18e81350c..9d486f6a59c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2000-11-28 Nathan Sidwell + + * spew.c (yyerror): Cope if yylval.ttype is NULL. + 2000-11-28 Nathan Sidwell * decl.c (grokdeclarator): Diagnose undefined template contexts. diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index 070cf2fef98..38d8bd00bdc 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -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)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f827bf055e2..06f689b7083 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-11-28 Nathan Sidwell + + * g++.old-deja/g++.other/parse2.C: New test. + 2000-11-28 Nathan Sidwell * 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 index 00000000000..6ecc6e55c81 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/parse2.C @@ -0,0 +1,11 @@ +// Build don't link: + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Nov 2000 + +// Bug 531: We ICEd trying to give a parse error. + +struct X +{ + bool operator (const X &) const; // ERROR - parse error +}; -- 2.30.2