]> gcc.gnu.org Git - gcc.git/commitdiff
langhooks.h (lang_hooks_for_types): Change global_bindings_p's return type to bool...
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 7 May 2011 19:58:29 +0000 (19:58 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 7 May 2011 19:58:29 +0000 (19:58 +0000)
2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>

* langhooks.h (lang_hooks_for_types): Change global_bindings_p's return
type to bool and adjust comment.
* fold-const.c (fold_range_test): Adjust call to global_bindings_p.
(fold_mathfn_compare): Remove calls to global_bindings_p.
(fold_inf_compare): Likewise.
* stor-layout.c (variable_size): Adjust call to global_bindings_p.
* c-tree.h (global_bindings_p): Adjust prototype.
* c-decl.c (global_bindings_p): Return bool and simplify.
ada/
* gcc-interface/gigi.h (global_bindings_p): Adjust prototype.
* gcc-interface/utils.c (global_bindings_p): Return bool and simplify.
cp/
* name-lookup.h (global_bindings_p): Adjust prototype.
* name-lookup.c (global_bindings_p): Return bool.
fortran/
* f95-lang.c (global_bindings_p): Return bool and simplify.
go/
* go-lang.c (global_bindings_p): Return bool and simplify.
java/
* java-tree.h (global_bindings_p): Adjust prototype.
* decl.c (global_bindings_p): Return bool.
lto/
* lto-lang.c (global_bindings_p): Return bool.

From-SVN: r173535

21 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/utils.c
gcc/c-decl.c
gcc/c-tree.h
gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/fold-const.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/go/ChangeLog
gcc/go/go-lang.c
gcc/java/ChangeLog
gcc/java/decl.c
gcc/java/java-tree.h
gcc/langhooks.h
gcc/lto/ChangeLog
gcc/lto/lto-lang.c
gcc/stor-layout.c

index a3f6a11146388635e40fde8cfab08124ebd2b90e..61b6bcd0048dd1c4f0e74cd543234d8fffbb9db7 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * langhooks.h (lang_hooks_for_types): Change global_bindings_p's return
+       type to bool and adjust comment.
+       * fold-const.c (fold_range_test): Adjust call to global_bindings_p.
+       (fold_mathfn_compare): Remove calls to global_bindings_p.
+       (fold_inf_compare): Likewise.
+       * stor-layout.c (variable_size): Adjust call to global_bindings_p.
+       * c-tree.h (global_bindings_p): Adjust prototype.
+       * c-decl.c (global_bindings_p): Return bool and simplify.
+
 2011-05-07  Zdenek Dvorak  <ook@ucw.cz>
 
        PR tree-optimization/48837
index 18c56d0af994ad8896cc9906bd681b48ebffb0e1..b13e734c8096937de681f6901980b9a1b38812f0 100644 (file)
@@ -1,7 +1,11 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/gigi.h (global_bindings_p): Adjust prototype.
+       * gcc-interface/utils.c (global_bindings_p): Return bool and simplify.
+
 2011-05-05  Nathan Froyd  <froydnj@codesourcery.com>
 
-       * gcc-interface/trans.c (Case_Statement_to_gnu): Call
-       build_case_label.
+       * gcc-interface/trans.c (Case_Statement_to_gnu): Call build_case_label.
 
 2011-05-05  Nathan Froyd  <froydnj@codesourcery.com>
 
index 8c69e751a3314e432dd2fc88a34c41d186bb3131..c1f1217a59441d4c2d71715be6cb19e9b94cfa27 100644 (file)
@@ -422,8 +422,8 @@ extern GTY(()) tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1];
 /* Routines expected by the gcc back-end. They must have exactly the same
    prototype and names as below.  */
 
-/* Returns nonzero if we are currently in the global binding level.  */
-extern int global_bindings_p (void);
+/* Return true if we are in the global binding level.  */
+extern bool global_bindings_p (void);
 
 /* Enter and exit a new binding level.  */
 extern void gnat_pushlevel (void);
