Commit 7c775aca by Eric Botcazou Committed by Eric Botcazou

ada-tree.h (TYPE_IMPLEMENTS_PACKED_ARRAY_P): Rename to

	* gcc-interface/ada-tree.h (TYPE_IMPLEMENTS_PACKED_ARRAY_P): Rename to
	(TYPE_IMPL_PACKED_ARRAY_P): ...this.
	(TYPE_CAN_HAVE_DEBUG_TYPE_P): Do not test TYPE_DEBUG_TYPE.
	* gcc-interface/decl.c (gnat_to_gnu_entity): Simplify NULL_TREE tests
	and tweak gnat_encodings tests throughout.
	(initial_value_needs_conversion): Likewise.
	(intrin_arglists_compatible_p): Likewise.
	* gcc-interface/misc.c (gnat_print_type): Likewise.
	(gnat_get_debug_type): Likewise.
	(gnat_get_fixed_point_type_info): Likewise.
	(gnat_get_array_descr_info): Likewise.
	(get_array_bit_stride): Likewise.
	(gnat_get_type_bias): Fix formatting.
	(enumerate_modes): Likewise.
	* gcc-interface/trans.c (gnat_to_gnu): Likewise.
	(add_decl_expr): Simplify NULL_TREE test.
	(end_stmt_group): Likewise.
	(build_binary_op_trapv): Fix formatting.
	(get_exception_label): Use switch statement.
	(init_code_table): Move around.
	* gcc-interface/utils.c (global_bindings_p): Simplify NULL_TREE test.
	(gnat_poplevel): Likewise.
	(gnat_set_type_context): Likewise.
	(defer_or_set_type_context): Fix formatting.
	(gnat_pushdecl): Simplify NULL_TREE test.
	(maybe_pad_type): Likewise.
	(add_parallel_type): Likewise.
	(create_range_type): Likewise.
	(process_deferred_decl_context): Likewise.
	(convert): Likewise.
	(def_builtin_1): Likewise.
	* gcc-interface/utils2.c (find_common_type): Likewise.
	(build_binary_op): Likewise.
	(gnat_rewrite_reference): Likewise.
	(get_inner_constant_reference): Likewise.

