aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/gigi.h
AgeCommit message (Collapse)AuthorFilesLines
2020-11-11Remove superfluous call to Base_TypeEric Botcazou1-1/+1
gcc/ada/ChangeLog: * gcc-interface/gigi.h: Remove ^L characters throughout. * gcc-interface/decl.c: Likewise. * gcc-interface/utils.c: Likewise. * gcc-interface/utils2.c: Likewise. * gcc-interface/trans.c (gnat_to_gnu) <N_Allocator>: Do not explicitly go to the base type for the Has_Constrained_Partial_View flag.
2020-09-12Add preliminary support for 128-bit integer typesEric Botcazou1-0/+5
This is only the gigi part, in preparation for the bulk of the implementation. gcc/ada/ChangeLog: * fe.h: Fix pilot error in previous change. * gcc-interface/gigi.h (enum standard_datatypes): Add ADT_mulv128_decl. (mulv128_decl): New macro. (get_target_long_long_long_size): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity): Use a maximum size of 128 bits for discrete types if Enable_128bit_Types is true. * gcc-interface/targtyps.c: Include target.h. (get_target_long_long_long_size): New function. * gcc-interface/trans.c (gigi): Initialize mulv128_decl if need be. (build_binary_op_trapv): Call it for 128-bit multiplication. * gcc-interface/utils.c (make_type_from_size): Enforce a maximum size of 128 bits if Enable_128bit_Types is true.
2020-05-25Fix wrong assignment to mutable Out parameter of task entryEric Botcazou1-0/+8
Under very specific circumstances the compiler can generate a wrong assignment to a mutable record object which contains an array component, because it does not correctly handle the update of the discriminant. gcc/ada/ChangeLog * gcc-interface/gigi.h (operand_type): New static inline function. * gcc-interface/trans.c (gnat_to_gnu): Do not suppress conversion to the resulty type at the end for array types. * gcc-interface/utils2.c (build_binary_op) <MODIFY_EXPR>: Do not remove conversions between array types on the LHS. gcc/testsuite/ChangeLog * gnat.dg/array39.adb: New test. * gnat.dg/array39_pkg.ads: New helper. * gnat.dg/array39_pkg.adb: Likewise.
2020-05-09Update copyright yearEric Botcazou1-1/+1
2020-05-09Fix small issues with -fgnat-encodings=minimalEric Botcazou1-6/+4
This is the mode where the GNAT compiler does not use special encodings in the debug info to describe some Ada constructs, for example packed array types. * gcc-interface/ada-tree.h (TYPE_PACKED_ARRAY_TYPE_P): Rename into... (TYPE_BIT_PACKED_ARRAY_TYPE_P): ...this. (TYPE_IS_PACKED_ARRAY_TYPE_P): Rename into... (BIT_PACKED_ARRAY_TYPE_P): ...this. (TYPE_IMPL_PACKED_ARRAY_P): Adjust to above renaming. * gcc-interface/gigi.h (maybe_pad_type): Remove IS_USER_TYPE.. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Adjust call to maybe_pad_type. <E_Ordinary_Fixed_Point_Type>: Remove const qualifiers for tree. <E_Signed_Integer_Subtype>: Remove redundant test and redundant call to associate_original_type_to_packed_array. Turn into assertion. Call associate_original_type_to_packed_array and modify gnu_entity_name accordingly. Explicitly set the parallel type for GNAT encodings. Call create_type_decl in the misaligned case before maybe_pad_type. <E_Array_Type>: Do not use the name of the implementation type for a packed array when not using GNAT encodings. <E_Array_Subtype>: Move around setting flags. Use the result of the call to associate_original_type_to_packed_array for gnu_entity_name. <E_Record_Subtype>: Create XVS type and XVZ variable only if debug info is requested for the type. Call create_type_decl if a padded type was created for a type entity (gnat_to_gnu_component_type): Use local variable and adjust calls to maybe_pad_type. (gnat_to_gnu_subprog_type): Adjust call to maybe_pad_type. (gnat_to_gnu_field): Likewise. (validate_size): Adjust to renaming of macro. (set_rm_size): Likewise. (associate_original_type_to_packed_array): Adjust return type and return the name of the original type if GNAT encodings are not used * gcc-interface/misc.c (gnat_get_debug_typ): Remove obsolete stuff. (gnat_get_fixed_point_type_info): Remove const qualifiers for tree. (gnat_get_array_descr_info): Likewise and set variables lazily. Remove call to maybe_debug_type. Simplify a few computations. (enumerate_modes): Remove const qualifier for tree. * gcc-interface/utils.c (make_type_from_size): Adjust to renaming. (maybe_pad_type): Remove IS_USER_TYPE parameter and adjust. Remove specific code for implementation types for packed arrays. (compute_deferred_decl_context): Remove const qualifier for tree. (convert): Adjust call to maybe_pad_type. (unchecked_convert): Likewise. * gcc-interface/utils2.c (is_simple_additive_expressio): Likewise.
2020-05-09Small housekeeping work in gigiEric Botcazou1-21/+34
No functional changes. * gcc-interface/gigi.h (change_qualified_type): Move around. (maybe_vector_array): Likewise. (maybe_padded_object): New static line function. * gcc-interface/trans.c (Attribute_to_gnu) <Attr_Component_Size>: Remove useless code. <Attr_Null_Parameter>: Remove obsolete code. (Call_to_gn): Likewise. Use maybe_padded_object to remove padding. (gnat_to_gnu): Likewise. <N_String_Literal>: Do not add a useless null character at the end. <N_Indexed_Component>: Likewise and remove obsolete code. (add_decl_expr): Likewise. (maybe_implicit_deref): Likewise. * gcc-interface/utils.c (maybe_unconstrained_array): Likewise. * gcc-interface/utils2.c (gnat_invariant_expr): Likewise.
2019-08-30gigi.h (aggregate_type_contains_array_p): Declare.Eric Botcazou1-0/+5
* gcc-interface/gigi.h (aggregate_type_contains_array_p): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: For an extension, test Has_Record_Rep_Clause instead of Has_Specified_Layout. (adjust_packed): Return 0 if the type of the field is an aggregate type that contains (or is) a self-referential array. (type_has_variable_size): Delete. * gcc-interface/utils.c (inish_record_type): Constify a variable. (aggregate_type_contains_array_p): Add parameter SELF_REFERENTIAL. <RECORD_TYPE>: Pass it in the recursive call. <ARRAY_TYPE>: If it is true, return true only if the array type is self-referential. (create_field_decl): Streamline the setting of the alignment on the field. Pass false to aggregate_type_contains_array_p. From-SVN: r275196
2019-08-30gigi.h (gigi_checking_assert): New macro.Eric Botcazou1-1/+7
* gcc-interface/gigi.h (gigi_checking_assert): New macro. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Modular_Integer_Type>: Remove redundant test and adjust comments. Minor tweaks. * gcc-interface/trans.c (Call_to_gnu): Do not generate range checks, instead assert that the Do_Range_Check flag is not set. Adjust call to convert_with_check. (gnat_to_gnu): Likewise. (assoc_to_constructor): Likewise. (pos_to_constructor): Likewise. Remove GNAT_COMPONENT_TYPE parameter. (emit_range_check): Delete. (convert_with_check): Remove RANGE_P parameter and adjust. Do a single overflow check for modular types. From-SVN: r275174
2019-06-29expr.c (expand_expr_real_1): Apply the big-endian adjustment for bit-fields ↵Eric Botcazou1-2/+2
to all aggregate types. * expr.c (expand_expr_real_1) <BIT_FIELD_REF>: Apply the big-endian adjustment for bit-fields to all aggregate types. ada/ * gcc-interface/gigi.h (make_packable_type): Remove default value. (value_factor_p): Tweak prototype. * gcc-interface/decl.c (gnat_to_gnu_entity): Add comment. (gnat_to_gnu_component_type): Likewise. (gnat_to_gnu_field): Likewise. Fetch the position of the field earlier and simplify the condition under which the type is packed. Declare local variable is_bitfield. Pass 1 as max_align to make_packable_type if it is set to true. (copy_and_substitute_in_layout): Pass 0 to make_packable_type. * gcc-interface/utils.c (make_packable_array_type): New function. (make_packable_type): Use it to rewrite the type of array field. (maybe_pad_type): Pass align parameter to make_packable_type. (create_field_decl): Minor tweaks. (value_factor_p): Assert that FACTOR is a power of 2 and replace the modulo computation by a masking operation. From-SVN: r272810
2019-06-25decl.c (gnat_to_gnu_entity): Remove superfluous test in previous change.Eric Botcazou1-2/+4
* gcc-interface/decl.c (gnat_to_gnu_entity): Remove superfluous test in previous change. * gcc-interface/gigi.h (maybe_character_type): Fix formatting. (maybe_character_value): Likewise. From-SVN: r272637
2019-06-24ipa-utils.h (type_with_linkage_p): Verify that type is CXX_ODR_P.Jan Hubicka1-2/+4
* ipa-utils.h (type_with_linkage_p): Verify that type is CXX_ODR_P. (odr_type_p): Remove extra return. * lto-streamer-out.c (hash_tree): Hash TYPE_CXX_ODR_P; hash STRING_FLAG only for arrays and integers. * tree-stremaer-in.c (unpack_ts_type_common_value_fields): Update analogously. * tree-streamer-out.c (pack_ts_type_common_value_fields): Likewise. * print-tree.c (print_node): Print cxx-odr-p and string-flag. * tree.c (need_assembler_name_p): Also check that type is CXX_ODR_TYPE_P (verify_type_variant): Update verification of SRING_FLAG; also check CXX_ODR_P. * tree.h (ARRAY_OR_INTEGER_TYPE_CHECK): New macro. (TYPE_STRING_FLAG): Use it. (TYPE_CXX_ODR_P): New macro. * lto-common.c (compare_tree_sccs_1): Compare CXX_ODR_P; compare STRING_FLAG only for arrays and integers. * gcc-interface/decl.c (gnat_to_gnu_entity): Check that type is array or integer prior checking string flag. * gcc-interface/gigi.h (gnat_signed_type_for, maybe_character_value): Likewise. * c-common.c (braced_lists_to_strings): Check that type is array or integer prior checking string flag. * lex.c (cxx_make_type): Set TYPE_CXX_ODR_P. * dwarf2out.c (gen_array_type_die): First check that type is an array and then test string flag. * trans-expr.c (gfc_conv_substring): Check that type is array or integer prior checking string flag. (gfc_conv_string_parameter): Likewise. * trans-openmp.c (gfc_omp_scalar_p): Likewise. * trans.c (gfc_build_array_ref): Likewise. From-SVN: r272628
2019-01-27repinfo.adb (List_Component_Layout): Remove superfluous space for zero-sized ↵Eric Botcazou1-0/+3
field. * repinfo.adb (List_Component_Layout): Remove superfluous space for zero-sized field. * gcc-interface/ada-tree.h (TYPE_IS_EXTRA_SUBTYPE_P): New macro. * gcc-interface/gigi.h (create_extra_subtype): Declare. * gcc-interface/decl.c (TYPE_ARRAY_SIZE_LIMIT): Likewise. (update_n_elem): New function. (gnat_to_gnu_entity): Use create_extra_subtype to create extra subtypes instead of doing it manually. <E_Array_Type>: Use update_n_elem to compute the maximum size. Use the index type instead of base type for the bounds. Set TYPE_ARRAY_MAX_SIZE of the array to the maximum size. <E_Array_Subtype>: Create an extra subtype using the index type of the base array type for self-referential bounds. Use update_n_elem to compute the maximum size. Set TYPE_ARRAY_MAX_SIZE of the array to the maximum size. (gnat_to_gnu_field): Clear DECL_NONADDRESSABLE_P on discriminants. * gcc-interface/misc.c (gnat_get_alias_set): Return the alias set of the base type for an extra subtype. (gnat_type_max_size): Remove obsolete code. * gcc-interface/trans.c (Attribute_to_gnu): Minor tweak. (can_be_lower_p): Deal with pathological types. * gcc-interface/utils.c (create_extra_subtype): New function. (create_field_decl): Minor tweak. (max_size) <tcc_reference>: Compute a better value by using the extra subtypes on the self-referential bounds. <tcc_binary>: Rewrite. Deal with "negative value" in unsigned types. <tcc_expression>: Likewise. * gcc-interface/utils2.c (compare_arrays): Retrieve the original bounds of the arrays upfront. Swap only if the second length is not constant. Use comparisons on the original bounds consistently for the null tests. (build_binary_op): Use TYPE_IS_EXTRA_SUBTYPE_P macro. (build_allocator): Minor tweak. From-SVN: r268318
2018-12-11[Ada] Almost always inline init. procedure of small and simple recordsEric Botcazou1-2/+4
2018-12-11 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * fe.h (Debug_Generated_Code): Declare. * gcc-interface/gigi.h (enum inline_status_t): Rename is_disabled to is_default, is_enabled to is_requested and add is_prescribed. * gcc-interface/decl.c (inline_status_for_subprog): New function. (gnat_to_gnu_entity) <E_Subprogram_Type>: Use it to get the inlining status of the subprogram. * gcc-interface/trans.c (gigi): Adjust to above renaming. (build_raise_check): Likewise. (Compilation_Unit_to_gnu): Likewise. (gnat_to_gnu): Likewise. * gcc-interface/utils.c (create_subprog_decl): Likewise. Deal with is_prescribed status by setting DECL_DISREGARD_INLINE_LIMITS. Do not set the DECL_NO_INLINE_WARNING_P flag if Debug_Generated_Code is true. From-SVN: r266976
2018-09-26[Ada] Set Current_Error_Node directlyEric Botcazou1-3/+0
This changes gigi to set Current_Error_Node directly, which should result in a more robust error handling. 2018-09-26 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * gcc-interface/gigi.h (error_gnat_node): Delete. * gcc-interface/trans.c (error_gnat_node): Likewise. (gigi): Replace it with Current_Error_Node. (gnat_to_gnu): Likewise. * gcc-interface/utils.c (rest_of_subprog_body_compilation): Likewise. * gcc-interface/misc.c (internal_error_function): Do not set it. From-SVN: r264607
2018-08-27Come up with fndecl_built_in_p.Martin Liska1-1/+1
2018-08-27 Martin Liska <mliska@suse.cz> * builtins.h (is_builtin_fn): Remove and fndecl_built_in_p. * builtins.c (is_builtin_fn): Likewise. * attribs.c (diag_attr_exclusions): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. (builtin_mathfn_code): Likewise. (fold_builtin_expect): Likewise. (fold_call_expr): Likewise. (fold_builtin_call_array): Likewise. (fold_call_stmt): Likewise. (set_builtin_user_assembler_name): Likewise. (is_simple_builtin): Likewise. * calls.c (gimple_alloca_call_p): Likewise. (maybe_warn_nonstring_arg): Likewise. * cfgexpand.c (expand_call_stmt): Likewise. * cgraph.c (cgraph_update_edges_for_call_stmt_node): Likewise. (cgraph_edge::verify_corresponds_to_fndecl): Likewise. (cgraph_node::verify_node): Likewise. * cgraphclones.c (build_function_decl_skip_args): Likewise. (cgraph_node::create_clone): Likewise. * config/arm/arm.c (arm_insert_attributes): Likewise. * config/i386/i386.c (ix86_gimple_fold_builtin): Likewise. * dse.c (scan_insn): Likewise. * expr.c (expand_expr_real_1): Likewise. * fold-const.c (operand_equal_p): Likewise. (fold_binary_loc): Likewise. * gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise. * gimple-low.c (lower_stmt): Likewise. * gimple-pretty-print.c (dump_gimple_call): Likewise. * gimple-ssa-warn-restrict.c (wrestrict_dom_walker::check_call): Likewise. * gimple.c (gimple_build_call_from_tree): Likewise. (gimple_call_builtin_p): Likewise. (gimple_call_combined_fn): Likewise. * gimplify.c (gimplify_call_expr): Likewise. (gimple_boolify): Likewise. (gimplify_modify_expr): Likewise. (gimplify_addr_expr): Likewise. * hsa-gen.c (gen_hsa_insns_for_call): Likewise. * ipa-cp.c (determine_versionability): Likewise. * ipa-fnsummary.c (compute_fn_summary): Likewise. * ipa-param-manipulation.c (ipa_modify_formal_parameters): Likewise. * ipa-split.c (visit_bb): Likewise. (split_function): Likewise. * ipa-visibility.c (cgraph_externally_visible_p): Likewise. * lto-cgraph.c (input_node): Likewise. * lto-streamer-out.c (write_symbol): Likewise. * omp-low.c (setjmp_or_longjmp_p): Likewise. (lower_omp_1): Likewise. * predict.c (strip_predict_hints): Likewise. * print-tree.c (print_node): Likewise. * symtab.c (symtab_node::output_to_lto_symbol_table_p): Likewise. * trans-mem.c (is_tm_irrevocable): Likewise. (is_tm_load): Likewise. (is_tm_simple_load): Likewise. (is_tm_store): Likewise. (is_tm_simple_store): Likewise. (is_tm_abort): Likewise. (tm_region_init_1): Likewise. * tree-call-cdce.c (gen_shrink_wrap_conditions): Likewise. * tree-cfg.c (verify_gimple_call): Likewise. (move_stmt_r): Likewise. (stmt_can_terminate_bb_p): Likewise. * tree-eh.c (lower_eh_constructs_2): Likewise. * tree-if-conv.c (if_convertible_stmt_p): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. (copy_bb): Likewise. (estimate_num_insns): Likewise. (fold_marked_statements): Likewise. * tree-sra.c (scan_function): Likewise. * tree-ssa-ccp.c (surely_varying_stmt_p): Likewise. (optimize_stack_restore): Likewise. (pass_fold_builtins::execute): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise. (mark_all_reaching_defs_necessary_1): Likewise. * tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Likewise. * tree-ssa-forwprop.c (simplify_builtin_call): Likewise. (pass_forwprop::execute): Likewise. * tree-ssa-loop-im.c (stmt_cost): Likewise. * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise. * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Likewise. * tree-ssa-strlen.c (get_string_length): Likewise. * tree-ssa-structalias.c (handle_lhs_call): Likewise. (find_func_aliases_for_call): Likewise. * tree-ssa-ter.c (find_replaceable_in_bb): Likewise. * tree-stdarg.c (optimize_va_list_gpr_fpr_size): Likewise. * tree-tailcall.c (find_tail_calls): Likewise. * tree.c (need_assembler_name_p): Likewise. (free_lang_data_in_decl): Likewise. (get_call_combined_fn): Likewise. * ubsan.c (is_ubsan_builtin_p): Likewise. * varasm.c (incorporeal_function_p): Likewise. * tree.h (DECL_BUILT_IN): Remove and replace with fndecl_built_in_p. (DECL_BUILT_IN_P): Transfort to fndecl_built_in_p. (fndecl_built_in_p): New. 2018-08-27 Martin Liska <mliska@suse.cz> * gcc-interface/decl.c (update_profile): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. * gcc-interface/gigi.h (call_is_atomic_load): Likewise. * gcc-interface/utils.c (gnat_pushdecl): Likewise. 2018-08-27 Martin Liska <mliska@suse.cz> * c-common.c (check_function_restrict): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. (check_builtin_function_arguments): Likewise. (reject_gcc_builtin): Likewise. * c-warn.c (sizeof_pointer_memaccess_warning): Likewise. 2018-08-27 Martin Liska <mliska@suse.cz> * c-decl.c (locate_old_decl): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. (diagnose_mismatched_decls): Likewise. (merge_decls): Likewise. (warn_if_shadowing): Likewise. (pushdecl): Likewise. (implicitly_declare): Likewise. * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. * c-tree.h (C_DECL_ISNT_PROTOTYPE): Likewise. * c-typeck.c (build_function_call_vec): Likewise. (convert_arguments): Likewise. 2018-08-27 Martin Liska <mliska@suse.cz> * call.c (build_call_a): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. (build_cxx_call): Likewise. * constexpr.c (constexpr_fn_retval): Likewise. (cxx_eval_builtin_function_call): Likewise. (cxx_eval_call_expression): Likewise. (potential_constant_expression_1): Likewise. * cp-gimplify.c (cp_gimplify_expr): Likewise. (cp_fold): Likewise. * decl.c (decls_match): Likewise. (validate_constexpr_redeclaration): Likewise. (duplicate_decls): Likewise. (make_rtl_for_nonlocal_decl): Likewise. * name-lookup.c (consider_binding_level): Likewise. (cp_emit_debug_info_for_using): Likewise. * semantics.c (finish_call_expr): Likewise. * tree.c (builtin_valid_in_constant_expr_p): Likewise. 2018-08-27 Martin Liska <mliska@suse.cz> * go-gcc.cc (Gcc_backend::call_expression): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. 2018-08-27 Martin Liska <mliska@suse.cz> * lto-lang.c (handle_const_attribute): Use new function fndecl_built_in_p and remove check for FUNCTION_DECL if possible. * lto-symtab.c (lto_symtab_merge_p): Likewise. (lto_symtab_merge_decls_1): Likewise. (lto_symtab_merge_symbols): Likewise. * lto.c (lto_maybe_register_decl): Likewise. (read_cgraph_and_symbols): Likewise. From-SVN: r263880
2018-07-31Introduce instance discriminatorsAlexandre Oliva1-1/+1
With -gnateS, the Ada compiler sets itself up to output discriminators for different instantiations of generics, but the middle and back ends have lacked support for that. This patch introduces the missing bits, translating the GNAT-internal representation of the per-file instance map to an instance_table that maps decls to instance discriminators. From: Alexandre Oliva <oliva@adacore.com>, Olivier Hainque <hainque@adacore.com> for gcc/ChangeLog * debug.h (decl_to_instance_map_t): New type. (decl_to_instance_map): Declare. (maybe_create_decl_to_instance_map): New inline function. * final.c (bb_discriminator, last_bb_discriminator): New statics, to track basic block discriminators. (final_start_function_1): Initialize them. (final_scan_insn_1): On NOTE_INSN_BASIC_BLOCK, track bb_discriminator. (decl_to_instance_map): New variable. (map_decl_to_instance, maybe_set_discriminator): New functions. (notice_source_line): Set discriminator. for gcc/ada/ChangeLog * trans.c: Include debug.h. (file_map): New static variable. (gigi): Set it. Create decl_to_instance_map when needed. (Subprogram_Body_to_gnu): Pass gnu_subprog_decl to... (Sloc_to_locus): ... this. Add decl parm, map it to instance. * gigi.h (Sloc_to_locus): Adjust declaration. for gcc/testsuite/ChangeLog * gnat.dg/dinst.adb: New. * gnat.dg/dinst_pkg.ads, gnat.dg/dinst_pkg.adb: New. Co-Authored-By: Olivier Hainque <hainque@adacore.com> From-SVN: r263182
2018-07-17[Ada] Type mismatch warning for imported C++ classEric Botcazou1-5/+1
2018-07-17 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * gcc-interface/ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Define for METHOD_TYPE too. (TYPE_RETURN_UNCONSTRAINED_P): Likewise. (TYPE_CI_CO_LIST): Likewise. * gcc-interface/gigi.h (is_cplusplus_method): Delete. (fntype_same_flags_p): Adjust comment. * gcc-interface/decl.c (Has_Thiscall_Convention): Delete. (gnat_to_gnu_entity) <E_Subprogram_Type>: Do not set the "thiscall" attribute directly. (is_cplusplus_method): Make static and adjust head comment. (gnat_to_gnu_param): Return a pointer for the "this" parameter of C++ constructors. (gnat_to_gnu_subprog_type): Turn imported C++ constructors into their callable form. Generate a METHOD_TYPE node for imported C++ methods. Set param_list at the very end of the processing. (substitute_in_type) <METHOD_TYPE>: New case. * gcc-interface/misc.c (gnat_print_type) <METHOD_TYPE>: Likewise. (gnat_type_hash_eq): Accept METHOD_TYPE. * gcc-interface/trans.c (Identifier_to_gnu): Deal with METHOD_TYPE. (Attribute_to_gnu): Likewise. (Call_to_gnu): Likewise. (process_freeze_entity): Likewise. * gcc-interface/utils.c (create_subprog_decl): Adjust head comment. (fntype_same_flags_p): Likewise. From-SVN: r262792
2018-07-07gigi.h (add_decl_expr): Adjust prototype.Eric Botcazou1-3/+3
* gcc-interface/gigi.h (add_decl_expr): Adjust prototype. * gcc-interface/decl.c (gnat_to_gnu_entity): Remove useless test. * gcc-interface/trans.c (add_stmt_with_node): Remove exceptions. (add_decl_expr): Change type of second parameter and rename it. (renaming_from_instantiation_p): New function moved from... (set_expr_location_from_node): Test for exceptions here and add one for actual subtypes built for unconstrained composite actuals. * gcc-interface/utils.c (renaming_from_instantiation_p): ...here. From-SVN: r262497
2018-06-12ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Change from using TYPE_LANG_FLAG_4 ↵Eric Botcazou1-2/+15
to using TYPE_LANG_FLAG_0. * gcc-interface/ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Change from using TYPE_LANG_FLAG_4 to using TYPE_LANG_FLAG_0. (TYPE_ALIGN_OK): Move around. (TYPE_PADDING_FOR_COMPONENT): Remove superfluous parentheses. * gcc-interface/decl.c (change_qualified_type): Move to... (gnat_to_gnu_entity): Adjust comment. * gcc-interface/gigi.h (change_qualified_type): ...here; make inline. (ceil_pow2): Use ceil_log2. * gcc-interface/utils.c (finish_subprog_decl): Add couple of comments and do not set TREE_SIDE_EFFECTS. (handle_noreturn_attribute): Use change_qualified_type. From-SVN: r261486
2017-12-14gigi.h (pad_type_has_rm_size): Declare.Eric Botcazou1-0/+3
* gcc-interface/gigi.h (pad_type_has_rm_size): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Do not build a padding type for the alignment before validating the size. Flip conditional construct and add a comment. * gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Make sure to apply the exception for padded objects to the type of the object. * gcc-interface/utils.c (hash_pad_type): New static function. (lookup_and_insert_pad_type): Rename into... (canonicalize_pad_type): ...this. Call hash_pad_type, do only one lookup with insertion and always return the canonical type. (maybe_pad_type): Adjust to above changes. Set debug type later. (pad_type_has_rm_size): New predicate. (set_reverse_storage_order_on_pad_type): Adjust to above changes. From-SVN: r255631
2017-10-20sem_dim.adb (Analyze_Dimension_Binary_Op): Accept with a warning to compare ↵Pierre-Marie de Rodat1-2/+2
a dimensioned expression with a literal. gcc/ada/ 2017-10-20 Yannick Moy <moy@adacore.com> * sem_dim.adb (Analyze_Dimension_Binary_Op): Accept with a warning to compare a dimensioned expression with a literal. (Dim_Warning_For_Numeric_Literal): Do not issue a warning for the special value zero. * doc/gnat_ugn/gnat_and_program_execution.rst: Update description of dimensionality system in GNAT. * gnat_ugn.texi: Regenerate. 2017-10-20 Yannick Moy <moy@adacore.com> * sem_ch6.adb (Analyze_Expression_Function.Freeze_Expr_Types): Remove inadequate silencing of errors. * sem_util.adb (Check_Part_Of_Reference): Do not issue an error when checking the subprogram body generated from an expression function, when this is done as part of the preanalysis done on expression functions, as the subprogram body may not yet be attached in the AST. The error if any will be issued later during the analysis of the body. (Is_Aliased_View): Trivial rewrite with Is_Formal_Object. 2017-10-20 Arnaud Charlet <charlet@adacore.com> * sem_ch8.adb (Update_Chain_In_Scope): Add missing [-gnatwu] marker for warning on ineffective use clause. 2017-10-20 Eric Botcazou <ebotcazou@adacore.com> * exp_ch11.ads (Warn_If_No_Local_Raise): Declare. * exp_ch11.adb (Expand_Exception_Handlers): Use Warn_If_No_Local_Raise to issue the warning on the absence of local raise. (Possible_Local_Raise): Do not issue the warning for Call_Markers. (Warn_If_No_Local_Raise): New procedure to issue the warning on the absence of local raise. * sem_elab.adb: Add with and use clauses for Exp_Ch11. (Record_Elaboration_Scenario): Call Possible_Local_Raise in the cases where a scenario could give rise to raising Program_Error. * sem_elab.adb: Typo fixes. * fe.h (Warn_If_No_Local_Raise): Declare. * gcc-interface/gigi.h (get_exception_label): Change return type. * gcc-interface/trans.c (gnu_constraint_error_label_stack): Change to simple vector of Entity_Id. (gnu_storage_error_label_stack): Likewise. (gnu_program_error_label_stack): Likewise. (gigi): Adjust to above changes. (Raise_Error_to_gnu): Likewise. (gnat_to_gnu) <N_Goto_Statement>: Set TREE_USED on the label. (N_Push_Constraint_Error_Label): Push the label onto the stack. (N_Push_Storage_Error_Label): Likewise. (N_Push_Program_Error_Label): Likewise. (N_Pop_Constraint_Error_Label): Pop the label from the stack and issue a warning on the absence of local raise. (N_Pop_Storage_Error_Label): Likewise. (N_Pop_Program_Error_Label): Likewise. (push_exception_label_stack): Delete. (get_exception_label): Change return type to Entity_Id and adjust. * gcc-interface/utils2.c (build_goto_raise): Change type of first parameter to Entity_Id and adjust. Set TREE_USED on the label. (build_call_raise): Adjust calls to get_exception_label and also build_goto_raise. (build_call_raise_column): Likewise. (build_call_raise_range): Likewise. * doc/gnat_ugn/building_executable_programs_with_gnat.rst (-gnatw.x): Document actual default behavior. 2017-10-20 Piotr Trojanek <trojanek@adacore.com> * einfo.ads: Minor consistent punctuation in comment. All numbered items in the comment of Is_Internal are now terminated with a period. 2017-10-20 Piotr Trojanek <trojanek@adacore.com> * exp_util.adb (Build_Temporary): Mark created temporary entity as internal. 2017-10-20 Piotr Trojanek <trojanek@adacore.com> * sem_type.adb (In_Generic_Actual): Simplified. 2017-10-20 Justin Squirek <squirek@adacore.com> * sem_ch12.adb (Check_Formal_Package_Instance): Add sanity check to verify a renaming exists for a generic formal before comparing it to the actual as defaulted formals will not have a renamed_object. 2017-10-20 Javier Miranda <miranda@adacore.com> * exp_ch6.adb (Replace_Returns): Fix wrong management of N_Block_Statement nodes. gcc/testsuite/ 2017-10-20 Justin Squirek <squirek@adacore.com> * gnat.dg/default_pkg_actual.adb, gnat.dg/default_pkg_actual2.adb: New testcases. From-SVN: r253945
2017-09-11gigi.h (enum standard_datatypes): Minor tweak.Eric Botcazou1-1/+2
* gcc-interface/gigi.h (enum standard_datatypes): Minor tweak. (gigi): Likewise. From-SVN: r251974
2017-09-05gigi.h (renaming_from_generic_instantiation_p): Turn toEric Botcazou1-1/+1
* gcc-interface/gigi.h (renaming_from_generic_instantiation_p): Turn to (renaming_from_instantiation_p): ...this. * gcc-interface/decl.c (gnat_to_gnu_entity): Use inline predicate instead of explicit tests on kind of entities. Adjust for renaming. (gnat_to_gnu_profile_type): Likewise. (gnat_to_gnu_subprog_type): Likewise. * gcc-interface/trans.c (Identifier_to_gnu): Likewise. (Case_Statement_to_gnu): Likewise. (gnat_to_gnu): Likewise. (process_freeze_entity): Likewise. (process_type): Likewise. (add_stmt_with_node): Adjust for renaming. * gcc-interface/utils.c (gnat_pushdecl): Adjust for renaming. (renaming_from_generic_instantiation_p): Rename to... (renaming_from_instantiation_p): ...this. Use inline predicate. (pad_type_hasher::keep_cache_entry): Fold. From-SVN: r251700
2017-06-21DWARF: make it possible to emit debug info for declarations onlyPierre-Marie de Rodat1-1/+4
The DWARF back-end used to systematically ignore file-scope function and variable declarations. While this is justified in language like C/C++, where such declarations can appear in several translation units and thus bloat uselessly the debug info, this behavior is counter-productive in languages with a well-defined module system. Specifically, it prevents the description of imported entities, that belong to foreign languages, making them unavailable from debuggers. Take for instance: package C_Binding is function My_C_Function (I : Integer) return Integer; pragma Import (C, My_C_Function, "my_c_function"); end C_Binding; This makes available for Ada programs the C function "my_c_function" under the following name: C_Binding.My_C_Function. When GCC compiles it, though, it is represented as a FUNCTION_DECL node with DECL_EXTERNAL set and a null DECL_INITIAL, which used to be discarded unconditionally in the DWARF back-end. This patch moves such filter from the DWARF back-end to the relevant callers: passes.c:rest_of_decl_compilation and godump.c:go_early_global_decl. It also This patch also updates the Ada front-end to call debug hooks for functions such as in the above example, so that we do generate debugging information for them. gcc/ * dwarf2out.c (gen_decl_die): Remove the guard to skip file-scope FUNCTION_DECL declarations. (dwarf2out_early_global_decl): Remove the guard to skip FUNCTION_DECL declarations. (dwaf2out_decl): Likewise. * godump.c (go_early_global_decl): Skip call to the real debug hook for FUNCTION_DECL declarations. * passes.c (rest_of_decl_compilation): Skip call to the early_global_decl debug hook for FUNCTION_DECL declarations, unless -fdump-go-spec is passed. gcc/ada/ * gcc-interface/ada-tree.h (DECL_FUNCTION_IS_DEF): Update copyright notice. New macro. * gcc-interface/trans.c (Subprogram_Body_to_gnu): Tag the subprogram as a definition. (Compilation_Unit_to_gnu): Tag the elaboration procedure as a definition. * gcc-interface/decl.c (gnat_to_gnu_entity): Tag declarations of imported subprograms for the current compilation unit as definitions. Disable debug info for references to variables. * gcc-interface/gigi.h (create_subprog_decl): Update declaration. * gcc-interface/utils.c (gnat_pushdecl): Add external DECLs that are not built-in functions to their binding scope. (create_subprog_decl): Add a DEFINITION parameter. If it is true, tag the function as a definition. Update all callers. (gnat_write_global_declarations): Emit debug info for imported functions. Filter out external variables for which debug info is disabled. gcc/testsuite/ * gnat.dg/debug11_pkg.adb, gnat.dg/debug11_pkg.ads, gnat.dg/debug11_pkg2.ads: New testcase. From-SVN: r249449
2017-05-15gigi.h (get_elaboration_procedure): Delete.Eric Botcazou1-4/+1
* gcc-interface/gigi.h (get_elaboration_procedure): Delete. * gcc-interface/trans.c (get_elaboration_procedure): Make static. From-SVN: r248055
2017-05-15trans.c (gnat_to_gnu): Fix formatting.Eric Botcazou1-7/+4
* gcc-interface/trans.c (gnat_to_gnu) <N_Aggregate>: Fix formatting. <N_Allocator>: Use properly typed constants. (extract_values): Move around. (pos_to_constructor): Minor tweaks. (Sloc_to_locus): Fix formatting. * gcc-interface/utils.c (process_deferred_decl_context): Minor tweaks. * gcc-interface/gigi.h (MARK_VISITED): Remove blank line. (Gigi_Equivalent_Type): Adjust head comment. * gcc-interface/decl.c (Gigi_Equivalent_Type): Likewise. From-SVN: r248050
2016-10-11exp_dbug.adb (Debug_Renaming_Declaration): Process underlying types.Pierre-Marie de Rodat1-0/+5
* exp_dbug.adb (Debug_Renaming_Declaration): Process underlying types. Emit GNAT encodings for object renamings involving record components whose normalized bit offset is not null. * uintp.h (UI_No_Uint): Declare. * gcc-interface/gigi.h (can_materialize_object_renaming_p): New. * gcc-interface/utils.c (can_materialize_object_renaming_p): New function. * gcc-interface/trans.c (gnat_to_gnu) <N_Object_Renaming_Declaration>: In code generation mode, materialize all renamings as long as they need debug info and we are not optimizing. From-SVN: r240985
2016-10-11utils2.c (build_binary_op): Add a NO_FOLD argument.Pierre-Marie de Rodat1-6/+4
* gcc-interface/utils2.c (build_binary_op): Add a NO_FOLD argument. Disable folding when true. * gcc-interface/gigi.h (choices_to_gnu): Remove declaration. (build_binary_op): Update signature and comment. * gcc-interface/decl.c (choices_to_gnu): Make static. Disable folding for all calls to build_binary_op. From-SVN: r240978
2016-06-29re PR ada/48835 (porting GNAT to m68k-linux)Eric Botcazou1-3/+6
PR ada/48835 PR ada/61954 * gcc-interface/gigi.h (enum standard_datatypes): Add ADT_realloc_decl (realloc_decl): New macro. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Use local variable for the entity type and translate it as void pointer if the entity has convention C. (gnat_to_gnu_entity) <E_Function>: If this is not a definition and the external name matches that of malloc_decl or realloc_decl, return the correspoding node directly. (gnat_to_gnu_subprog_type): Likewise for parameter and return types. * gcc-interface/trans.c (gigi): Initialize void_list_node here, not... Initialize realloc_decl. * gcc-interface/utils.c (install_builtin_elementary_types): ...here. (build_void_list_node): Delete. * gcc-interface/utils2.c (known_alignment) <CALL_EXPR>: Return the alignment of the system allocator for malloc_decl and realloc_decl. Do not take alignment from void pointer types either. From-SVN: r237850
2016-06-06gigi.h (finish_subprog_decl): Add ASM_NAME parameter.Eric Botcazou1-3/+3
* gcc-interface/gigi.h (finish_subprog_decl): Add ASM_NAME parameter. * gcc-interface/decl.c (gnu_ext_name_for_subprog): New function. (gnat_to_gnu_entity) <E_Subprogram_Type>: Do not check compatibility of profiles for builtins here... Call gnu_ext_name_for_subprog. Also update profiles if pointers to limited_with'ed types are updated. (gnat_to_gnu_param): Restore the correct source location information for vector ABI warnings. (associate_subprog_with_dummy_type): Add comment about AI05-019. Set TYPE_DUMMY_IN_PROFILE_P flag unconditionally. (update_profile): Deal with builtin declarations. Call gnu_ext_name_for_subprog. Adjust call to finish_subprog_decl. (update_profiles_with): Add comment. (gnat_to_gnu_subprog_type): Reuse the return type if it is complete. Likewise for parameter declarations in most cases. Do not change the return type for the CICO mechanism if the profile is incomplete. ...but here instead. Always reset the slot for the parameters. * gcc-interface/utils.c (create_subprog_decl): Call gnu_ext_name_for_subprog. Do not set the assembler name here but... (finish_subprog_decl): ...but here instead. Add ASM_NAME parameter. From-SVN: r237119
2016-05-16* doc/gnat_rm/implementation_defined_attributes.rstEric Botcazou1-3/+5
(Scalar_Storage_Order): Adjust restriction for packed array types. * einfo.ads (Is_Bit_Packed_Array): Adjust description. (Is_Packed): Likewise. (Is_Packed_Array_Impl_Type): Likewise. (Packed_Array_Impl_Type): Likewise. * exp_ch4.adb (Expand_N_Indexed_Component): Do not do anything special if the prefix is not a packed array implemented specially. * exp_ch6.adb (Expand_Actuals): Expand indexed components only for bit-packed array types. * exp_pakd.adb (Install_PAT): Set Is_Packed_Array_Impl_Type flag on the PAT before analyzing its declaration. (Create_Packed_Array_Impl_Type): Remove redundant statements. * freeze.adb (Check_Component_Storage_Order): Reject packed array components only if they are bit packed. (Freeze_Array_Type): Fix logic detecting bit packing and do not bit pack for composite types whose size is multiple of a byte. Create the implementation type for packed array types only when it is needed, i.e. bit packing or packing because of holes in index types. Make sure the Has_Non_Standard_Rep and Is_Packed flags agree. * gcc-interface/gigi.h (make_packable_type): Add MAX_ALIGN parameter. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Signed_Integer_Subtype>: Call maybe_pad_type instead of building the padding type manually. (gnat_to_gnu_entity) <E_Array_Subtype>: Do not assert that Packed_Array_Impl_Type is present for packed arrays. (gnat_to_gnu_component_type): Also handle known alignment for packed types by passing it to make_packable_type. * gcc-interface/utils.c (make_packable_type): Add MAX_ALIGN parameter and deal with it in the array case. Adjust recursive call. Simplify computation of new size and cap the alignment to BIGGEST_ALIGNMENT. From-SVN: r236279
2016-04-27sem_aux.adb (Is_By_Reference_Type): Also return true for a tagged incomplete ↵Eric Botcazou1-27/+15
type without full view. * sem_aux.adb (Is_By_Reference_Type): Also return true for a tagged incomplete type without full view. * sem_ch6.adb (Exchange_Limited_Views): Change into a function and return the list of changes. (Restore_Limited_Views): New procedure to undo the transformation made by Exchange_Limited_Views. (Analyze_Subprogram_Body_Helper): Adjust call to Exchange_Limited_Views and call Restore_Limited_Views at the end, if need be. (Possible_Freeze): Do not delay freezing because of incomplete types. (Process_Formals): Remove kludges for class-wide types. * types.h (By_Copy_Return): Delete. * gcc-interface/ada-tree.h (TYPE_MAX_ALIGN): Move around. (TYPE_DUMMY_IN_PROFILE_P): New macro. * gcc-interface/gigi.h (update_profiles_with): Declare. (finish_subprog_decl): Likewise. (get_minimal_subprog_decl): Delete. (create_subprog_type): Likewise. (create_param_decl): Adjust prototype. (create_subprog_decl): Likewise. * gcc-interface/decl.c (defer_limited_with): Rename into... (defer_limited_with_list): ...this. (gnat_to_gnu_entity): Adjust to above renaming. (finalize_from_limited_with): Likewise. (tree_entity_vec_map): New structure. (gt_pch_nx): New helpers. (dummy_to_subprog_map): New hash table. (gnat_to_gnu_param): Set the SLOC here. Remove MECH parameter and add FIRST parameter. Deal with the mechanism here instead of... Do not make read-only variant of types. Simplify expressions. In the by-ref case, test the mechanism before must_pass_by_ref and also TYPE_IS_BY_REFERENCE_P before building the reference type. (gnat_to_gnu_subprog_type): New static function extracted from... Do not special-case the type_annotate_only mode. Call gnat_to_gnu_profile_type instead of gnat_to_gnu_type on return type. Deal with dummy return types. Likewise for parameter types. Deal with by-reference types explicitly and add a kludge for null procedures with untagged incomplete types. Remove assertion on the types and be prepared for multiple elaboration of the declarations. Skip the whole CICO processing if the profile is incomplete. Handle the completion of a previously incomplete profile. (gnat_to_gnu_entity) <E_Variable>: Rename local variable. Adjust couple of calls to create_param_decl. <E_Access_Subprogram_Type, E_Anonymous_Access_Subprogram_Type>: Remove specific deferring code. <E_Access_Type>: Also deal with E_Subprogram_Type designated type. Simplify handling of dummy types and remove obsolete comment. Constify a couple of variables. Do not set TYPE_UNIVERSAL_ALIASING_P on dummy types. <E_Access_Subtype>: Tweak comment and simplify condition. <E_Subprogram_Type>: ...here. Call it and clean up handling. Remove obsolete comment and adjust call to gnat_to_gnu_param. Adjust call to create_subprog_decl. <E_Incomplete_Type>: Add a couple of 'const' qualifiers and get rid of inner break statements. Tidy up condition guarding direct use of the full view. (get_minimal_subprog_decl): Delete. (finalize_from_limited_with): Call update_profiles_with on dummy types with TYPE_DUMMY_IN_PROFILE_P set. (is_from_limited_with_of_main): Delete. (associate_subprog_with_dummy_type): New function. (update_profile): Likewise. (update_profiles_with): Likewise. (gnat_to_gnu_profile_type): Likewise. (init_gnat_decl): Initialize dummy_to_subprog_map. (destroy_gnat_decl): Destroy dummy_to_subprog_map. * gcc-interface/misc.c (gnat_get_alias_set): Add guard for accessing TYPE_UNIVERSAL_ALIASING_P. (gnat_get_array_descr_info): Minor tweak. * gcc-interface/trans.c (gigi): Adjust calls to create_subprog_decl. (build_raise_check): Likewise. (Compilation_Unit_to_gnu): Likewise. (Identifier_to_gnu): Accept mismatches coming from a limited context. (Attribute_to_gnu): Remove kludge for dispatch table entities. (process_freeze_entity): Do not retrieve old definition if there is an address clause on the entity. Call update_profiles_with on dummy types with TYPE_DUMMY_IN_PROFILE_P set. * gcc-interface/utils.c (build_dummy_unc_pointer_types): Also set TYPE_REFERENCE_TO to the fat pointer type. (create_subprog_type): Delete. (create_param_decl): Remove READONLY parameter. (finish_subprog_decl): New function extracted from... (create_subprog_decl): ...here. Call it. Remove CONST_FLAG and VOLATILE_FLAG parameters and adjust. (update_pointer_to): Also clear TYPE_REFERENCE_TO in the unconstrained case. From-SVN: r235521
2016-04-27gigi.h (gnat_to_gnu_entity): Adjust prototype.Eric Botcazou1-13/+11
* gcc-interface/gigi.h (gnat_to_gnu_entity): Adjust prototype. (maybe_pad_type): Adjust comment. (finish_record_type): Likewise. (rest_of_record_type_compilation): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity): Change DEFINITION type parameter from integer to boolean. Adjust recursive calls. <E_Subprogram_Type>: Use copy_type and remove redundant assignments. <E_Signed_Integer_Subtype>: Adjust comment. Remove call to rest_of_record_type_compilation. Set TYPE_PADDING_P flag earlier. Pass false to finish_record_type. Set the debug type later. <E_Record_Subtype>: Remove call to rest_of_record_type_compilation. (gnat_to_gnu_component_type): Fix formatting. (gnat_to_gnu_field_decl): Adjust call to gnat_to_gnu_entity. (gnat_to_gnu_type): Likewise. * gcc-interface/trans.c (Identifier_to_gnu): Likewise. (Loop_Statement_to_gnu): Likewise. (Subprogram_Body_to_gnu): Likewise. (Exception_Handler_to_gnu_fe_sjlj): Likewise. (Exception_Handler_to_gnu_gcc): Likewise. (Compilation_Unit_to_gnu): Likewise. (gnat_to_gnu): Likewise. (push_exception_label_stack): Likewise. (elaborate_all_entities_for_package): Likewise. (process_freeze_entity): Likewise. (process_decls): Likewise. (process_type): Likewise. * gcc-interface/utils.c (struct deferred_decl_context_node): Tweak. (maybe_pad_type): Adjust comments. Set the debug type later. Remove call to rest_of_record_type_compilation. (rest_of_record_type_compilation): Use copy_type. (copy_type): Use correctly typed constants. (gnat_signed_or_unsigned_type_for): Use copy_type. * gcc-interface/utils2.c (nonbinary_modular_operation): Likewise. (build_goto_raise): Adjust call tognat_to_gnu_entity. From-SVN: r235479
2016-02-29ada-tree.h (DECL_RETURN_VALUE_P): New macro.Eric Botcazou1-6/+8
* gcc-interface/ada-tree.h (DECL_RETURN_VALUE_P): New macro. * gcc-interface/gigi.h (gigi): Remove useless attribute. (gnat_gimplify_expr): Likewise. (gnat_to_gnu_external): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Factor out code dealing with the expression of external constants into... Invoke gnat_to_gnu_external instead. <E_Variable>: Invoke gnat_to_gnu_external to translate renamed objects when not for a definition. Deal with COMPOUND_EXPR and variables with DECL_RETURN_VALUE_P set for renamings and with the case of a dangling 'reference to a function call in a renaming. Remove obsolete test and adjust associated comment. * gcc-interface/trans.c (Call_to_gnu): Set DECL_RETURN_VALUE_P on the temporaries created to hold the return value, if any. (gnat_to_gnu_external): ...this. New function. * gcc-interface/utils.c (create_var_decl): Detect a constant created to hold 'reference to function call. * gcc-interface/utils2.c (build_unary_op) <ADDR_EXPR>: Add folding for COMPOUND_EXPR in the DECL_RETURN_VALUE_P case. From-SVN: r233804
2016-02-16gigi.h (maybe_debug_type): New inline function.Eric Botcazou1-0/+11
* gcc-interface/gigi.h (maybe_debug_type): New inline function. * gcc-interface/misc.c (gnat_get_array_descr_info): Use it. Call maybe_character_value on the array bounds. Get to the base type of the index type and call maybe_debug_type on it. * gcc-interface/utils.c (finish_character_type): Add special treatment From-SVN: r233469
2016-01-28gigi.h (enum attr_type): Rename into...Eric Botcazou1-2/+2
* gcc-interface/gigi.h (enum attr_type): Rename into... (enum attrib_type): ...this. (struct attrib): Adjust. * gcc-interface/decl.c (prepend_one_attribute): Likewise. From-SVN: r232923
2016-01-20exp_ch2.adb (Expand_Current_Value): Make an appropriate character literal if ↵Eric Botcazou1-0/+30
the entity is of a character type. * exp_ch2.adb (Expand_Current_Value): Make an appropriate character literal if the entity is of a character type. * gcc-interface/lang.opt (fsigned-char): New option. * gcc-interface/misc.c (gnat_handle_option): Accept it. (gnat_init): Adjust comment. * gcc-interface/gigi.h (finish_character_type): New prototype. (maybe_character_type): New inline function. (maybe_character_value): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Enumeration_Type>: For a character of CHAR_TYPE_SIZE, make a signed type if flag_signed_char. Set TYPE_ARTIFICIAL early and call finish_character_type on the type. <E_Enumeration_Subtype>: For a subtype of character with RM_Size and Esize equal to CHAR_TYPE_SIZE, make a signed type if flag_signed_char. Copy TYPE_STRING_FLAG from type to subtype. <E_Array_Type>: Deal with character index types. <E_Array_Subtype>: Likewise. * gcc-interface/trans.c (gigi): Replace unsigned_char_type_node with char_type_node throughout. (build_raise_check): Likewise. (get_type_length): Deal with character types. (Attribute_to_gnu) <Attr_Pos>: Likewise. Remove obsolete range check code. Minor tweak. <Attr_Pred>: Likewise. (Loop_Statement_to_gnu): Likewise. (Raise_Error_to_gnu): Likewise. <N_Indexed_Component>: Deal with character index types. Remove obsolete code. <N_Slice>: Likewise. <N_Type_Conversion>: Deal with character types. Minor tweak. <N_Unchecked_Type_Conversion>: Likewise. <N_In>: Likewise. <N_Op_Eq>: Likewise. (emit_index_check): Delete. * gcc-interface/utils.c (finish_character_type): New function. (gnat_signed_or_unsigned_type_for): Deal with built-in character types. * gcc-interface/utils2.c (expand_sloc): Replace unsigned_char_type_node with char_type_node. (build_call_raise): Likewise. (build_call_raise_column): Likewise. (build_call_raise_range): Likewise. From-SVN: r232604
2016-01-18gigi.h (build_call_raise_column): Adjust prototype.Eric Botcazou1-8/+22
* gcc-interface/gigi.h (build_call_raise_column): Adjust prototype. (build_call_raise_range): Likewise. (gnat_unsigned_type): Delete. (gnat_signed_type): Likewise. (gnat_signed_or_unsigned_type_for): New prototype. (gnat_unsigned_type_for): New inline function. (gnat_signed_type_for): Likewise. * gcc-interface/cuintp.c (build_cst_from_int): Call build_int_cst. * gcc-interface/decl.c (gnat_to_gnu_entity): Likewise. (gnat_to_gnu_entity) <E_Array_Type>: Always translate the index types and compute their base type from that. <E_Array_Subtype>: Remove duplicate declaration. * gcc-interface/misc.c (get_array_bit_stride): Call build_int_cst. * gcc-interface/trans.c (get_type_length): Likewise. (Attribute_to_gnu): Likewise. (Loop_Statement_to_gnu): Likewise. (Call_to_gnu): Likewise. (gnat_to_gnu): Call build_real, build_int_cst, gnat_unsigned_type_for and gnat_signed_type_for. Minor tweaks. (build_binary_op_trapv): Likewise. (emit_check): Likewise. (convert_with_check): Likewise. (Raise_Error_to_gnu): Adjust calls to the build_call_raise family of functions. Minor tweaks. (Case_Statement_to_gnu): Remove dead code. (gnat_to_gnu): Call gnat_unsigned_type_for and gnat_signed_type_for. (init_code_table): Minor reordering. * gcc-interface/utils.c (gnat_unsigned_type): Delete. (gnat_signed_type): Likewise. (gnat_signed_or_unsigned_type_for): New function. (unchecked_convert): Use directly the size in the test for precision vs size adjustments. (install_builtin_elementary_types): Call gnat_signed_type_for. * gcc-interface/utils2.c (nonbinary_modular_operation): Call build_int_cst. (build_goto_raise): New function taken from... (build_call_raise): ...here. Call it. (build_call_raise_column): Add KIND parameter and call it. (build_call_raise_range): Likewise. From-SVN: r232503
2015-12-10gigi.h (create_var_decl): Adjust comment.Eric Botcazou1-6/+12
* gcc-interface/gigi.h (create_var_decl): Adjust comment. (create_subprog_decl): Likewise. * gcc-interface/utils.c (create_var_decl): Likewise. (create_subprog_decl): Likewise. From-SVN: r231511
2015-11-30gigi.h (create_var_decl): Adjust prototype.Eric Botcazou1-5/+9
* gcc-interface/gigi.h (create_var_decl): Adjust prototype. (create_subprog_decl): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Rename static_p into static_flag and add volatile_flag local variable. Do not locally change the type of a volatile object, except for the pointed-to type if the object is handled by reference. Adjust calls to create_var_decl. <E_Subprogram_Type>: Likewise for const and noreturn subprograms. (get_minimal_subprog_decl): Adjust call to create_subprog_decl. (elaborate_expression_1): Adjust call to create_var_decl. (gnat_to_gnu_field): Minor tweak. * gcc-interface/trans.c (gigi): Adjust calls to create_var_decl and create_subprog_decl. (build_raise_check): Likewise. (Subprogram_Body_to_gnu): Likewise. (create_temporary): Likewise. (Handled_Sequence_Of_Statements_to_gnu): Likewise. (Exception_Handler_to_gnu_gcc): Likewise. (Compilation_Unit_to_gnu): Likewise. (gnat_to_gnu): Likewise. * gcc-interface/utils.c (maybe_pad_type): Likewise. (create_var_decl): Add VOLATILE_FLAG parameter and handle it. (create_subprog_decl): Add CONST_FLAG and VOLATILE_FLAG parameters and handle them. From-SVN: r231065
2015-11-30gigi.h (is_simple_additive_expression): Declare.Eric Botcazou1-0/+6
* gcc-interface/gigi.h (is_simple_additive_expression): Declare. * gcc-interface/trans.c (struct range_check_info_d): Add DISP and NEG_P fields. (find_loop_for): Add DISP and NEG_P parameters with default value. Call is_simple_additive_expression to handle additive expressions. (Loop_Statement_to_gnu): Deal with displacement in range checks. (Raise_Error_to_gnu): Likewise. (gnat_to_gnu): Add call to find_loop_for. (is_simple_additive_expression): New function extracted from... (gnat_invariant_expr): ...here. Call it on the expression. From-SVN: r231064
2015-11-18ada-tree.h (DECL_INVARIANT_P): New macro.Eric Botcazou1-15/+12
* gcc-interface/ada-tree.h (DECL_INVARIANT_P): New macro. * gcc-interface/gigi.h (enum standard_datatypes): Remove ADT_longjmp_decl and add ADT_not_handled_by_others_decl. (longjmp_decl): Delete. (not_handled_by_others_decl): New macro. (build_simple_component_ref): Delete. (build_component_ref): Adjust prototype. * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust calls to build_component_ref. (gnat_to_gnu_field): Set DECL_INVARIANT_P on discriminants without default value. * gcc-interface/trans.c (gigi): Reorder initialization sequence and add not_handled_by_others_decl. (Attribute_to_gnu): Adjust calls to build_component_ref. (Subprogram_Body_to_gnu): Likewise. (Call_to_gnu): Likewise. (Exception_Handler_to_gnu_sjlj): Likewise. (gnat_to_gnu): Likewise. (range_check_info_d): Add inserted_cond field. (Loop_Statement_to_gnu): Make two passes on the recorded range checks. (build_noreturn_cond): New static function. (Raise_Error_to_gnu): Record range checks in loops at -O1 and above. (make_invariant): New static function. (Loop_Statement_to_gnu): Use it to compute invariant expressions for the loop bounds if possible, but do not require it if loop unswitching is enabled. * gcc-interface/utils.c (convert_to_fat_pointer): Likewise. (convert): Likewise. (maybe_unconstrained_array): Likewise. Call it instead of build_simple_component_ref and add guard for CONSTRUCTORs. (unchecked_convert): Likewise. * gcc-interface/utils2.c (compare_fat_pointers): Likewise. (build_simple_component_ref): Remove COMPONENT parameter, unify code dealing with VIEW_CONVERT_EXPR and make it more general, remove special treatment for CONSTRUCTORs of template types. (build_component_ref): Remove COMPONENT parameter and adjust call to build_simple_component_ref. (maybe_wrap_malloc): Likewise. (build_allocator): Likewise. (gnat_invariant_expr): Look through overflow checks, deal with addition and subtraction of constants and take into account DECL_INVARIANT_P for the COMPONENT_REF case. From-SVN: r230575
2015-11-12decl.c (gnat_to_gnu_entity): Create IMPORTED_DECL nodes to describe the ↵Arnaud Charlet1-0/+5
subprogram renamings which are... 2015-11-12 Pierre-Marie de Rodat <derodat@adacore.com> * gcc-interface/decl.c (gnat_to_gnu_entity): Create IMPORTED_DECL nodes to describe the subprogram renamings which are relevant at debug time. * gcc-interface/gigi.h (get_debug_scope): Add declaration. * gcc-interface/trans.c (Identifier_to_gnu): Consider N_Defining_Operator_Symbol as valid entities. (gnat_to_gnu): Handle N_Defining_Operator_Symbol the same way as other entities. Introduce a specific handling for N_Subprogram_Renaming_Declaration: call gnat_to_gnu_entity on the entity defined for relevant ones. (process_decls): Process subprogram renaming declarations during the second pass only. * gcc-interface/utils.c (get_debug_scope): Make it external. Consider N_Defining_Operator_Symbol as valid entities. (gnat_write_global_declarations): Output debugging information for top-level imported declarations. * gcc-interface/Makefile.in: Fix typo. From-SVN: r230227
2015-11-08Merge of the scalar-storage-order branch.Eric Botcazou1-0/+3
From-SVN: r229965
2015-09-14gigi.h (ref_filename): Delete.Eric Botcazou1-21/+15
* gcc-interface/gigi.h (ref_filename): Delete. (Sloc_to_locus): Add clean_column parameter defaulting to false. (build_call_raise): Adjust comment. (build_call_raise_range): Move around. * gcc-interface/trans.c (ref_filename): Delete. (gigi): Fix formatting. (block_end_locus_sink): Delete. (Sloc_to_locus1): Tidy up and reformat. Rename into... (Sloc_to_locus): ...this. Add default for clean_colmun parameter. (set_expr_location_from_node1): Rename into... (set_expr_location_from_node): ...this. (set_end_locus_from_node): Move around. Adjust for renaming. (Handled_Sequence_Of_Statements_to_gnu): Likewise. (add_cleanup): Likewise. * gcc-interface/utils2.c (expand_sloc): New static function. (build_call_raise): Call it. (build_call_raise_column): Likewise. (build_call_raise_range): Likewise. Move around. From-SVN: r227736
2015-06-26gigi.h (note_types_used_by_globals): Delete.Eric Botcazou1-3/+2
* gcc-interface/gigi.h (note_types_used_by_globals): Delete. (gnat_write_global_declarations): New prototype. * gcc-interface/utils.c (type_decls): Rename back to... (global_decls): ...this. (gnat_pushdecls): Revert previous change. (create_var_decl): Do not output global variables. (note_types_used_by_globals): Rename back to... (gnat_write_global_declarations): ...this. Output variables on the global_decls vector. * gcc-interface/misc.c (gnat_parse_file): Adjust to above renaming. From-SVN: r225003
2015-06-26gigi.h (create_var_decl_1): Rename into...Eric Botcazou1-53/+40
* gcc-interface/gigi.h (create_var_decl_1): Rename into... (create_var_decl): ...this. Add default value for last parameter. (create_type_stub_decl): Adjust. (create_type_decl): Likewise. (create_field_decl): Likewise. (create_param_decl): Likewise. (create_label_decl): Likewise. (create_subprog_decl): Likewise. * gcc-interface/utils.c (create_var_decl_1): Rename into... (create_var_decl): ...this. Rename var_name into name and var_init into init, move const_decl_allowed_p last and adjust accordingly. (create_type_stub_decl): Rename type_name into name and adjust. (create_type_decl): Likewise. (create_field_decl): Likewise for field_name and field_type. (create_param_decl): Likewise for param_name and param_type. (create_label_decl): Likewise for label_name. (create_subprog_decl): Likewise for subprog_name and subprog_type. * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust couple of calls to create_var_decl_1. From-SVN: r225002
2015-06-19gigi.h (record_builtin_type): Adjust comment.Eric Botcazou1-24/+25
* gcc-interface/gigi.h (record_builtin_type): Adjust comment. (tree create_type_decl): Likewise. (create_var_decl_1): Add artificial_p and debug_info_p parameters. (create_var_decl): Likewise. (create_true_var_decl): Delete. (create_subprog_decl): Add debug_info_p parameter. * gcc-interface/decl.c (gnat_to_gnu_entity): Add artificial_p local variable and use it throughout. Remove DECL_ARTIFICIAL settings. <E_Variable>: Adjust calls to create_var_decl and create_var_decl_1. Remove DECL_IGNORED_P settings. <E_Enumeration_Type>: Likewise. <E_Record_Type>: Likewise. <E_Subprogram_Type>: Likewise. Remove artificial_flag local variable. Adjust call to create_subprog_decl. (get_minimal_subprog_decl): Likewise. (elaborate_expression_1): Adjust call to create_var_decl. * gcc-interface/trans.c (gigi): Adjust calls to create_var_decl and create_subprog_decl. Remove DECL_ARTIFICIAL & DECL_IGNORED_P settings. * gcc-interface/utils.c (maybe_pad_type): Likewise. (record_builtin_type): Adjust comment. (create_type_stub_decl): Remove obsolete comment. (create_var_decl_1): Add artificial_p and debug_info_p parameters. Set DECL_ARTIFICIAL and DECL_IGNORED_P accordingly. (create_subprog_decl): Add debug_info_p parameter. Set DECL_IGNORED_P accordingly. From-SVN: r224699
2015-06-05Merge debug-early branch into mainline.Aldy Hernandez1-2/+3
* dwarf2out.c: Remove deferred_locations*. (dwarf2_debug_hooks): Add early_finish hook. Remove global_decl hook. Add early_global_decl and late_global_decl hook. New global early_dwarf. New structure set_early_dwarf. (output_die): Indicate whether a DIE was generated early when generating assembly with -dA. (struct limbo_die_struct): Document created_for field. Remove file_table_last_lookup. (remove_AT): Return TRUE if successful. (remove_child_TAG): Clear die_parent. (reparent_child): New function abstracted from... (splice_child_die): ...here. (new_die): ICE if a DIE ends up in limbo too late. (check_die): New. (defer_location): Remove. (add_subscript_info): Reuse DW_TAG_subrange_type if available. (fill_variable_array_bounds): New. (decl_start_label): Call fill_variable_array_bounds. (gen_formal_parameter_die): Rewrite to reuse previously generated DIEs. (gen_subprogram_die): Same. (gen_variable_die): Same. (gen_const_die): Same. (gen_label_die): Same. (gen_lexical_block_die): Same. (decl_will_get_specification_p): New. (local_function_static): New. (gen_struct_or_union_type_die): Fill in variable-length fields. (gen_typedef_die): Fill in variable-length typedefs. (gen_tagged_type_die): Gracefully return on error_mark_node. Handle re-entrancy. (gen_type_die_with_usage): Handle variable-length types. Remove duplicate code for ARRAY_TYPE case. (process_scope_var): Only process imported modules during early dwarf. (dwarf2out_early_global_decl): New. (dwarf2out_late_global_decl): Rename from dwarf2out_global_decl. (dwarf2out_type_decl): Set early_dwarf while calling dwarf2out_decl. (dwarf2out_decl): Verify that we did not recreate a previously generated DIE. Do not return on DECL_EXTERNALs in VAR_DECLs. Abstract some code to local_function_static. (lookup_filename): Remove use of file_table_last_lookup. Gracefully exit on missing file_name. (dwarf2out_finish): Verify limbo list. Remove deferred_locations_list use. Move deferred_asm_name and limbo flushing to... (dwarf2out_early_finish): ...here. New. (dwarf2out_c_finalize): Remove set of deferred_location_list, deferred_asm_name, and file_table_last_lookup. * cgraph.h (referred_to_p): Add default argument. * cgraphunit.c (referred_to_p): Add and handle include_self argument. (analyze_functions): Add first_time argument. Call check_global_declaration for all symbols. Call late_global_decl for nodes for moribund nodes. (finalize_compilation_unit): Add new argument to analyze_functions. Call early_global_decl for functions. Call early_finish debug hook. * dbxout.c (dbxout_early_global_decl): New. (dbxout_late_global_decl): New. Adapted from dbxout_global_decl. (dbx_debug_hooks): Add new hooks. (xcoff_debug_hooks): Same. * debug.c (do_nothing_debug_hooks): Add early_finish field. Add early and late debug hooks. Remove global_decl hook. * debug.h (struct gcc_debug_hooks): Add early_finish, early_global_decl, and late_global_decl fields. Remove global_decl field. Document gcc_debug_hooks. * gengtype.c (output_typename): Remove. * godump.c (go_early_global_decl): New. (go_late_global_decl): New. (go_global_decl): Remove. (dump_go_spec_init): Remove global_decl. Add {early,late}_global_decl. * langhooks-def.h (LANG_HOOKS_WRITE_GLOBALS): Remove. (LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): New. * langhooks.c (lhd_warn_unused_global_decl): Adjust comment. (write_global_declarations): Remove. (global_decl_processing): New. * langhooks.h (struct lang_hooks_for_decls): Remove final_write_globals field. Add post_compilation_parsing_cleanups field. * passes.c (rest_of_decl_compilation): Call early_global_decl. * sdbout.c: Add early and late_global_decl hooks. Remove sdbout_global_decl hook. Add early_finish field for sdb_debug_hooks. (sdbout_global_decl): Remove. (sdbout_early_global_decl): New. (sdbout_late_global_decl): New. * timevar.def (TV_PHASE_LATE_PARSING_CLEANUPS): New. * toplev.c (check_global_declaration): Rename from check_global_declaration_1. Adapt to use symtab infrastructure. (check_global_declarations): Remove. (emit_debug_global_declarations): Remove. (compile_file): Remove call to final_write_globals langhook. Run the actual compilation process. Perform any post compilation parser cleanups. Generate late debug info. * toplev.h (check_global_declaration): New. (check_global_declaration_1): Remove. (check_global_declarations): Remove. (write_global_declarations): Remove. (emit_debug_global_declarations): Remove. (global_decl_processing): New. * tree-core.h (struct tree_block): Add DIE field. * tree.h (BLOCK_DIE): New. * vmsdbgout.c (vmsdbgout_global_decl): Remove function and its use throughout. (vmsdbgout_early_global_decl): New. (vmsdbgout_late_global_decl): New. Add early_finish debug hook field to vmsdbg_debug_hooks. Remove vmsdbgout_decl to vmsdbgout_function_decl. Add early and late_global_decl debug hooks. From-SVN: r224161
2015-06-01gigi.h (build_simple_component_ref): Declare.Eric Botcazou1-0/+5
* gcc-interface/gigi.h (build_simple_component_ref): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Deal with address clause on aliased object with unconstrained nominal subtype. Mark the aligning variable as artificial, do not convert the address expression immediately but mark it as constant instead. * gcc-interface/utils.c (convert): If the target type contains a template, be prepared for an empty array. (maybe_unconstrained_array): Likewise. * gcc-interface/utils2.c (known_alignment) <POINTER_PLUS_EXPR>: Deal with the pattern built for aligning types. <INTEGER_CST>: Do not cap the value at BIGGEST_ALIGNMENT. (build_simple_component_ref): Make public. If the base object is a constructor that contains a template, fold the result field by field. From-SVN: r223912