index 1703a8b89a8b877563c63340d104b31fbd2884d8..cfa58b939978f4bc5e8407046815c67ccb8dc57a 100644 (file)
@@ -365,12 +365,12 @@ build_dummy_unc_pointer_types (Entity_Id gnat_desig_type, tree gnu_desig_type)
   TYPE_OBJECT_RECORD_TYPE (gnu_desig_type) = gnu_object_type;
 }
 \f
-/* Return nonzero if we are currently in the global binding level.  */
+/* Return true if we are in the global binding level.  */
 
-int
+bool
 global_bindings_p (void)
 {
-  return ((force_global || !current_function_decl) ? -1 : 0);
+  return force_global || current_function_decl == NULL_TREE;
 }
 
 /* Enter a new binding level.  */
index cea26052a9e060421d3b36345c2f196c1feae1fb..6e359a9f41ec233e32c5ad9f5c8be6033e366363 100644 (file)
@@ -845,14 +845,12 @@ objc_mark_locals_volatile (void *enclosing_blk)
     }
 }
 
-/* Nonzero if we are currently in file scope.  */
+/* Return true if we are in the global binding level.  */
 
-int
+bool
 global_bindings_p (void)
 {
-  return (current_scope == file_scope && !c_override_global_bindings_to_false
-         ? -1
-         : 0);
+  return current_scope == file_scope && !c_override_global_bindings_to_false;
 }
 
 void
index 97a4e55cd12af4d7800a81c7028df8f6aa3219a2..e2b42bf83177b4bc19d586795aa2454798a3abb9 100644 (file)
@@ -413,7 +413,7 @@ extern struct obstack parser_obstack;
 extern tree c_break_label;
 extern tree c_cont_label;
 
-extern int global_bindings_p (void);
+extern bool global_bindings_p (void);
 extern void push_scope (void);
 extern tree pop_scope (void);
 extern void c_bindings_start_stmt_expr (struct c_spot_bindings *);
index 70c7f3e31a34d96962bcefb0367f878d2537c06a..f56be1d5744e3005592a8b97e7f678901a8837c0 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * name-lookup.h (global_bindings_p): Adjust prototype.
+       * name-lookup.c (global_bindings_p): Return bool.
+
 2011-05-06  Jason Merrill  <jason@redhat.com>
 
        * decl.c (stabilize_save_expr_r): Set *walk_subtrees as
index e1cf1cf0f1db6ba9920aec99559d734e1a0ffbd5..3d1c64d85cf73e2e1e652fd7c763e846efbd53a5 100644 (file)
@@ -1576,9 +1576,9 @@ maybe_push_cleanup_level (tree type)
     }
 }
 
-/* Nonzero if we are currently in the global binding level.  */
+/* Return true if we are in the global binding level.  */
 
-int
+bool
 global_bindings_p (void)
 {
   return global_scope_p (current_binding_level);
index bfcac69c110d10d54dd5fbac01fe6165daee8a5e..4bf253f3680fbac3385f534554c6572ce78c9024 100644 (file)
@@ -290,7 +290,7 @@ extern GTY(()) tree global_type_node;
 
 extern cxx_scope *leave_scope (void);
 extern bool kept_level_p (void);
-extern int global_bindings_p (void);
+extern bool global_bindings_p (void);
 extern bool toplevel_bindings_p        (void);
 extern bool namespace_bindings_p (void);
 extern bool template_parm_scope_p (void);
index f7d4e5f05c957d0548c3f0d0e5bdb513598d0ee9..a42921b685873b4cd8dbbf41682fb720796e4a5e 100644 (file)
@@ -4849,8 +4849,8 @@ fold_range_test (location_t loc, enum tree_code code, tree type,
                           ? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
                           type, op0, op1);
 
-      else if (lang_hooks.decls.global_bindings_p () == 0
-              && ! CONTAINS_PLACEHOLDER_P (lhs))
+      else if (!lang_hooks.decls.global_bindings_p ()
+              && !CONTAINS_PLACEHOLDER_P (lhs))
        {
          tree common = save_expr (lhs);
 
@@ -6148,10 +6148,6 @@ fold_mathfn_compare (location_t loc,
                                    build_real (TREE_TYPE (arg), dconst0));
 
              /* sqrt(x) < y is x >= 0 && x != +Inf, when y is large.  */
-             if (lang_hooks.decls.global_bindings_p () != 0
-                 || CONTAINS_PLACEHOLDER_P (arg))
-               return NULL_TREE;
-
              arg = save_expr (arg);
              return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
                                  fold_build2_loc (loc, GE_EXPR, type, arg,
@@ -6168,18 +6164,14 @@ fold_mathfn_compare (location_t loc,
                                build_real (TREE_TYPE (arg), c2));
 
          /* sqrt(x) < c is the same as x >= 0 && x < c*c.  */
-         if (lang_hooks.decls.global_bindings_p () == 0
-             && ! CONTAINS_PLACEHOLDER_P (arg))
-           {
-             arg = save_expr (arg);
-             return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
+         arg = save_expr (arg);
+         return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
                                  fold_build2_loc (loc, GE_EXPR, type, arg,
                                               build_real (TREE_TYPE (arg),
                                                           dconst0)),
                                  fold_build2_loc (loc, code, type, arg,
                                               build_real (TREE_TYPE (arg),
                                                           c2)));
-           }
        }
     }
 
