OSDN Git Service

[gcc/ChangeLog]
[pf3gnuchains/gcc-fork.git] / gcc / c-semantics.c
index 3d747e6..17a301c 100644 (file)
@@ -1,7 +1,7 @@
 /* This file contains the definitions and documentation for the common
    tree codes used in the GNU C and C++ compilers (see c-common.def
    for the standard codes).
-   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Written by Benjamin Chelf (chelf@codesourcery.com).
 
 This file is part of GCC.
@@ -31,6 +31,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "varray.h"
 #include "c-common.h"
 #include "except.h"
+/* In order for the format checking to accept the C frontend
+   diagnostic framework extensions, you must define this token before
+   including toplev.h.  */
+#define GCC_DIAG_STYLE __gcc_cdiag__
 #include "toplev.h"
 #include "flags.h"
 #include "ggc.h"
@@ -98,10 +102,6 @@ add_stmt (tree t)
      statements are full-expressions.  We record that fact here.  */
   STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p ();
 
-  /* Keep track of the number of statements in this function.  */
-  if (current_function_decl)
-    ++DECL_NUM_STMTS (current_function_decl);
-
   return t;
 }
 
@@ -296,7 +296,7 @@ emit_local_var (tree decl)
 void
 genrtl_do_pushlevel (void)
 {
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   clear_last_expr ();
 }
 
