aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2006-10-13 08:38:43 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-10-13 08:38:43 +0000
commit0b45aeddd8b0a144ac78998ff0f65490dc2ad1fc (patch)
treed0987ed158a6772cd231320670bc4c23d1e423b3 /gcc/cp/parser.c
parent16dbbd9957c126f9d3b8014ac8f9d414163c03c7 (diff)
downloadgcc-0b45aeddd8b0a144ac78998ff0f65490dc2ad1fc.zip
gcc-0b45aeddd8b0a144ac78998ff0f65490dc2ad1fc.tar.gz
gcc-0b45aeddd8b0a144ac78998ff0f65490dc2ad1fc.tar.bz2
re PR c++/28506 (ICE with initializers for functions)
PR c++/28506 * parser.c (function_declarator_p): New function. (cp_parser_init_declarator): Use it. (cp_parser_member_declaration): Likewise. PR c++/28506 * g++.dg/parse/pure1.C: New test. From-SVN: r117687
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 41fe858..cb357cf 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -965,6 +965,24 @@ make_parameter_declarator (cp_decl_specifier_seq *decl_specifiers,
return parameter;
}
+/* Returns true iff DECLARATOR is a declaration for a function. */
+
+static bool
+function_declarator_p (const cp_declarator *declarator)
+{
+ while (declarator)
+ {
+ if (declarator->kind == cdk_function
+ && declarator->declarator->kind == cdk_id)
+ return true;
+ if (declarator->kind == cdk_id
+ || declarator->kind == cdk_error)
+ return false;
+ declarator = declarator->declarator;
+ }
+ return false;
+}
+
/* The parser. */
/* Overview
@@ -11157,8 +11175,7 @@ cp_parser_init_declarator (cp_parser* parser,
is_non_constant_init = true;
if (is_initialized)
{
- if (declarator->kind == cdk_function
- && declarator->declarator->kind == cdk_id
+ if (function_declarator_p (declarator)
&& initialization_kind == CPP_EQ)
initializer = cp_parser_pure_specifier (parser);
else
@@ -13825,8 +13842,7 @@ cp_parser_member_declaration (cp_parser* parser)
for a pure-specifier; otherwise, we look for a
constant-initializer. When we call `grokfield', it will
perform more stringent semantics checks. */
- if (declarator->kind == cdk_function
- && declarator->declarator->kind == cdk_id)
+ if (function_declarator_p (declarator))
initializer = cp_parser_pure_specifier (parser);
else
/* Parse the initializer. */