@@ -6226,13 +6218,8 @@ fold_inf_compare (location_t loc, enum tree_code code, tree type,
        return omit_one_operand_loc (loc, type, integer_one_node, arg0);
 
       /* x <= +Inf is the same as x == x, i.e. isfinite(x).  */
-      if (lang_hooks.decls.global_bindings_p () == 0
-         && ! CONTAINS_PLACEHOLDER_P (arg0))
-       {
-         arg0 = save_expr (arg0);
-         return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg0);
-       }
-      break;
+      arg0 = save_expr (arg0);
+      return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg0);
 
     case EQ_EXPR:
     case GE_EXPR:
index 0a392c544124d8626f6c4f26b7e73d8fb07b5d3f..162da2e5c986361a04b360c4f881cb7e083eecba 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * f95-lang.c (global_bindings_p): Return bool and simplify.
+
 2011-05-07  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/18918
index eb38484ee33388d24461561341f38a5b7561481e..e247d70a6c014220f95702033b0a5d7e58f4c17e 100644 (file)
@@ -91,7 +91,7 @@ static void gfc_finish (void);
 static void gfc_write_global_declarations (void);
 static void gfc_print_identifier (FILE *, tree, int);
 void do_function_end (void);
-int global_bindings_p (void);
+bool global_bindings_p (void);
 static void clear_binding_stack (void);
 static void gfc_be_parse_file (void);
 static alias_set_type gfc_get_alias_set (tree);
@@ -373,12 +373,12 @@ static GTY(()) struct binding_level *global_binding_level;
 static struct binding_level clear_binding_level = { NULL, NULL, NULL };
 
 
-/* Return nonzero if we are currently in the global binding level.  */
+/* Return true if we are in the global binding level.  */
 
-int
+bool
 global_bindings_p (void)
 {
-  return current_binding_level == global_binding_level ? -1 : 0;
+  return current_binding_level == global_binding_level;
 }
 
 tree
index 6df65976ccbdf11337b3fe330293bb9ffc2d541b..4136702481bca89e4bc02a4aff9cf1abd03c354d 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * go-lang.c (global_bindings_p): Return bool and simplify.
+
 2011-05-05  Nathan Froyd  <froydnj@codesourcery.com>
 
        * go-gcc.cc (Gcc_backend::switch_statement): Call build_case_label.
index 5132e97cfe34dbabba4c31c779d49be2e84adc97..84c7f8d159158b8254fe4fb20a6fcb0ce39e2821 100644 (file)
@@ -308,10 +308,12 @@ go_langhook_builtin_function (tree decl)
   return decl;
 }
 
