OSDN Git Service

* gcc-interface/trans.c (can_equal_min_or_max_val_p): Be prepared for
[pf3gnuchains/gcc-fork.git] / gcc / cp / expr.c
index 267b847..c521e7d 100644 (file)
@@ -1,7 +1,7 @@
 /* Convert language-specific tree expression to rtl instructions,
    for GNU compiler.
    Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   2000, 2001, 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2007, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -24,17 +24,12 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
-#include "rtl.h"
 #include "tree.h"
 #include "flags.h"
-#include "expr.h"
 #include "cp-tree.h"
-#include "toplev.h"
-#include "except.h"
 #include "tm_p.h"
 
-/* Hook used by output_constant to expand language-specific
-   constants.  */
+/* Expand C++-specific constants.  Currently, this means PTRMEM_CST.  */
 
 tree
 cplus_expand_constant (tree cst)
@@ -84,45 +79,72 @@ cplus_expand_constant (tree cst)
   return cst;
 }
 
-/* Hook used by expand_expr to expand language-specific tree codes.  */
-/* ??? The only thing that should be here are things needed to expand
-   constant initializers; everything else should be handled by the
-   gimplification routines.  Are EMPTY_CLASS_EXPR or BASELINK needed?  */
+/* Called whenever an expression is used
+   in a rvalue context.  */
 
-rtx
-cxx_expand_expr (tree exp, rtx target, enum machine_mode tmode, int modifier,
-                rtx *alt_rtl)
+tree
+mark_rvalue_use (tree expr)
 {
-  tree type = TREE_TYPE (exp);
-  enum machine_mode mode = TYPE_MODE (type);
-  enum tree_code code = TREE_CODE (exp);
+  mark_exp_read (expr);
+  return expr;
+}
 
-  /* No sense saving up arithmetic to be done
-     if it's all in the wrong mode to form part of an address.
-     And force_operand won't know whether to sign-extend or zero-extend.  */
+/* Called whenever an expression is used
+   in a lvalue context.  */
 
-  if (mode != Pmode && modifier == EXPAND_SUM)
-    modifier = EXPAND_NORMAL;
+tree
+mark_lvalue_use (tree expr)
+{
+  mark_exp_read (expr);
+  return expr;
+}
 
-  switch (code)
-    {
-    case PTRMEM_CST:
-      return expand_expr (cplus_expand_constant (exp),
-                         target, tmode, modifier);
+/* Called whenever an expression is used in a type use context.  */
 
-    case OFFSET_REF:
-      /* Offset refs should not make it through to here.  */
-      gcc_unreachable ();
+tree
+mark_type_use (tree expr)
+{
+  mark_exp_read (expr);
+  return expr;
+}
 
-    case EMPTY_CLASS_EXPR:
-      /* We don't need to generate any code for an empty class.  */
-      return const0_rtx;
+/* Mark EXP as read, not just set, for set but not used -Wunused
+   warning purposes.  */
 
-    case BASELINK:
-      return expand_expr (BASELINK_FUNCTIONS (exp), target, tmode,
-                         modifier);
+void
+mark_exp_read (tree exp)
+{
+  if (exp == NULL)
+    return;
 
+  switch (TREE_CODE (exp))
+    {
+    case VAR_DECL:
+    case PARM_DECL:
+      DECL_READ_P (exp) = 1;
+      break;
+    case ARRAY_REF:
+    case COMPONENT_REF:
+    case MODIFY_EXPR:
+    case REALPART_EXPR:
+    case IMAGPART_EXPR:
+    CASE_CONVERT:
+    case ADDR_EXPR:
+    case INDIRECT_REF:
+    case FLOAT_EXPR:
+      mark_exp_read (TREE_OPERAND (exp, 0));
+      break;
+    case COMPOUND_EXPR:
+      mark_exp_read (TREE_OPERAND (exp, 1));
+      break;
+    case COND_EXPR:
+      if (TREE_OPERAND (exp, 1))
+       mark_exp_read (TREE_OPERAND (exp, 1));
+      if (TREE_OPERAND (exp, 2))
+       mark_exp_read (TREE_OPERAND (exp, 2));
+      break;
     default:
-      return c_expand_expr (exp, target, tmode, modifier, alt_rtl);
+      break;
     }
 }
+