aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-10-10 05:02:54 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-10-10 05:02:54 +0000
commit17a27b4f0c4ce1f151263c1919dba4fd2231eedc (patch)
treec79be0800daaa4e6c1647924399c5e22fb0b7902 /gcc/cp/parser.c
parentc69c9b36a97fddbde2112a5f8d50a4aabe13a19a (diff)
downloadgcc-17a27b4f0c4ce1f151263c1919dba4fd2231eedc.zip
gcc-17a27b4f0c4ce1f151263c1919dba4fd2231eedc.tar.gz
gcc-17a27b4f0c4ce1f151263c1919dba4fd2231eedc.tar.bz2
re PR c++/17867 ("void" instead of class name in error message)
PR c++/17867 * error.c (dump_expr): Correct handling of AGGR_INIT_EXPRs using a constructor. PR c++/17670 * init.c (build_new): Correct comments. * parser.c (cp_parser_new_expression): Use NULL_TREE for nelts in the non-array case. PR c++/17821 * parser.c (cp_parser_postfix_dot_deref_expression): If the pseduo-destructor-name production does not work, fall back to the ordinary production. PR c++/17826 * tree.c (cp_tree_equal): Handle a BASELINK. PR c++/17687 * g++.dg/parse/error19.C: New test. PR c++/17670 * g++.dg/init/new11.C: New test. PR c++/17821 * g++.dg/parse/error20.C: New test. PR c++/17826 * g++.dg/template/crash24.C: New test. From-SVN: r88836
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 9bd3f18..7fb9d96 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4274,6 +4274,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
tree name;
bool dependent_p;
bool template_p;
+ bool pseudo_destructor_p;
tree scope = NULL_TREE;
/* If this is a `->' operator, dereference the pointer. */
@@ -4315,11 +4316,34 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
postfix_expression = error_mark_node;
}
- /* If the SCOPE is not a scalar type, we are looking at an
- ordinary class member access expression, rather than a
- pseudo-destructor-name. */
- if (!scope || !SCALAR_TYPE_P (scope))
+ /* Assume this expression is not a pseudo-destructor access. */
+ pseudo_destructor_p = false;
+
+ /* If the SCOPE is a scalar type, then, if this is a valid program,
+ we must be looking at a pseudo-destructor-name. */
+ if (scope && SCALAR_TYPE_P (scope))
{
+ tree s;
+ tree type;
+
+ cp_parser_parse_tentatively (parser);
+ /* Parse the pseudo-destructor-name. */
+ s = NULL_TREE;
+ cp_parser_pseudo_destructor_name (parser, &s, &type);
+ if (cp_parser_parse_definitely (parser))
+ {
+ pseudo_destructor_p = true;
+ postfix_expression
+ = finish_pseudo_destructor_expr (postfix_expression,
+ s, TREE_TYPE (type));
+ }
+ }
+
+ if (!pseudo_destructor_p)
+ {
+ /* If the SCOPE is not a scalar type, we are looking at an
+ ordinary class member access expression, rather than a
+ pseudo-destructor-name. */
template_p = cp_parser_optional_template_keyword (parser);
/* Parse the id-expression. */
name = cp_parser_id_expression (parser, template_p,
@@ -4354,19 +4378,6 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
postfix_expression
= finish_class_member_access_expr (postfix_expression, name);
}
- /* Otherwise, try the pseudo-destructor-name production. */
- else
- {
- tree s = NULL_TREE;
- tree type;
-
- /* Parse the pseudo-destructor-name. */
- cp_parser_pseudo_destructor_name (parser, &s, &type);
- /* Form the call. */
- postfix_expression
- = finish_pseudo_destructor_expr (postfix_expression,
- s, TREE_TYPE (type));
- }
/* We no longer need to look up names in the scope of the object on
the left-hand side of the `.' or `->' operator. */
@@ -4862,7 +4873,7 @@ cp_parser_new_expression (cp_parser* parser)
inform ("try removing the parentheses around the type-id");
cp_parser_direct_new_declarator (parser);
}
- nelts = integer_one_node;
+ nelts = NULL_TREE;
}
/* Otherwise, there must be a new-type-id. */
else