-static int
+/* Return true if we are in the global binding level.  */
+
+static bool
 go_langhook_global_bindings_p (void)
 {
-  return current_function_decl == NULL ? 1 : 0;
+  return current_function_decl == NULL_TREE;
 }
 
 /* Push a declaration into the current binding level.  We can't
index 7dea6e43f543694b830fd89d169da71f37abda6d..bdc0aa7bdaf337a4fc1b62a7fdefcaa8745da76a 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * java-tree.h (global_bindings_p): Adjust prototype.
+       * decl.c (global_bindings_p): Return bool.
+
 2011-05-05  Nathan Froyd  <froydnj@codesourcery.com>
 
        * expr.c (expand_java_switch): Call build_case_label.
index cb012485d00712b242b9fc2e87af150215c084a5..47b4ebe8de97ac850588689ae07dbc95f9cc8de1 100644 (file)
@@ -1302,9 +1302,9 @@ pushdecl_function_level (tree x)
   return t;
 }
 
-/* Nonzero if we are currently in the global binding level.  */
+/* Return true if we are in the global binding level.  */
 
-int
+bool
 global_bindings_p (void)
 {
   return current_binding_level == global_binding_level;
index e422b4a1557ea83d1a040f8d326ab63d43cc994b..7743c6e5c82bf418c6f8d862b3d89238a1d88116 100644 (file)
@@ -983,7 +983,7 @@ extern tree ident_subst (const char *, int, const char *, int, int,
                         const char *);
 extern tree identifier_subst (const tree, const char *, int, int,
                              const char *);
-extern int global_bindings_p (void);
+extern bool global_bindings_p (void);
 extern tree getdecls (void);
 extern void pushlevel (int);
 extern tree poplevel (int,int, int);
index e0dea01fc9aef02857d6618297a36d4b0aa6df47..89e74f936813135110c58ec8d6c1bd3adee02887 100644 (file)
@@ -148,9 +148,10 @@ struct lang_hooks_for_types
 
 struct lang_hooks_for_decls
 {
-  /* Returns nonzero if we are in the global binding level.  Ada
-     returns -1 for an undocumented reason used in stor-layout.c.  */
-  int (*global_bindings_p) (void);
+  /* Return true if we are in the global binding level.  This hook is really
+     needed only if the language supports variable-sized types at the global
+     level, i.e. declared outside subprograms.  */
+  bool (*global_bindings_p) (void);
 
   /* Function to add a decl to the current scope level.  Takes one
      argument, a decl to add.  Returns that decl, or, if the same
index 61558e3fc4a879c62fa1ec2743709e171f254e69..46779ff192bc1ddf7731731337c1f8c83fa005e0 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * lto-lang.c (global_bindings_p): Return bool.
+
 2011-05-07  Jan Hubicka  <jh@suse.cz>
 
        * lto.c (lto_materialize_function): Use cgraph_function_with_gimple_body_p.
index c65d916c14c8560cf38dddb4b67eb7879f91f107..5872928be0ddb03181deaebbcba3cb12bdaf33ed 100644 (file)
@@ -938,8 +938,10 @@ lto_type_for_mode (enum machine_mode mode, int unsigned_p)
   return NULL_TREE;
 }
 
-static int
-lto_global_bindings_p (void) 
+/* Return true if we are in the global binding level.  */
+
+static bool
+lto_global_bindings_p (void)
 {
   return cfun == NULL;
 }
index 6d662377c6d7c852c1b88e2f7bb8ccf590866859..12ccd803999f47e6182b9f8c0f4221a0ba3ca53e 100644 (file)
@@ -89,10 +89,10 @@ variable_size (tree size)
   if (CONTAINS_PLACEHOLDER_P (size))
     return self_referential_size (size);
 
-  /* If the language-processor is to take responsibility for variable-sized
-     items (e.g., languages which have elaboration procedures like Ada),
-     just return SIZE unchanged.  */
-  if (lang_hooks.decls.global_bindings_p () < 0)
+  /* If we are in the global binding level, we can't make a SAVE_EXPR
+     since it may end up being shared across functions, so it is up
+     to the front-end to deal with this case.  */
+  if (lang_hooks.decls.global_bindings_p ())
     return size;
 
   return save_expr (size);
This page took 0.121271 seconds and 5 git commands to generate.