Revert
authorOllie Wild <aaw@google.com>
Sat, 29 Sep 2007 03:47:05 +0000 (03:47 +0000)
committerOllie Wild <aaw@gcc.gnu.org>
Sat, 29 Sep 2007 03:47:05 +0000 (03:47 +0000)
2007-09-27  Ollie Wild  <aaw@google.com>

gcc/
* varasm.c (compare_constant): Removed call to
lang_hooks.expand_constant.
(copy_constants): Removed call to lang_hooks.expand_constant.
(compute_reloc_for_constant): Removed call to
lang_hooks.expand_constant.
(output_addressed_constants): Removed call to
lang_hooks.expand_constant.
(constructor_static_from_elts_p): Removed call to
lang_hooks.expand_constant.
(output_constant): Removed calls to lang_hooks.expand_constant.
* langhooks.h (struct lang_hooks): Removed field expand_constant.
* langhooks-def.h (lhd_return_tree): Removed.
(LANG_HOOKS_EXPAND_CONSTANT): Removed.
(LANG_HOOKS_INITIALIZER): Removed LANG_HOOKS_EXPAND_CONSTANT.
* langhooks.c (lhd_return_tree): Removed.

gcc/cp/
* typeck2.c (digest_init): Call cplus_expand_constant after
convert_for_initialization.
* cp-objcp-common.h (LANG_HOOKS_EXPAND_CONSTANT): Removed.
* expr.c (cplus_expand_constant): Updated function description.

From-SVN: r128881

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.h
gcc/cp/expr.c
gcc/cp/typeck2.c
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/varasm.c

index 70ddb711051ef4e0ffb0052c732bd83211a857d3..ce12f805c0c4e51632eaf70c234ef564aadfb706 100644 (file)
@@ -1,3 +1,24 @@
+2007-09-28  Ollie Wild  <aaw@google.com>
+
+       Revert
+       2007-09-27  Ollie Wild  <aaw@google.com>
+
+       * varasm.c (compare_constant): Removed call to
+       lang_hooks.expand_constant.
+       (copy_constants): Removed call to lang_hooks.expand_constant.
+       (compute_reloc_for_constant): Removed call to
+       lang_hooks.expand_constant.
+       (output_addressed_constants): Removed call to
+       lang_hooks.expand_constant.
+       (constructor_static_from_elts_p): Removed call to
+       lang_hooks.expand_constant.
+       (output_constant): Removed calls to lang_hooks.expand_constant.
+       * langhooks.h (struct lang_hooks): Removed field expand_constant.
+       * langhooks-def.h (lhd_return_tree): Removed.
+       (LANG_HOOKS_EXPAND_CONSTANT): Removed.
+       (LANG_HOOKS_INITIALIZER): Removed LANG_HOOKS_EXPAND_CONSTANT.
+       * langhooks.c (lhd_return_tree): Removed.
+
 2007-09-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR target/33347
index 44a4d901aa79a0b6e297585e431ac73618674f39..5827a57964e3b1769c37783fac4fe9d2271d5b8e 100644 (file)
@@ -1,3 +1,13 @@
+2007-09-28  Ollie Wild  <aaw@google.com>
+
+       Revert
+       2007-09-27  Ollie Wild  <aaw@google.com>
+
+       * typeck2.c (digest_init): Call cplus_expand_constant after
+       convert_for_initialization.
+       * cp-objcp-common.h (LANG_HOOKS_EXPAND_CONSTANT): Removed.
+       * expr.c (cplus_expand_constant): Updated function description.
+
 2007-09-28  Jason Merrill  <jason@redhat.com>
 
        PR c++/10179
index 60d78181ad1f370d0afc345c4e2a774bd22a09eb..7f8138c6e60431805c96402336ecf631de5145c8 100644 (file)
@@ -50,6 +50,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET cxx_get_alias_set
+#undef LANG_HOOKS_EXPAND_CONSTANT
+#define LANG_HOOKS_EXPAND_CONSTANT cplus_expand_constant
 #undef LANG_HOOKS_EXPAND_EXPR
 #define LANG_HOOKS_EXPAND_EXPR cxx_expand_expr
 #undef LANG_HOOKS_EXPAND_DECL
