2003-12-15 Mark Mitchell <mark@codesourcery.com>
+ PR c++/10926
+ * decl2.c (grokfield): Robustify.
+
+ PR c++/11116
+ * parser.c (cp_parser_throw_expression): Determine whether or not
+ an assignment-expression is present by doing one-token lookahead.
+
PR c++/13269
* parser.c (cp_parser_function_definition_after_declarator): Stop
scanning tokens when reaching EOF.
init = NULL_TREE;
value = grokdeclarator (declarator, declspecs, FIELD, init != 0, &attrlist);
- if (! value || value == error_mark_node)
+ if (! value || error_operand_p (value))
/* friend or constructor went bad. */
- return value;
- if (TREE_TYPE (value) == error_mark_node)
return error_mark_node;
if (TREE_CODE (value) == TYPE_DECL && init)
if (processing_template_decl
&& (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == FUNCTION_DECL))
- value = push_template_decl (value);
+ {
+ value = push_template_decl (value);
+ if (error_operand_p (value))
+ return error_mark_node;
+ }
if (attrlist)
cplus_decl_attributes (&value, attrlist, 0);
cp_parser_throw_expression (cp_parser* parser)
{
tree expression;
+ cp_token* token;
cp_parser_require_keyword (parser, RID_THROW, "`throw'");
- /* We can't be sure if there is an assignment-expression or not. */
- cp_parser_parse_tentatively (parser);
- /* Try it. */
- expression = cp_parser_assignment_expression (parser);
- /* If it didn't work, this is just a rethrow. */
- if (!cp_parser_parse_definitely (parser))
+ token = cp_lexer_peek_token (parser->lexer);
+ /* Figure out whether or not there is an assignment-expression
+ following the "throw" keyword. */
+ if (token->type == CPP_COMMA
+ || token->type == CPP_SEMICOLON
+ || token->type == CPP_CLOSE_PAREN
+ || token->type == CPP_CLOSE_SQUARE
+ || token->type == CPP_CLOSE_BRACE
+ || token->type == CPP_COLON)
expression = NULL_TREE;
+ else
+ expression = cp_parser_assignment_expression (parser);
return build_throw (expression);
}
+2003-12-15 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/10926
+ * g++.dg/template/error9.C: New test.
+
+ PR c++/11116
+ * g++.dg/template/error8.C: New test.
+
2003-12-15 Roger Sayle <roger@eyesopen.com>
PR middle-end/13400
--- /dev/null
+// PR c++/11116
+
+template <typename T> struct S {};
+
+void f() {
+ throw S (); // { dg-error "template" }
+}
--- /dev/null
+// PR c++/10926
+
+struct Foo
+{
+ template <int i>
+ ~Foo(); // { dg-error "" }
+};