]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/cp/parse.y
cp-tre.h (finish_function): Change prototype.
[gcc.git] / gcc / cp / parse.y
index 000ab1df02c9f632242d98594edd8f24be02d017..65b90bb7ec91f54dfc180553be33d9061e141b0f 100644 (file)
@@ -1,5 +1,6 @@
 /* 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.
@@ -151,7 +152,10 @@ static void
 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);
 }
 
@@ -437,9 +441,9 @@ program:
 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:
@@ -728,9 +732,9 @@ eat_saved_input:
 
 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
                { }
        ;
@@ -772,7 +776,8 @@ constructor_declarator:
 
 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))
@@ -1054,7 +1059,7 @@ expr:
 
 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 ')'
@@ -1063,7 +1068,7 @@ paren_expr_or_null:
 
 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 ')'
@@ -1157,7 +1162,7 @@ unary_expr:
        /* 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); }
@@ -1242,7 +1247,7 @@ new_initializer:
        | '=' 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);
@@ -1272,7 +1277,7 @@ cast_expr:
                  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;
 
@@ -1467,7 +1472,7 @@ primary:
                      YYERROR;
                    }
                  if (pedantic)
-                   pedwarn ("ANSI C++ forbids braced-groups within expressions");  
+                   pedwarn ("ISO C++ forbids braced-groups within expressions");  
                  $<ttype>$ = begin_stmt_expr (); 
                }
          compstmt ')'
@@ -1594,7 +1599,7 @@ primary_no_id:
                  $<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); }
@@ -1704,7 +1709,7 @@ fcast_or_absdcl:
                                             NULL_TREE); }
        ;
 
-/* ANSI type-id (8.1) */
+/* ISO type-id (8.1) */
 type_id:
          typed_typespecs absdcl
                { $$.t = build_decl_list ($1.t, $2); 
@@ -2097,17 +2102,17 @@ fn.defpen:
 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); }
        ;
 
@@ -2199,10 +2204,10 @@ structsp:
                  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);
@@ -2653,7 +2658,7 @@ enumerator:
                { 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); 
@@ -2666,7 +2671,7 @@ new_type_id:
        | '(' 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;
@@ -2941,7 +2946,7 @@ typename_sub:
 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);
@@ -2968,7 +2973,7 @@ typename_sub1:
                }
        | 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);
@@ -3051,7 +3056,7 @@ global_scope:
                { 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); }
@@ -3072,7 +3077,7 @@ new_declarator:
        | 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); }
@@ -3090,7 +3095,7 @@ absdcl_intern:
                }
        ;
        
-/* ANSI abstract-declarator (8.1) */
+/* ISO abstract-declarator (8.1) */
 absdcl:
          '*' nonempty_cv_qualifiers absdcl_intern
                { $$ = make_pointer_declarator ($2.t, $3); }
@@ -3119,7 +3124,7 @@ absdcl:
        | direct_abstract_declarator  %prec EMPTY
        ;
 
-/* ANSI direct-abstract-declarator (8.1) */
+/* ISO direct-abstract-declarator (8.1) */
 direct_abstract_declarator:
          '(' absdcl_intern ')'
                { $$ = $2; }
@@ -3165,7 +3170,7 @@ maybe_label_decls:
          /* empty */
        | label_decls
                { if (pedantic)
-                   pedwarn ("ANSI C++ forbids label declarations"); }
+                   pedwarn ("ISO C++ forbids label declarations"); }
        ;
 
 label_decls:
@@ -3318,7 +3323,7 @@ simple_stmt:
        | GOTO '*' expr ';'
                 { 
                  if (pedantic)
-                   pedwarn ("ANSI C++ forbids computed gotos");
+                   pedwarn ("ISO C++ forbids computed gotos");
                  finish_goto_stmt ($3);
                }
        | GOTO identifier ';'
@@ -3418,7 +3423,7 @@ for.init.statement:
        | decl
        | '{' compstmtend
                { if (pedantic)
-                   pedwarn ("ANSI C++ forbids compound statements inside for initializations");
+                   pedwarn ("ISO C++ forbids compound statements inside for initializations");
                }
        ;
 
@@ -3426,10 +3431,8 @@ for.init.statement:
 
 maybe_cv_qualifier:
          /* empty */
-               { emit_line_note (input_filename, lineno);
-                 $$ = NULL_TREE; }
+               { $$ = NULL_TREE; }
        | CV_QUALIFIER
-               { emit_line_note (input_filename, lineno); }
        ;
 
 xexpr:
This page took 0.040167 seconds and 5 git commands to generate.