@@ -313,7 +313,7 @@ genrtl_goto_stmt (tree destination)
   if (TREE_CODE (destination) == LABEL_DECL)
     TREE_USED (destination) = 1;
 
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
 
   if (TREE_CODE (destination) == LABEL_DECL)
     {
@@ -346,7 +346,7 @@ genrtl_expr_stmt_value (tree expr, int want_value, int maybe_last)
 {
   if (expr != NULL_TREE)
     {
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
 
       if (stmts_are_full_exprs_p ())
        expand_start_target_temps ();
@@ -365,7 +365,7 @@ void
 genrtl_decl_stmt (tree t)
 {
   tree decl;
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   decl = DECL_STMT_DECL (t);
   /* If this is a declaration for an automatic local
      variable, initialize it.  Note that we might also see a
@@ -401,7 +401,7 @@ genrtl_if_stmt (tree t)
   tree cond;
   genrtl_do_pushlevel ();
   cond = expand_cond (IF_COND (t));
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   expand_start_cond (cond, 0);
   if (THEN_CLAUSE (t))
     {
@@ -430,15 +430,14 @@ genrtl_while_stmt (tree t)
 {
   tree cond = WHILE_COND (t);
 
-  emit_nop ();
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   expand_start_loop (1);
   genrtl_do_pushlevel ();
 
   if (cond && !integer_nonzerop (cond))
     {
       cond = expand_cond (cond);
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
       expand_exit_loop_top_cond (0, cond);
       genrtl_do_pushlevel ();
     }
@@ -467,26 +466,24 @@ genrtl_do_stmt_1 (tree cond, tree body)
     }
   else if (integer_nonzerop (cond))
     {
-      emit_nop ();
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
       expand_start_loop (1);
 
       expand_stmt (body);
 
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
       expand_end_loop ();
     }
   else
     {
-      emit_nop ();
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
       expand_start_loop_continue_elsewhere (1);
 
       expand_stmt (body);
 
       expand_loop_continue_here ();
       cond = expand_cond (cond);
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
       expand_exit_loop_if_false (0, cond);
       expand_end_loop ();
     }
@@ -517,7 +514,7 @@ genrtl_return_stmt (tree stmt)
 
   expr = RETURN_STMT_EXPR (stmt);
 
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   if (!expr)
     expand_null_return ();
   else
@@ -542,8 +539,7 @@ genrtl_for_stmt (tree t)
   expand_stmt (FOR_INIT_STMT (t));
 
   /* Expand the initialization.  */
-  emit_nop ();
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   if (FOR_EXPR (t))
     expand_start_loop_continue_elsewhere (1);
   else
@@ -558,7 +554,7 @@ genrtl_for_stmt (tree t)
   if (cond && !integer_nonzerop (cond))
     {
       cond = expand_cond (cond);
-      emit_line_note (input_filename, input_line);
+      emit_line_note (input_location);
       expand_exit_loop_top_cond (0, cond);
       genrtl_do_pushlevel ();
     }
@@ -568,7 +564,7 @@ genrtl_for_stmt (tree t)
 
   /* Expand the increment expression.  */
   input_location = saved_loc;
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   if (FOR_EXPR (t))
     {
       expand_loop_continue_here ();
@@ -590,9 +586,9 @@ build_break_stmt (void)
 void
 genrtl_break_stmt (void)
 {
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   if ( ! expand_exit_something ())
-    error ("break statement not within loop or switch");
+    abort ();
 }
 
 /* Build a continue statement node and return it.  */
@@ -608,9 +604,9 @@ build_continue_stmt (void)
 void
 genrtl_continue_stmt (void)
 {
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   if (! expand_continue_loop (0))
-    error ("continue statement not within a loop");
+    abort ();
 }
 
 /* Generate the RTL for T, which is a SCOPE_STMT.  */
@@ -629,10 +625,8 @@ genrtl_scope_stmt (tree t)
     }
   else if (!SCOPE_NULLIFIED_P (t))
     {
-      rtx note = emit_note (NULL,
-                           (SCOPE_BEGIN_P (t)
-                            ? NOTE_INSN_BLOCK_BEG
-                            : NOTE_INSN_BLOCK_END));
+      rtx note = emit_note (SCOPE_BEGIN_P (t)
+                           ? NOTE_INSN_BLOCK_BEG : NOTE_INSN_BLOCK_END);
       NOTE_BLOCK (note) = block;
     }
 
@@ -646,7 +640,8 @@ genrtl_scope_stmt (tree t)
        {
          if (TREE_CODE (fn) == FUNCTION_DECL
              && DECL_CONTEXT (fn) == current_function_decl
-             && DECL_SAVED_INSNS (fn)
+             && DECL_STRUCT_FUNCTION (fn)
+             && DECL_STRUCT_FUNCTION (fn)->saved_for_inline
              && !TREE_ASM_WRITTEN (fn)
              && TREE_ADDRESSABLE (fn))
            {
@@ -670,9 +665,9 @@ genrtl_switch_stmt (tree t)
   if (cond == error_mark_node)
     /* The code is in error, but we don't want expand_end_case to
        crash.  */
-    cond = boolean_false_node;
+    cond = truthvalue_false_node;
 
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
   expand_stmt (expand_unreachable_stmt (SWITCH_BODY (t), warn_notreached));
   expand_end_case_type (cond, SWITCH_TYPE (t));
@@ -699,7 +694,7 @@ genrtl_case_label (tree case_label)
   if (cleanup)
     {
       static int explained = 0;
-      warning ("destructor needed for `%#D'", (TREE_PURPOSE (cleanup)));
+      warning ("destructor needed for `%D'", (TREE_PURPOSE (cleanup)));
       warning ("where case label appears here");
       if (!explained)
        {
@@ -744,13 +739,13 @@ genrtl_asm_stmt (tree cv_qualifier, tree string, tree output_operands,
       cv_qualifier = NULL_TREE;
     }
 
-  emit_line_note (input_filename, input_line);
+  emit_line_note (input_location);
   if (asm_input_p)
     expand_asm (string, cv_qualifier != NULL_TREE);
   else
     c_expand_asm_operands (string, output_operands, input_operands,
                           clobbers, cv_qualifier != NULL_TREE,
-                          input_filename, input_line);
+                          input_location);
 }
 
 /* Generate the RTL for a CLEANUP_STMT.  */
@@ -759,7 +754,8 @@ void
 genrtl_cleanup_stmt (tree t)
 {
   tree decl = CLEANUP_DECL (t);
-  if (!decl || (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node))
+  if (!decl || !DECL_P (decl)
+      || (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node))
     expand_decl_cleanup_eh (decl, CLEANUP_EXPR (t), CLEANUP_EH_ONLY (t));
 }
 
@@ -858,7 +854,7 @@ expand_stmt (tree t)
              && TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL
              && flag_guess_branch_prob)
            {
-             rtx note = emit_note (NULL, NOTE_INSN_PREDICTION);
+             rtx note = emit_note (NOTE_INSN_PREDICTION);
 
              NOTE_PREDICTION (note) = NOTE_PREDICT (PRED_GOTO, NOT_TAKEN);
            }
@@ -922,7 +918,8 @@ static tree
 find_reachable_label (tree exp)
 {
   location_t saved_loc = input_location;
-  tree ret = walk_tree (&exp, find_reachable_label_1, NULL, NULL);
+  tree ret = walk_tree_without_duplicates
+               (&exp, find_reachable_label_1, NULL);
   input_location = saved_loc;
   return ret;
 }