/* YACC parser for C++ syntax.
- Copyright (C) 1988, 89, 93-98, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
parse_end_decl (decl, init, asmspec)
tree decl, init, asmspec;
{
- decl_type_access_control (decl);
+ /* If decl is NULL_TREE, then this was a variable declaration using
+ () syntax for the initializer, so we handled it in grokdeclarator. */
+ if (decl)
+ decl_type_access_control (decl);
cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
}
extdefs:
{ $<ttype>$ = NULL_TREE; }
lang_extdef
- { $<ttype>$ = NULL_TREE; }
+ { $<ttype>$ = NULL_TREE; ggc_collect (); }
| extdefs lang_extdef
- { $<ttype>$ = NULL_TREE; }
+ { $<ttype>$ = NULL_TREE; ggc_collect (); }
;
extdefs_opt:
fndef:
fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
- { expand_body (finish_function (lineno, (int)$3)); }
+ { expand_body (finish_function ((int)$3)); }
| fn.def1 maybe_return_init function_try_block
- { expand_body (finish_function (lineno, (int)$3)); }
+ { expand_body (finish_function ((int)$3)); }
| fn.def1 maybe_return_init error
{ }
;
fn.def1:
typed_declspecs declarator
- { if (!begin_function_definition ($1.t, $2))
+ { check_for_new_type ("return type", $1);
+ if (!begin_function_definition ($1.t, $2))
YYERROR1; }
| declmods notype_declarator
{ if (!begin_function_definition ($1.t, $2))
paren_expr_or_null:
LEFT_RIGHT
- { error ("ANSI C++ forbids an empty condition for `%s'",
+ { error ("ISO C++ forbids an empty condition for `%s'",
cond_stmt_keyword);
$$ = integer_zero_node; }
| '(' expr ')'
paren_cond_or_null:
LEFT_RIGHT
- { error ("ANSI C++ forbids an empty condition for `%s'",
+ { error ("ISO C++ forbids an empty condition for `%s'",
cond_stmt_keyword);
$$ = integer_zero_node; }
| '(' condition ')'
/* Refer to the address of a label as a pointer. */
| ANDAND identifier
{ if (pedantic)
- pedwarn ("ANSI C++ forbids `&&'");
+ pedwarn ("ISO C++ forbids `&&'");
$$ = finish_label_address_expr ($2); }
| SIZEOF unary_expr %prec UNARY
{ $$ = expr_sizeof ($2); }
| '=' init
{
if (pedantic)
- pedwarn ("ANSI C++ forbids initialization of new expression with `='");
+ pedwarn ("ISO C++ forbids initialization of new expression with `='");
if (TREE_CODE ($2) != TREE_LIST
&& TREE_CODE ($2) != CONSTRUCTOR)
$$ = build_tree_list (NULL_TREE, $2);
tree init = build_nt (CONSTRUCTOR, NULL_TREE,
nreverse ($3));
if (pedantic)
- pedwarn ("ANSI C++ forbids constructor-expressions");
+ pedwarn ("ISO C++ forbids constructor-expressions");
/* Indicate that this was a GNU C constructor expression. */
TREE_HAS_CONSTRUCTOR (init) = 1;
YYERROR;
}
if (pedantic)
- pedwarn ("ANSI C++ forbids braced-groups within expressions");
+ pedwarn ("ISO C++ forbids braced-groups within expressions");
$<ttype>$ = begin_stmt_expr ();
}
compstmt ')'
$<ttype>$ = expand_start_stmt_expr (); }
compstmt ')'
{ if (pedantic)
- pedwarn ("ANSI C++ forbids braced-groups within expressions");
+ pedwarn ("ISO C++ forbids braced-groups within expressions");
$$ = expand_end_stmt_expr ($<ttype>2); }
| primary_no_id '(' nonnull_exprlist ')'
{ $$ = build_x_function_call ($$, $3, current_class_ref); }
NULL_TREE); }
;
-/* ANSI type-id (8.1) */
+/* ISO type-id (8.1) */
type_id:
typed_typespecs absdcl
{ $$.t = build_decl_list ($1.t, $2);
pending_inline:
fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
{
- expand_body (finish_function (lineno, (int)$3 | 2));
+ expand_body (finish_function ((int)$3 | 2));
process_next_inline ($1);
}
| fn.defpen maybe_return_init function_try_block
{
- expand_body (finish_function (lineno, (int)$3 | 2));
+ expand_body (finish_function ((int)$3 | 2));
process_next_inline ($1);
}
| fn.defpen maybe_return_init error
{
- finish_function (lineno, 2);
+ finish_function (2);
process_next_inline ($1); }
;
else
{
$$.t = $1.t;
- /* struct B: public A; is not accepted by the WP grammar. */
+ /* struct B: public A; is not accepted by the standard grammar. */
if (CLASS_TYPE_P ($$.t)
&& TYPE_BINFO_BASETYPES ($$.t)
- && !TYPE_SIZE ($$.t)
+ && !COMPLETE_TYPE_P ($$.t)
&& ! TYPE_BEING_DEFINED ($$.t))
cp_error ("base clause without member specification for `%#T'",
$$.t);
{ build_enumerator ($1, $3, current_enum_type); }
;
-/* ANSI new-type-id (5.3.4) */
+/* ISO new-type-id (5.3.4) */
new_type_id:
type_specifier_seq new_declarator
{ $$.t = build_decl_list ($1.t, $2);
| '(' type_id ')' '[' expr ']'
{
if (pedantic)
- pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
+ pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
$$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
$$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
$$.new_type_flag = $2.new_type_flag;
typename_sub0:
typename_sub1 identifier %prec EMPTY
{
- if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
+ if (TYPE_P ($1))
$$ = make_typename_type ($1, $2, /*complain=*/1);
else if (TREE_CODE ($2) == IDENTIFIER_NODE)
cp_error ("`%T' is not a class or namespace", $2);
}
| typename_sub1 typename_sub2
{
- if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
+ if (TYPE_P ($1))
$$ = make_typename_type ($1, $2, /*complain=*/1);
else if (TREE_CODE ($2) == IDENTIFIER_NODE)
cp_error ("`%T' is not a class or namespace", $2);
{ got_scope = void_type_node; }
;
-/* ANSI new-declarator (5.3.4) */
+/* ISO new-declarator (5.3.4) */
new_declarator:
'*' cv_qualifiers new_declarator
{ $$ = make_pointer_declarator ($2, $3); }
| direct_new_declarator %prec EMPTY
;
-/* ANSI direct-new-declarator (5.3.4) */
+/* ISO direct-new-declarator (5.3.4) */
direct_new_declarator:
'[' expr ']'
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
}
;
-/* ANSI abstract-declarator (8.1) */
+/* ISO abstract-declarator (8.1) */
absdcl:
'*' nonempty_cv_qualifiers absdcl_intern
{ $$ = make_pointer_declarator ($2.t, $3); }
| direct_abstract_declarator %prec EMPTY
;
-/* ANSI direct-abstract-declarator (8.1) */
+/* ISO direct-abstract-declarator (8.1) */
direct_abstract_declarator:
'(' absdcl_intern ')'
{ $$ = $2; }
/* empty */
| label_decls
{ if (pedantic)
- pedwarn ("ANSI C++ forbids label declarations"); }
+ pedwarn ("ISO C++ forbids label declarations"); }
;
label_decls:
| GOTO '*' expr ';'
{
if (pedantic)
- pedwarn ("ANSI C++ forbids computed gotos");
+ pedwarn ("ISO C++ forbids computed gotos");
finish_goto_stmt ($3);
}
| GOTO identifier ';'
| decl
| '{' compstmtend
{ if (pedantic)
- pedwarn ("ANSI C++ forbids compound statements inside for initializations");
+ pedwarn ("ISO C++ forbids compound statements inside for initializations");
}
;
maybe_cv_qualifier:
/* empty */
- { emit_line_note (input_filename, lineno);
- $$ = NULL_TREE; }
+ { $$ = NULL_TREE; }
| CV_QUALIFIER
- { emit_line_note (input_filename, lineno); }
;
xexpr: