aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-01-22 22:24:30 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-01-22 22:24:30 +0000
commite08607323876b31915e5c5d24115f1937d6ee61f (patch)
treea89731eddd2b91fbf4754ea78cbc882a4dbe84fb
parentb4ec7fc7f0de5ef2f80066f87b12a168a5625c5a (diff)
downloadgcc-e08607323876b31915e5c5d24115f1937d6ee61f.zip
gcc-e08607323876b31915e5c5d24115f1937d6ee61f.tar.gz
gcc-e08607323876b31915e5c5d24115f1937d6ee61f.tar.bz2
re PR c++/9298 ([new parser] ICE with function-pointer-type template args)
PR c++/9298 * parser.c (cp_parser_consume_semicolon_at_end_of_statement): New function. (cp_parser_expression_statement): Use it. (cp_parser_explicit_instantiation): Likewise. * pt.c (do_decl_instantiation): Improve error handling logic. PR c++/9298 * g++.dg/parse/template1.C: New test. From-SVN: r61618
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c34
-rw-r--r--gcc/cp/pt.c4
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/parse/template1.C11
5 files changed, 48 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 02262fd..f871077 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,14 @@
2003-01-22 Mark Mitchell <mark@codesourcery.com>
+ PR c++/9298
+ * parser.c (cp_parser_consume_semicolon_at_end_of_statement): New
+ function.
+ (cp_parser_expression_statement): Use it.
+ (cp_parser_explicit_instantiation): Likewise.
+ * pt.c (do_decl_instantiation): Improve error handling logic.
+
+2003-01-22 Mark Mitchell <mark@codesourcery.com>
+
PR c++/9384
* parser.c (cp_parser_using_declaration): Issue error messages
about name resolution failures here.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7f4eeaf..d64f0b4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1766,6 +1766,8 @@ static bool cp_parser_skip_to_closing_parenthesis_or_comma
(cp_parser *);
static void cp_parser_skip_to_end_of_statement
PARAMS ((cp_parser *));
+static void cp_parser_consume_semicolon_at_end_of_statement
+ (cp_parser *);
static void cp_parser_skip_to_end_of_block_or_statement
PARAMS ((cp_parser *));
static void cp_parser_skip_to_closing_brace
@@ -2107,6 +2109,25 @@ cp_parser_skip_to_end_of_statement (parser)
}
}
+/* This function is called at the end of a statement or declaration.
+ If the next token is a semicolon, it is consumed; otherwise, error
+ recovery is attempted. */
+
+static void
+cp_parser_consume_semicolon_at_end_of_statement (cp_parser *parser)
+{
+ /* Look for the trailing `;'. */
+ if (!cp_parser_require (parser, CPP_SEMICOLON, "`;'"))
+ {
+ /* If there is additional (erroneous) input, skip to the end of
+ the statement. */
+ cp_parser_skip_to_end_of_statement (parser);
+ /* If the next token is now a `;', consume it. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+ cp_lexer_consume_token (parser->lexer);
+ }
+}
+
/* Skip tokens until we have consumed an entire block, or until we
have consumed a non-nested `;'. */
@@ -5628,15 +5649,7 @@ cp_parser_expression_statement (parser)
statement = NULL_TREE;
}
/* Consume the final `;'. */
- if (!cp_parser_require (parser, CPP_SEMICOLON, "`;'"))
- {
- /* If there is additional (erroneous) input, skip to the end of
- the statement. */
- cp_parser_skip_to_end_of_statement (parser);
- /* If the next token is now a `;', consume it. */
- if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
- cp_lexer_consume_token (parser->lexer);
- }
+ cp_parser_consume_semicolon_at_end_of_statement (parser);
return statement;
}
@@ -8256,8 +8269,7 @@ cp_parser_explicit_instantiation (parser)
/* Trun access control back on. */
scope_chain->check_access = flag_access_control;
- /* Look for the trailing `;'. */
- cp_parser_require (parser, CPP_SEMICOLON, "`;'");
+ cp_parser_consume_semicolon_at_end_of_statement (parser);
}
/* Parse an explicit-specialization.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9f391eb..ca75cb0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10219,9 +10219,9 @@ do_decl_instantiation (tree decl, tree storage)
should handle VAR_DECLs as it currently handles
FUNCTION_DECLs. */
result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, 0);
- if (result && TREE_CODE (result) != VAR_DECL)
+ if (!result || TREE_CODE (result) != VAR_DECL)
{
- error ("no matching template for `%D' found", result);
+ error ("no matching template for `%D' found", decl);
return;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1bc7453..fed915c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2003-01-22 Mark Mitchell <mark@codesourcery.com>
+ PR c++/9298
+ * g++.dg/parse/template1.C: New test.
+
PR c++/9384
* g++.dg/parse/using1.C: New test.
diff --git a/gcc/testsuite/g++.dg/parse/template1.C b/gcc/testsuite/g++.dg/parse/template1.C
new file mode 100644
index 0000000..d7bbb07
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/template1.C
@@ -0,0 +1,11 @@
+struct CPU {
+ typedef int (*pfun)();
+
+ template <pfun step1>
+ static int dispatch();
+};
+
+template<int>
+static int foo();
+
+template int CPU::dispatch<&template foo<2> > (); // { dg-error "" }