index b5186462e5ec3efe0da76e1350dc423d1aafbdae..267b847770ea220aa7381178961d52b1989ddd8b 100644 (file)
@@ -33,7 +33,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "except.h"
 #include "tm_p.h"
 
-/* Expand C++-specific constants.  Currently, this means PTRMEM_CST.  */
+/* Hook used by output_constant to expand language-specific
+   constants.  */
 
 tree
 cplus_expand_constant (tree cst)
index adbe9de75413e3b5411d481cfe5cdc514b11aa35..53e22023f27e9b3c8359e151820d14ec1642ee48 100644 (file)
@@ -703,23 +703,8 @@ digest_init (tree type, tree init)
   /* Handle scalar types (including conversions) and references.  */
   if (TREE_CODE (type) != COMPLEX_TYPE
       && (SCALAR_TYPE_P (type) || code == REFERENCE_TYPE))
-    {
-      tree *exp;
-
-      init = convert_for_initialization (0, type, init, LOOKUP_NORMAL,
-                                        "initialization", NULL_TREE, 0);
-      exp = &init;
-
-      /* Skip any conversions since we'll be outputting the underlying
-        constant.  */
-      while (TREE_CODE (*exp) == NOP_EXPR || TREE_CODE (*exp) == CONVERT_EXPR
-            || TREE_CODE (*exp) == NON_LVALUE_EXPR)
-       exp = &TREE_OPERAND (*exp, 0);
-
-      *exp = cplus_expand_constant (*exp);
-
-      return init;
-    }
+    return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
+                                      "initialization", NULL_TREE, 0);
 
   /* Come here only for aggregates: records, arrays, unions, complex numbers
      and vectors.  */
index e0bfb67a305e5991157461cf956404c55f627f24..6eca2f0497f03810ed74ee874e26412f9fcacd0f 100644 (file)
@@ -41,6 +41,7 @@ extern void lhd_do_nothing_i (int);
 extern void lhd_do_nothing_f (struct function *);
 extern bool lhd_post_options (const char **);
 extern alias_set_type lhd_get_alias_set (tree);
+extern tree lhd_return_tree (tree);
 extern tree lhd_return_null_tree_v (void);
 extern tree lhd_return_null_tree (tree);
 extern tree lhd_return_null_const_tree (const_tree);
@@ -92,6 +93,7 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 #define LANG_HOOKS_MISSING_ARGUMENT    hook_bool_constcharptr_size_t_false
 #define LANG_HOOKS_POST_OPTIONS                lhd_post_options
 #define LANG_HOOKS_GET_ALIAS_SET       lhd_get_alias_set
+#define LANG_HOOKS_EXPAND_CONSTANT     lhd_return_tree
 #define LANG_HOOKS_EXPAND_EXPR         lhd_expand_expr
 #define LANG_HOOKS_EXPAND_DECL         lhd_expand_decl
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL lhd_do_nothing_t
@@ -248,6 +250,7 @@ extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_PARSE_FILE, \
   LANG_HOOKS_CLEAR_BINDING_STACK, \
   LANG_HOOKS_GET_ALIAS_SET, \
+  LANG_HOOKS_EXPAND_CONSTANT, \
   LANG_HOOKS_EXPAND_EXPR, \
   LANG_HOOKS_EXPAND_DECL, \
   LANG_HOOKS_FINISH_INCOMPLETE_DECL, \
index 6a9a74dc70cb30591562809f4bf90dcc6e305d0a..4682514508d121e6cf2bb855453305c7229ab2a3 100644 (file)
@@ -76,6 +76,14 @@ lhd_do_nothing_f (struct function * ARG_UNUSED (f))
 {
 }
 