From-SVN: r232501
parent 3dd5f42e
2016-01-18 Eric Botcazou <ebotcazou@adacore.com> 2016-01-18 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada-tree.h (TYPE_IMPLEMENTS_PACKED_ARRAY_P): Rename to
(TYPE_IMPL_PACKED_ARRAY_P): ...this.
(TYPE_CAN_HAVE_DEBUG_TYPE_P): Do not test TYPE_DEBUG_TYPE.
* gcc-interface/decl.c (gnat_to_gnu_entity): Simplify NULL_TREE tests
and tweak gnat_encodings tests throughout.
(initial_value_needs_conversion): Likewise.
(intrin_arglists_compatible_p): Likewise.
* gcc-interface/misc.c (gnat_print_type): Likewise.
(gnat_get_debug_type): Likewise.
(gnat_get_fixed_point_type_info): Likewise.
(gnat_get_array_descr_info): Likewise.
(get_array_bit_stride): Likewise.
(gnat_get_type_bias): Fix formatting.
(enumerate_modes): Likewise.
* gcc-interface/trans.c (gnat_to_gnu): Likewise.
(add_decl_expr): Simplify NULL_TREE test.
(end_stmt_group): Likewise.
(build_binary_op_trapv): Fix formatting.
(get_exception_label): Use switch statement.
(init_code_table): Move around.
* gcc-interface/utils.c (global_bindings_p): Simplify NULL_TREE test.
(gnat_poplevel): Likewise.
(gnat_set_type_context): Likewise.
(defer_or_set_type_context): Fix formatting.
(gnat_pushdecl): Simplify NULL_TREE test.
(maybe_pad_type): Likewise.
(add_parallel_type): Likewise.
(create_range_type): Likewise.
(process_deferred_decl_context): Likewise.
(convert): Likewise.
(def_builtin_1): Likewise.
* gcc-interface/utils2.c (find_common_type): Likewise.
(build_binary_op): Likewise.
(gnat_rewrite_reference): Likewise.
(get_inner_constant_reference): Likewise.
2016-01-18 Eric Botcazou <ebotcazou@adacore.com>
PR ada/69219 PR ada/69219
* gcc-interface/trans.c (check_inlining_for_nested_subprog): Consider * gcc-interface/trans.c (check_inlining_for_nested_subprog): Consider
the parent function instead of the current function in order to issue the parent function instead of the current function in order to issue
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Header File * * C Header File *
* * * *
* Copyright (C) 1992-2015, Free Software Foundation, Inc. * * Copyright (C) 1992-2016, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -189,14 +189,12 @@ do { \ ...@@ -189,14 +189,12 @@ do { \
/* True for types that implement a packed array and for original packed array /* True for types that implement a packed array and for original packed array
types. */ types. */
#define TYPE_IMPLEMENTS_PACKED_ARRAY_P(NODE) \ #define TYPE_IMPL_PACKED_ARRAY_P(NODE) \
((TREE_CODE (NODE) == ARRAY_TYPE && TYPE_PACKED (NODE)) \ ((TREE_CODE (NODE) == ARRAY_TYPE && TYPE_PACKED (NODE)) \
|| (TREE_CODE (NODE) == INTEGER_TYPE && TYPE_PACKED_ARRAY_TYPE_P (NODE))) \ || (TREE_CODE (NODE) == INTEGER_TYPE && TYPE_PACKED_ARRAY_TYPE_P (NODE)))
/* True for types that can hold a debug type. */ /* True for types that can hold a debug type. */
#define TYPE_CAN_HAVE_DEBUG_TYPE_P(NODE) \ #define TYPE_CAN_HAVE_DEBUG_TYPE_P(NODE) (!TYPE_IMPL_PACKED_ARRAY_P (NODE))
(!TYPE_IMPLEMENTS_PACKED_ARRAY_P (NODE) \
&& TYPE_DEBUG_TYPE (NODE) != NULL_TREE)
/* For an UNCONSTRAINED_ARRAY_TYPE, this is the record containing both the /* For an UNCONSTRAINED_ARRAY_TYPE, this is the record containing both the
template and the object. template and the object.
...@@ -385,8 +383,8 @@ do { \ ...@@ -385,8 +383,8 @@ do { \
#define SET_TYPE_DEBUG_TYPE(NODE, X) \ #define SET_TYPE_DEBUG_TYPE(NODE, X) \
SET_TYPE_LANG_SPECIFIC2 (NODE, X) SET_TYPE_LANG_SPECIFIC2 (NODE, X)
/* For types with TYPE_IMPLEMENTS_PACKED_ARRAY_P, this is the original packed /* For types with TYPE_IMPL_PACKED_ARRAY_P, this is the original packed
array type. Note that this predicate is trou for original packed array array type. Note that this predicate is true for original packed array
types, so these cannot have a debug type. */ types, so these cannot have a debug type. */
#define TYPE_ORIGINAL_PACKED_ARRAY(NODE) \ #define TYPE_ORIGINAL_PACKED_ARRAY(NODE) \
GET_TYPE_LANG_SPECIFIC2 (NODE) GET_TYPE_LANG_SPECIFIC2 (NODE)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2015, Free Software Foundation, Inc. * * Copyright (C) 1992-2016, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -1002,7 +1002,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1002,7 +1002,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* We cannot evaluate the first arm of a COMPOUND_EXPR in the /* We cannot evaluate the first arm of a COMPOUND_EXPR in the
correct place for this case, hence the above test. */ correct place for this case, hence the above test. */
gcc_assert (init == NULL_TREE); gcc_assert (!init);
/* No DECL_EXPR will be created so the expression needs to be /* No DECL_EXPR will be created so the expression needs to be
marked manually because it will likely be shared. */ marked manually because it will likely be shared. */
...@@ -2551,14 +2551,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -2551,14 +2551,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
types, are biased or are wider than sizetype. These are GNAT types, are biased or are wider than sizetype. These are GNAT
encodings, so we have to include them only when all encodings encodings, so we have to include them only when all encodings
are requested. */ are requested. */
if (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL if ((TREE_CODE (gnu_orig_min) != INTEGER_CST
&& (TREE_CODE (gnu_orig_min) != INTEGER_CST || TREE_CODE (gnu_orig_max) != INTEGER_CST
|| TREE_CODE (gnu_orig_max) != INTEGER_CST || TREE_CODE (gnu_index_type) != INTEGER_TYPE
|| TREE_CODE (gnu_index_type) != INTEGER_TYPE || (TREE_TYPE (gnu_index_type)
|| (TREE_TYPE (gnu_index_type) && TREE_CODE (TREE_TYPE (gnu_index_type))
&& TREE_CODE (TREE_TYPE (gnu_index_type)) != INTEGER_TYPE)
!= INTEGER_TYPE) || TYPE_BIASED_REPRESENTATION_P (gnu_index_type))
|| TYPE_BIASED_REPRESENTATION_P (gnu_index_type))) && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
need_index_type_struct = true; need_index_type_struct = true;
} }
...@@ -2621,8 +2621,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -2621,8 +2621,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
} }
/* Strip the ___XP suffix for standard DWARF. */ /* Strip the ___XP suffix for standard DWARF. */
if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL if (Is_Packed_Array_Impl_Type (gnat_entity)
&& Is_Packed_Array_Impl_Type (gnat_entity)) && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
{ {
Entity_Id gnat_original_array_type Entity_Id gnat_original_array_type
= Underlying_Type (Original_Array_Type (gnat_entity)); = Underlying_Type (Original_Array_Type (gnat_entity));
...@@ -2717,8 +2717,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -2717,8 +2717,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
{ {
tree gnu_base_decl tree gnu_base_decl
= gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, 0); = gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, 0);
if (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL if (!DECL_ARTIFICIAL (gnu_base_decl)
&& !DECL_ARTIFICIAL (gnu_base_decl)) && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
add_parallel_type (gnu_type, add_parallel_type (gnu_type,
TREE_TYPE (TREE_TYPE (gnu_base_decl))); TREE_TYPE (TREE_TYPE (gnu_base_decl)));
} }
...@@ -4279,7 +4279,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -4279,7 +4279,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& Present (gnat_renamed) && Present (gnat_renamed)
&& (Ekind (gnat_renamed) == E_Function && (Ekind (gnat_renamed) == E_Function
|| Ekind (gnat_renamed) == E_Procedure) || Ekind (gnat_renamed) == E_Procedure)
&& gnu_decl != NULL_TREE && gnu_decl
&& TREE_CODE (gnu_decl) == FUNCTION_DECL) && TREE_CODE (gnu_decl) == FUNCTION_DECL)
{ {
tree decl = build_decl (input_location, IMPORTED_DECL, tree decl = build_decl (input_location, IMPORTED_DECL,
...@@ -4306,7 +4306,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -4306,7 +4306,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
to let developers be notified on demand without risking false to let developers be notified on demand without risking false
positives with common default sets of options. */ positives with common default sets of options. */
if (gnu_builtin_decl == NULL_TREE && warn_shadow) if (!gnu_builtin_decl && warn_shadow)
post_error ("?gcc intrinsic not found for&!", gnat_entity); post_error ("?gcc intrinsic not found for&!", gnat_entity);
} }
...@@ -6171,8 +6171,8 @@ initial_value_needs_conversion (tree gnu_type, tree gnu_expr) ...@@ -6171,8 +6171,8 @@ initial_value_needs_conversion (tree gnu_type, tree gnu_expr)
without one, to keep the object simpler. */ without one, to keep the object simpler. */
if (TREE_CODE (gnu_type) == RECORD_TYPE if (TREE_CODE (gnu_type) == RECORD_TYPE
&& TREE_CODE (TREE_TYPE (gnu_expr)) == RECORD_TYPE && TREE_CODE (TREE_TYPE (gnu_expr)) == RECORD_TYPE
&& get_variant_part (gnu_type) != NULL_TREE && get_variant_part (gnu_type)
&& get_variant_part (TREE_TYPE (gnu_expr)) == NULL_TREE) && !get_variant_part (TREE_TYPE (gnu_expr)))
return false; return false;
/* In all the other cases, convert the expression to the object's type. */ /* In all the other cases, convert the expression to the object's type. */
...@@ -8527,17 +8527,17 @@ intrin_arglists_compatible_p (intrin_binding_t * inb) ...@@ -8527,17 +8527,17 @@ intrin_arglists_compatible_p (intrin_binding_t * inb)
/* Sequence position of the last argument we checked. */ /* Sequence position of the last argument we checked. */
int argpos = 0; int argpos = 0;
while (1) while (true)
{ {
tree ada_type = function_args_iter_cond (&ada_iter); tree ada_type = function_args_iter_cond (&ada_iter);
tree btin_type = function_args_iter_cond (&btin_iter); tree btin_type = function_args_iter_cond (&btin_iter);
/* If we've exhausted both lists simultaneously, we're done. */ /* If we've exhausted both lists simultaneously, we're done. */
if (ada_type == NULL_TREE && btin_type == NULL_TREE) if (!ada_type && !btin_type)
break; break;
/* If one list is shorter than the other, they fail to match. */ /* If one list is shorter than the other, they fail to match. */
if (ada_type == NULL_TREE || btin_type == NULL_TREE) if (!ada_type || !btin_type)
return false; return false;
/* If we're done with the Ada args and not with the internal builtin /* If we're done with the Ada args and not with the internal builtin
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2015, Free Software Foundation, Inc. * * Copyright (C) 1992-2016, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -6027,7 +6027,7 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -6027,7 +6027,7 @@ gnat_to_gnu (Node_Id gnat_node)
full view since the clause is on the partial view and we cannot have full view since the clause is on the partial view and we cannot have
2 different GCC trees for the object. The only bits of the full view 2 different GCC trees for the object. The only bits of the full view
we will use is the initializer, but it will be directly fetched. */ we will use is the initializer, but it will be directly fetched. */
if (Ekind(gnat_temp) == E_Constant if (Ekind (gnat_temp) == E_Constant
&& Present (Address_Clause (gnat_temp)) && Present (Address_Clause (gnat_temp))
&& Present (Full_View (gnat_temp))) && Present (Full_View (gnat_temp)))
save_gnu_tree (Full_View (gnat_temp), error_mark_node, true); save_gnu_tree (Full_View (gnat_temp), error_mark_node, true);
...@@ -8035,7 +8035,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity) ...@@ -8035,7 +8035,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
/* If this is a variable and an initializer is attached to it, it must be /* If this is a variable and an initializer is attached to it, it must be
valid for the context. Similar to init_const in create_var_decl. */ valid for the context. Similar to init_const in create_var_decl. */
if (TREE_CODE (gnu_decl) == VAR_DECL if (TREE_CODE (gnu_decl) == VAR_DECL
&& (gnu_init = DECL_INITIAL (gnu_decl)) != NULL_TREE && (gnu_init = DECL_INITIAL (gnu_decl))
&& (!gnat_types_compatible_p (type, TREE_TYPE (gnu_init)) && (!gnat_types_compatible_p (type, TREE_TYPE (gnu_init))
|| (TREE_STATIC (gnu_decl) || (TREE_STATIC (gnu_decl)
&& !initializer_constant_valid_p (gnu_init, && !initializer_constant_valid_p (gnu_init,
...@@ -8128,7 +8128,7 @@ end_stmt_group (void) ...@@ -8128,7 +8128,7 @@ end_stmt_group (void)
are cleanups, make a TRY_FINALLY_EXPR. Last, if there is a BLOCK, are cleanups, make a TRY_FINALLY_EXPR. Last, if there is a BLOCK,
make a BIND_EXPR. Note that we nest in that because the cleanup may make a BIND_EXPR. Note that we nest in that because the cleanup may
reference variables in the block. */ reference variables in the block. */
if (gnu_retval == NULL_TREE) if (!gnu_retval)
gnu_retval = alloc_stmt_list (); gnu_retval = alloc_stmt_list ();
if (group->cleanups) if (group->cleanups)
...@@ -9023,7 +9023,7 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left, ...@@ -9023,7 +9023,7 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
break; break;
default: default:
gcc_unreachable(); gcc_unreachable ();
} }
check = fold_build3 (COND_EXPR, boolean_type_node, rhs_lt_zero, check_neg, check = fold_build3 (COND_EXPR, boolean_type_node, rhs_lt_zero, check_neg,
...@@ -10083,7 +10083,39 @@ post_error_ne_tree_2 (const char *msg, Node_Id node, Entity_Id ent, tree t, ...@@ -10083,7 +10083,39 @@ post_error_ne_tree_2 (const char *msg, Node_Id node, Entity_Id ent, tree t,
Error_Msg_Uint_2 = UI_From_Int (num); Error_Msg_Uint_2 = UI_From_Int (num);
post_error_ne_tree (msg, node, ent, t); post_error_ne_tree (msg, node, ent, t);
} }
/* Return a label to branch to for the exception type in KIND or NULL_TREE
if none. */
tree
get_exception_label (char kind)
{
switch (kind)
{
case N_Raise_Constraint_Error:
return gnu_constraint_error_label_stack->last ();
case N_Raise_Storage_Error:
return gnu_storage_error_label_stack->last ();
case N_Raise_Program_Error:
return gnu_program_error_label_stack->last ();
default:
break;
}
return NULL_TREE;
}
/* Return the decl for the current elaboration procedure. */
tree
get_elaboration_procedure (void)
{
return gnu_elab_proc_stack->last ();
}
/* Initialize the table that maps GNAT codes to GCC codes for simple /* Initialize the table that maps GNAT codes to GCC codes for simple
binary and unary operations. */ binary and unary operations. */
...@@ -10117,28 +10149,4 @@ init_code_table (void) ...@@ -10117,28 +10149,4 @@ init_code_table (void)
gnu_codes[N_Op_Shift_Right_Arithmetic] = RSHIFT_EXPR; gnu_codes[N_Op_Shift_Right_Arithmetic] = RSHIFT_EXPR;
} }
/* Return a label to branch to for the exception type in KIND or NULL_TREE
if none. */
tree
get_exception_label (char kind)
{
if (kind == N_Raise_Constraint_Error)
return gnu_constraint_error_label_stack->last ();
else if (kind == N_Raise_Storage_Error)
return gnu_storage_error_label_stack->last ();
else if (kind == N_Raise_Program_Error)
return gnu_program_error_label_stack->last ();
else
return NULL_TREE;
}
/* Return the decl for the current elaboration procedure. */
tree
get_elaboration_procedure (void)
{
return gnu_elab_proc_stack->last ();
}
#include "gt-ada-trans.h" #include "gt-ada-trans.h"
...@@ -429,7 +429,7 @@ build_dummy_unc_pointer_types (Entity_Id gnat_desig_type, tree gnu_desig_type) ...@@ -429,7 +429,7 @@ build_dummy_unc_pointer_types (Entity_Id gnat_desig_type, tree gnu_desig_type)
bool bool
global_bindings_p (void) global_bindings_p (void)
{ {
return force_global || current_function_decl == NULL_TREE; return force_global || !current_function_decl;
} }
/* Enter a new binding level. */ /* Enter a new binding level. */
...@@ -515,7 +515,7 @@ gnat_poplevel (void) ...@@ -515,7 +515,7 @@ gnat_poplevel (void)
parent block. Otherwise, add it to the list of its parent. */ parent block. Otherwise, add it to the list of its parent. */
if (TREE_CODE (BLOCK_SUPERCONTEXT (block)) == FUNCTION_DECL) if (TREE_CODE (BLOCK_SUPERCONTEXT (block)) == FUNCTION_DECL)
; ;
else if (BLOCK_VARS (block) == NULL_TREE) else if (!BLOCK_VARS (block))
{ {
BLOCK_SUBBLOCKS (level->chain->block) BLOCK_SUBBLOCKS (level->chain->block)
= block_chainon (BLOCK_SUBBLOCKS (block), = block_chainon (BLOCK_SUBBLOCKS (block),
...@@ -570,9 +570,9 @@ gnat_set_type_context (tree type, tree context) ...@@ -570,9 +570,9 @@ gnat_set_type_context (tree type, tree context)
/* Give a context to the parallel types and their stub decl, if any. /* Give a context to the parallel types and their stub decl, if any.
Some parallel types seems to be present in multiple parallel type Some parallel types seems to be present in multiple parallel type
chains, so don't mess with their context if they already have one. */ chains, so don't mess with their context if they already have one. */
if (TYPE_CONTEXT (parallel_type) == NULL_TREE) if (!TYPE_CONTEXT (parallel_type))
{ {
if (TYPE_STUB_DECL (parallel_type) != NULL_TREE) if (TYPE_STUB_DECL (parallel_type))
DECL_CONTEXT (TYPE_STUB_DECL (parallel_type)) = context; DECL_CONTEXT (TYPE_STUB_DECL (parallel_type)) = context;
TYPE_CONTEXT (parallel_type) = context; TYPE_CONTEXT (parallel_type) = context;
} }
...@@ -625,17 +625,18 @@ get_debug_scope (Node_Id gnat_node, bool *is_subprogram) ...@@ -625,17 +625,18 @@ get_debug_scope (Node_Id gnat_node, bool *is_subprogram)
the outer one. */ the outer one. */
break; break;
} }
gnat_entity = Scope (gnat_entity); gnat_entity = Scope (gnat_entity);
} }
return Empty; return Empty;
} }
/* If N is NULL, set TYPE's context to CONTEXT. Defer this to the processing of /* If N is NULL, set TYPE's context to CONTEXT. Defer this to the processing
N otherwise. */ of N otherwise. */
static void static void
defer_or_set_type_context (tree type, defer_or_set_type_context (tree type, tree context,
tree context,
struct deferred_decl_context_node *n) struct deferred_decl_context_node *n)
{ {
if (n) if (n)
...@@ -644,7 +645,7 @@ defer_or_set_type_context (tree type, ...@@ -644,7 +645,7 @@ defer_or_set_type_context (tree type,
gnat_set_type_context (type, context); gnat_set_type_context (type, context);
} }
/* Return global_context. Create it if needed, first. */ /* Return global_context, but create it first if need be. */
static tree static tree
get_global_context (void) get_global_context (void)
...@@ -654,6 +655,7 @@ get_global_context (void) ...@@ -654,6 +655,7 @@ get_global_context (void)
global_context = build_translation_unit_decl (NULL_TREE); global_context = build_translation_unit_decl (NULL_TREE);
debug_hooks->register_main_translation_unit (global_context); debug_hooks->register_main_translation_unit (global_context);
} }
return global_context; return global_context;
} }
...@@ -694,14 +696,14 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) ...@@ -694,14 +696,14 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
/* External declarations (when force_global > 0) may not be in a /* External declarations (when force_global > 0) may not be in a
local context. */ local context. */
else if (current_function_decl != NULL_TREE && force_global == 0) else if (current_function_decl && force_global == 0)
context = current_function_decl; context = current_function_decl;
} }
/* If either we are forced to be in global mode or if both the GNAT scope and /* If either we are forced to be in global mode or if both the GNAT scope and
the current_function_decl did not help determining the context, use the the current_function_decl did not help in determining the context, use the
global scope. */ global scope. */
if (!deferred_decl_context && context == NULL_TREE) if (!deferred_decl_context && !context)
context = get_global_context (); context = get_global_context ();
/* Functions imported in another function are not really nested. /* Functions imported in another function are not really nested.
...@@ -710,9 +712,9 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) ...@@ -710,9 +712,9 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
lower_nested_functions will then recompute it. */ lower_nested_functions will then recompute it. */
if (TREE_CODE (decl) == FUNCTION_DECL if (TREE_CODE (decl) == FUNCTION_DECL
&& !TREE_PUBLIC (decl) && !TREE_PUBLIC (decl)
&& context != NULL_TREE && context
&& (TREE_CODE (context) == FUNCTION_DECL && (TREE_CODE (context) == FUNCTION_DECL
|| decl_function_context (context) != NULL_TREE)) || decl_function_context (context)))
DECL_STATIC_CHAIN (decl) = 1; DECL_STATIC_CHAIN (decl) = 1;
if (!deferred_decl_context) if (!deferred_decl_context)
...@@ -1281,16 +1283,15 @@ maybe_pad_type (tree type, tree size, unsigned int align, ...@@ -1281,16 +1283,15 @@ maybe_pad_type (tree type, tree size, unsigned int align,
if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
SET_TYPE_DEBUG_TYPE (record, type); SET_TYPE_DEBUG_TYPE (record, type);
/* ??? Kludge: padding types around packed array implementation types will be /* ??? Padding types around packed array implementation types will be
considered as root types in the array descriptor language hook (see considered as root types in the array descriptor language hook (see
gnat_get_array_descr_info). Give them the original packed array type gnat_get_array_descr_info). Give them the original packed array type
name so that the one coming from sources appears in the debugging name so that the one coming from sources appears in the debugging
information. */ information. */
if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL if (TYPE_IMPL_PACKED_ARRAY_P (type)
&& TYPE_IMPLEMENTS_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type)
&& TYPE_ORIGINAL_PACKED_ARRAY (type) != NULL_TREE) && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
TYPE_NAME (record) TYPE_NAME (record) = TYPE_NAME (TYPE_ORIGINAL_PACKED_ARRAY (type));
= TYPE_NAME (TYPE_ORIGINAL_PACKED_ARRAY (type));
else if (Present (gnat_entity)) else if (Present (gnat_entity))
TYPE_NAME (record) = create_concat_name (gnat_entity, "PAD"); TYPE_NAME (record) = create_concat_name (gnat_entity, "PAD");
...@@ -1855,17 +1856,17 @@ add_parallel_type (tree type, tree parallel_type) ...@@ -1855,17 +1856,17 @@ add_parallel_type (tree type, tree parallel_type)
SET_DECL_PARALLEL_TYPE (decl, parallel_type); SET_DECL_PARALLEL_TYPE (decl, parallel_type);
/* If PARALLEL_TYPE already has a context, we are done. */ /* If PARALLEL_TYPE already has a context, we are done. */
if (TYPE_CONTEXT (parallel_type) != NULL_TREE) if (TYPE_CONTEXT (parallel_type))
return; return;
/* Otherwise, try to get one from TYPE's context. */ /* Otherwise, try to get one from TYPE's context. If so, simply propagate
if (TYPE_CONTEXT (type) != NULL_TREE) it to PARALLEL_TYPE. */
/* TYPE already has a context, so simply propagate it to PARALLEL_TYPE. */ if (TYPE_CONTEXT (type))
gnat_set_type_context (parallel_type, TYPE_CONTEXT (type)); gnat_set_type_context (parallel_type, TYPE_CONTEXT (type));
/* ... otherwise TYPE has not context yet. We know it will thanks to /* Otherwise TYPE has not context yet. We know it will have one thanks to
gnat_pushdecl, and then its context will be propagated to PARALLEL_TYPE. gnat_pushdecl and then its context will be propagated to PARALLEL_TYPE,
So we have nothing to do in this case. */ so we have nothing to do in this case. */
} }
/* Return true if TYPE has a parallel type. */ /* Return true if TYPE has a parallel type. */
...@@ -2269,7 +2270,7 @@ create_range_type (tree type, tree min, tree max) ...@@ -2269,7 +2270,7 @@ create_range_type (tree type, tree min, tree max)
{ {
tree range_type; tree range_type;
if (type == NULL_TREE) if (!type)
type = sizetype; type = sizetype;
/* First build a type with the base range. */ /* First build a type with the base range. */
...@@ -2905,32 +2906,30 @@ process_deferred_decl_context (bool force) ...@@ -2905,32 +2906,30 @@ process_deferred_decl_context (bool force)
while (Present (gnat_scope)) while (Present (gnat_scope))
{ {
context = compute_deferred_decl_context (gnat_scope); context = compute_deferred_decl_context (gnat_scope);
if (!force || context != NULL_TREE) if (!force || context)
break; break;
gnat_scope = get_debug_scope (gnat_scope, NULL); gnat_scope = get_debug_scope (gnat_scope, NULL);
} }
/* Imported declarations must not be in a local context (i.e. not inside /* Imported declarations must not be in a local context (i.e. not inside
a function). */ a function). */
if (context != NULL_TREE && node->force_global > 0) if (context && node->force_global > 0)
{ {
tree ctx = context; tree ctx = context;
while (ctx != NULL_TREE) while (ctx)
{ {
gcc_assert (TREE_CODE (ctx) != FUNCTION_DECL); gcc_assert (TREE_CODE (ctx) != FUNCTION_DECL);
ctx = (DECL_P (ctx)) ctx = DECL_P (ctx) ? DECL_CONTEXT (ctx) : TYPE_CONTEXT (ctx);
? DECL_CONTEXT (ctx)
: TYPE_CONTEXT (ctx);
} }
} }
/* If FORCE, we want to get rid of all nodes in the queue: in case there /* If FORCE, we want to get rid of all nodes in the queue: in case there
was no elaborated scope, use the global context. */ was no elaborated scope, use the global context. */
if (force && context == NULL_TREE) if (force && !context)
context = get_global_context (); context = get_global_context ();
if (context != NULL_TREE) if (context)
{ {
tree t; tree t;
int i; int i;
...@@ -4514,11 +4513,11 @@ convert (tree type, tree expr) ...@@ -4514,11 +4513,11 @@ convert (tree type, tree expr)
if (TYPE_IS_THIN_POINTER_P (etype) && TYPE_IS_THIN_POINTER_P (type)) if (TYPE_IS_THIN_POINTER_P (etype) && TYPE_IS_THIN_POINTER_P (type))
{ {
tree etype_pos tree etype_pos
= TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype)) != NULL_TREE = TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype))
? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (etype)))) ? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (etype))))
: size_zero_node; : size_zero_node;
tree type_pos tree type_pos
= TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type)) != NULL_TREE = TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))
? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (type)))) ? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (type))))
: size_zero_node; : size_zero_node;
tree byte_diff = size_diffop (type_pos, etype_pos); tree byte_diff = size_diffop (type_pos, etype_pos);
...@@ -6107,7 +6106,7 @@ def_builtin_1 (enum built_in_function fncode, ...@@ -6107,7 +6106,7 @@ def_builtin_1 (enum built_in_function fncode,
/* Preserve an already installed decl. It most likely was setup in advance /* Preserve an already installed decl. It most likely was setup in advance
(e.g. as part of the internal builtins) for specific reasons. */ (e.g. as part of the internal builtins) for specific reasons. */
if (builtin_decl_explicit (fncode) != NULL_TREE) if (builtin_decl_explicit (fncode))
return; return;
gcc_assert ((!both_p && !fallback_p) gcc_assert ((!both_p && !fallback_p)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2015, Free Software Foundation, Inc. * * Copyright (C) 1992-2016, Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -223,8 +223,8 @@ find_common_type (tree t1, tree t2) ...@@ -223,8 +223,8 @@ find_common_type (tree t1, tree t2)
|| (TYPE_SIZE (t1) == TYPE_SIZE (t2) || (TYPE_SIZE (t1) == TYPE_SIZE (t2)
&& !(TREE_CODE (t1) == RECORD_TYPE && !(TREE_CODE (t1) == RECORD_TYPE
&& TREE_CODE (t2) == RECORD_TYPE && TREE_CODE (t2) == RECORD_TYPE
&& get_variant_part (t1) != NULL_TREE && get_variant_part (t1)
&& get_variant_part (t2) == NULL_TREE)))) && !get_variant_part (t2)))))
return t1; return t1;
/* Otherwise, if the lhs type is non-BLKmode, use it. Note that we know /* Otherwise, if the lhs type is non-BLKmode, use it. Note that we know
...@@ -852,7 +852,7 @@ build_binary_op (enum tree_code op_code, tree result_type, ...@@ -852,7 +852,7 @@ build_binary_op (enum tree_code op_code, tree result_type,
{ {
case INIT_EXPR: case INIT_EXPR:
case MODIFY_EXPR: case MODIFY_EXPR:
gcc_checking_assert (result_type == NULL_TREE); gcc_checking_assert (!result_type);
/* If there were integral or pointer conversions on the LHS, remove /* If there were integral or pointer conversions on the LHS, remove
them; we'll be putting them back below if needed. Likewise for them; we'll be putting them back below if needed. Likewise for
...@@ -2408,7 +2408,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, ...@@ -2408,7 +2408,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
} }
/* Indicate that we need to take the address of T and that it therefore /* Indicate that we need to take the address of T and that it therefore
should not be allocated in a register. Returns true if successful. */ should not be allocated in a register. Return true if successful. */
bool bool
gnat_mark_addressable (tree t) gnat_mark_addressable (tree t)
...@@ -2704,7 +2704,7 @@ gnat_rewrite_reference (tree ref, rewrite_fn func, void *data, tree *init) ...@@ -2704,7 +2704,7 @@ gnat_rewrite_reference (tree ref, rewrite_fn func, void *data, tree *init)
break; break;
case COMPOUND_EXPR: case COMPOUND_EXPR:
gcc_assert (*init == NULL_TREE); gcc_assert (!*init);
*init = TREE_OPERAND (ref, 0); *init = TREE_OPERAND (ref, 0);
/* We expect only the pattern built in Call_to_gnu. */ /* We expect only the pattern built in Call_to_gnu. */
gcc_assert (DECL_P (TREE_OPERAND (ref, 1)) gcc_assert (DECL_P (TREE_OPERAND (ref, 1))
...@@ -2778,7 +2778,7 @@ get_inner_constant_reference (tree exp) ...@@ -2778,7 +2778,7 @@ get_inner_constant_reference (tree exp)
break; break;
case COMPONENT_REF: case COMPONENT_REF:
if (TREE_OPERAND (exp, 2) != NULL_TREE) if (TREE_OPERAND (exp, 2))
return NULL_TREE; return NULL_TREE;
if (!TREE_CONSTANT (DECL_FIELD_OFFSET (TREE_OPERAND (exp, 1)))) if (!TREE_CONSTANT (DECL_FIELD_OFFSET (TREE_OPERAND (exp, 1))))
...@@ -2788,8 +2788,7 @@ get_inner_constant_reference (tree exp) ...@@ -2788,8 +2788,7 @@ get_inner_constant_reference (tree exp)
case ARRAY_REF: case ARRAY_REF:
case ARRAY_RANGE_REF: case ARRAY_RANGE_REF:
{ {
if (TREE_OPERAND (exp, 2) != NULL_TREE if (TREE_OPERAND (exp, 2) || TREE_OPERAND (exp, 3))
|| TREE_OPERAND (exp, 3) != NULL_TREE)
return NULL_TREE; return NULL_TREE;
tree array_type = TREE_TYPE (TREE_OPERAND (exp, 0)); tree array_type = TREE_TYPE (TREE_OPERAND (exp, 0));
...@@ -2917,7 +2916,7 @@ gnat_invariant_expr (tree expr) ...@@ -2917,7 +2916,7 @@ gnat_invariant_expr (tree expr)
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
case COMPONENT_REF: case COMPONENT_REF:
if (TREE_OPERAND (t, 2) != NULL_TREE) if (TREE_OPERAND (t, 2))
return NULL_TREE; return NULL_TREE;
invariant_p |= DECL_INVARIANT_P (TREE_OPERAND (t, 1)); invariant_p |= DECL_INVARIANT_P (TREE_OPERAND (t, 1));
break; break;
...@@ -2925,8 +2924,8 @@ gnat_invariant_expr (tree expr) ...@@ -2925,8 +2924,8 @@ gnat_invariant_expr (tree expr)
case ARRAY_REF: case ARRAY_REF:
case ARRAY_RANGE_REF: case ARRAY_RANGE_REF:
if (!TREE_CONSTANT (TREE_OPERAND (t, 1)) if (!TREE_CONSTANT (TREE_OPERAND (t, 1))
|| TREE_OPERAND (t, 2) != NULL_TREE || TREE_OPERAND (t, 2)
|| TREE_OPERAND (t, 3) != NULL_TREE) || TREE_OPERAND (t, 3))
return NULL_TREE; return NULL_TREE;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment