aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@wasabisystems.com>2004-02-13 16:11:39 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2004-02-13 16:11:39 +0000
commitd6e57462de47c49af631496fb269fe1a9fb86d0f (patch)
tree8e212bcdf838506c4ede9c33f222784c6bf36a76 /gcc
parentfaeb9bb6eed0f0043a8a6bccd42a0faa28767b18 (diff)
downloadgcc-d6e57462de47c49af631496fb269fe1a9fb86d0f.zip
gcc-d6e57462de47c49af631496fb269fe1a9fb86d0f.tar.gz
gcc-d6e57462de47c49af631496fb269fe1a9fb86d0f.tar.bz2
re PR c++/9851 (confusing error message when using '.', not '->')
PR c++/9851 * parser.c (cp_parser_pseudo_destructor_name): Check for errors on the type name and look ahead for ::~, and bail out early with a better error message if the parse is going to fail. From-SVN: r77758
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c17
2 files changed, 23 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 809dcfe..4238dea 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-13 Ian Lance Taylor <ian@wasabisystems.com>
+
+ PR c++/9851
+ * parser.c (cp_parser_pseudo_destructor_name): Check for errors on
+ the type name and look ahead for ::~, and bail out early with a
+ better error message if the parse is going to fail.
+
2004-02-12 Mark Mitchell <mark@codesourcery.com>
* call.c (conversion_kind): New type.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b17d669..7918602 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4187,7 +4187,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
If either of the first two productions is used, sets *SCOPE to the
TYPE specified before the final `::'. Otherwise, *SCOPE is set to
NULL_TREE. *TYPE is set to the TYPE_DECL for the final type-name,
- or ERROR_MARK_NODE if no type-name is present. */
+ or ERROR_MARK_NODE if the parse fails. */
static void
cp_parser_pseudo_destructor_name (cp_parser* parser,
@@ -4227,6 +4227,21 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
{
/* Look for the type-name. */
*scope = TREE_TYPE (cp_parser_type_name (parser));
+
+ /* If we didn't get an aggregate type, or we don't have ::~,
+ then something has gone wrong. Since the only caller of this
+ function is looking for something after `.' or `->' after a
+ scalar type, most likely the program is trying to get a
+ member of a non-aggregate type. */
+ if (*scope == error_mark_node
+ || cp_lexer_next_token_is_not (parser->lexer, CPP_SCOPE)
+ || cp_lexer_peek_nth_token (parser->lexer, 2)->type != CPP_COMPL)
+ {
+ cp_parser_error (parser, "request for member of non-aggregate type");
+ *type = error_mark_node;
+ return;
+ }
+
/* Look for the `::' token. */
cp_parser_require (parser, CPP_SCOPE, "`::'");
}