+/* Do nothing (return the tree node passed).  */
+
+tree
+lhd_return_tree (tree t)
+{
+  return t;
+}
+
 /* Do nothing (return NULL_TREE).  */
 
 tree
index 0efb13956d333d4248a0fbd50405f62c84c8c6d2..8a442753b1f9c9ba4f9dabb76d9b5319106ad0e7 100644 (file)
@@ -287,6 +287,11 @@ struct lang_hooks
      Returns -1 if the language does nothing special for it.  */
   alias_set_type (*get_alias_set) (tree);
 
+  /* Called with an expression that is to be processed as a constant.
+     Returns either the same expression or a language-independent
+     constant equivalent to its input.  */
+  tree (*expand_constant) (tree);
+
   /* Called by expand_expr for language-specific tree codes.
      Fourth argument is actually an enum expand_modifier.  */
   rtx (*expand_expr) (tree, rtx, enum machine_mode, int, rtx *);
index e85824577f6361dd7be7ca4e62cda499b0c80c63..9dece23fefeb6ab3aea422ab1d6897d50ba6eef3 100644 (file)
@@ -2985,7 +2985,15 @@ compare_constant (const tree t1, const tree t2)
       return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
 
     default:
-      return 0;
+      {
+       tree nt1, nt2;
+       nt1 = lang_hooks.expand_constant (t1);
+       nt2 = lang_hooks.expand_constant (t2);
+       if (nt1 != t1 || nt2 != t2)
+         return compare_constant (nt1, nt2);
+       else
+         return 0;
+      }
     }
 
   gcc_unreachable ();
@@ -3053,7 +3061,12 @@ copy_constant (tree exp)
       }
 
     default:
-      gcc_unreachable ();
+      {
+       tree t = lang_hooks.expand_constant (exp);
+
+       gcc_assert (t != exp);
+       return copy_constant (t);
+      }
     }
 }
 \f
@@ -3897,6 +3910,10 @@ compute_reloc_for_constant (tree exp)
   int reloc = 0, reloc2;
   tree tem;
 
+  /* Give the front-end a chance to convert VALUE to something that
+     looks more like a constant to the back-end.  */
+  exp = lang_hooks.expand_constant (exp);
+
   switch (TREE_CODE (exp))
     {
     case ADDR_EXPR:
@@ -3961,6 +3978,10 @@ output_addressed_constants (tree exp)
 {
   tree tem;
 
+  /* Give the front-end a chance to convert VALUE to something that
+     looks more like a constant to the back-end.  */
+  exp = lang_hooks.expand_constant (exp);
+
   switch (TREE_CODE (exp))
     {
     case ADDR_EXPR:
@@ -4034,6 +4055,10 @@ constructor_static_from_elts_p (const_tree ctor)
 tree
 initializer_constant_valid_p (tree value, tree endtype)
 {
+  /* Give the front-end a chance to convert VALUE to something that
+     looks more like a constant to the back-end.  */
+  value = lang_hooks.expand_constant (value);
+
   switch (TREE_CODE (value))
     {
     case CONSTRUCTOR:
@@ -4292,6 +4317,11 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align)
   enum tree_code code;
   unsigned HOST_WIDE_INT thissize;
 
+  /* Some front-ends use constants other than the standard language-independent
+     varieties, but which may still be output directly.  Give the front-end a
+     chance to convert EXP to a language-independent representation.  */
+  exp = lang_hooks.expand_constant (exp);
+
   if (size == 0 || flag_syntax_only)
     return;
 
@@ -4348,6 +4378,9 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align)
   code = TREE_CODE (TREE_TYPE (exp));
   thissize = int_size_in_bytes (TREE_TYPE (exp));
 
+  /* Give the front end another chance to expand constants.  */
+  exp = lang_hooks.expand_constant (exp);
+
   /* Allow a constructor with no elements for any data type.
      This means to fill the space with zeros.  */
   if (TREE_CODE (exp) == CONSTRUCTOR