aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
AgeCommit message (Collapse)AuthorFilesLines
2020-12-07Fix assembler name collisionEric Botcazou1-1/+1
Gigi uses a dummy global variable to register global types for debug info purposes and its name can now collide with user variables. gcc/ada/ChangeLog: * gcc-interface/trans.c (lvalue_for_aggregate_p): Also return true for return statements. * gcc-interface/utils.c (gnat_write_global_declarations): Use the maximum index for the dummy object to avoid a name collision.
2020-12-07Fix problematic conversion to boolean typeEric Botcazou1-7/+9
The new ranger exposed a problematic conversion to boolean type. gcc/ada/ChangeLog: * gcc-interface/utils.c (convert) <INTEGER_TYPE>: Call fold_convert in the cases where convert_to_integer is not called. <BOOLEAN_TYPE>: Call fold_convert instead of convert_to_integer.
2020-11-11Remove superfluous call to Base_TypeEric Botcazou1-31/+31
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-11-11Fix internal error with Shift_Right operator on signed typeEric Botcazou1-1/+1
This is a regression present on the mainline and 10 branch in the form of an ICE with a shift operator applied to a variable of a signed type, and which is caused by a type mismatch. gcc/ada/ChangeLog: * gcc-interface/trans.c (gnat_to_gnu) <N_Op_Shift>: Also convert GNU_MAX_SHIFT if the type of the operation has been changed. * gcc-interface/utils.c (can_materialize_object_renaming_p): Add pair of missing parentheses. gcc/testsuite/ChangeLog: * gnat.dg/shift1.adb: New test.
2020-10-22Implement no_stack_protector attribute.Martin Liska1-1/+30
gcc/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * cfgexpand.c (stack_protect_decl_phase): Guard with lookup_attribute("no_stack_protector") at various places. (expand_used_vars): Likewise here. * doc/extend.texi: Document no_stack_protector attribute. gcc/ada/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * gcc-interface/utils.c (handle_no_stack_protect_attribute): New. (handle_stack_protect_attribute): Add error message for a no_stack_protector function. gcc/c-family/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * c-attribs.c (handle_no_stack_protect_function_attribute): New. (handle_stack_protect_attribute): Add error message for a no_stack_protector function. gcc/testsuite/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * g++.dg/no-stack-protector-attr-2.C: New test. * g++.dg/no-stack-protector-attr-3.C: New test. * g++.dg/no-stack-protector-attr.C: New test.
2020-09-12Add preliminary support for 128-bit integer typesEric Botcazou1-1/+1
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-09-11Fix ICE on nested packed variant record typeEric Botcazou1-5/+32
This is a regression present on the mainline and 10 branch: the compiler aborts on code accessing a component of a packed record type whose type is a packed discriminated record type with variant part. gcc/ada/ChangeLog: * gcc-interface/utils.c (type_has_variable_size): New function. (create_field_decl): In the packed case, also force byte alignment when the type of the field has variable size. gcc/testsuite/ChangeLog: * gnat.dg/pack27.adb: New test. * gnat.dg/pack27_pkg.ads: New helper.
2020-06-23Emit debug info for integral variables firstEric Botcazou1-17/+25
This makes it possible for global dynamic types to reference the DIE of these integral variables. gcc/ada/ChangeLog: * gcc-interface/utils.c (gnat_write_global_declarations): Output integral global variables first and the imported functions later.
2020-06-19[Ada] Remove handling of 'Pos and 'Val attributes from gigiEric Botcazou1-1/+1
2020-06-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * gcc-interface/trans.c (lvalue_required_for_attribute_p): Do not deal with 'Pos or 'Val. (Attribute_to_gnu): Likewise. * gcc-interface/utils.c (create_field_decl): Small formatting fix.
2020-06-19[Ada] AI12-0028-1 Import of variadic C functionsEric Botcazou1-1/+2
2020-06-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_param): Tidy up. (gnat_to_gnu_subprog_type): For a variadic C function, do not build unnamed parameters and do not add final void node. * gcc-interface/misc.c: Include snames.h. * gcc-interface/trans.c (Attribute_to_gnu): Tidy up. (Call_to_gnu): Implement support for unnamed parameters in a variadic C function. * gcc-interface/utils.c: Include snames.h. (copy_type): Tidy up.
2020-05-25Change description of fat pointertype with -fgnat-encodings=minimalEric Botcazou1-7/+4
This makes a step back in the representation of fat pointer types in the debug info with -fgnat-encodings=minimal so as to avoid hiding the data indirection and making it easiser to synthetize the construct. gcc/ada/ChangeLog * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Add a description of the various types associated with the unconstrained type. Declare the fat pointer earlier. Set the current function as context on the template type, and the fat pointer type on the array type. Always mark the fat pointer type as artificial and set it as the context for the pointer type to the array. Also reuse GNU_ENTITY_NAME. Finish up the unconstrained type at the very end. * gcc-interface/misc.c (gnat_get_array_descr_info): Do not handle fat pointer types and tidy up accordingly. * gcc-interface/utils.c (build_unc_object_type): Do not set the context on the template type.
2020-05-12Fix incorrect scalar storage order handlingEric Botcazou1-5/+10
This fixes an oversight in the new canonicalization code for packable types: it does not take into account the scalar storage order. PR ada/95035 * gcc-interface/utils.c (packable_type_hasher::equal): Also compare the scalar storage order. (hash_packable_type): Also hash the scalar storage order. (hash_pad_type): Likewise.
2020-05-09Update copyright yearEric Botcazou1-1/+1
2020-05-09Fix small issues with -fgnat-encodings=minimalEric Botcazou1-35/+17
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-4/+2
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.
2020-05-08Couple of tweaks to help in LTO modeEric Botcazou1-8/+110
The first tweak is to remove the TREE_OVERFLOW flag on INTEGER_CSTs because it prevents them from being uniquized in LTO mode. The second, unrelated tweak is to canonicalize the packable types made by gigi so that at most one per type is present in the GENERIC IL. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Deal with artificial maximally-sized types designed by access types. * gcc-interface/utils.c (packable_type_hash): New structure. (packable_type_hasher): Likewise. (packable_type_hash_table): New hash table. (init_gnat_utils): Initialize it. (destroy_gnat_utils): Destroy it. (packable_type_hasher::equal): New method. (hash_packable_type): New static function. (canonicalize_packable_type): Likewise. (make_packable_type): Make sure not to use too small a type for the size of the new fields. Canonicalize the type if it is named.
2019-12-03re PR bootstrap/92783 (SEGV in field_byte_offset)Eric Botcazou1-7/+7
PR bootstrap/92783 * gcc-interface/utils.c (rest_of_record_type_compilation): Move down the guard for the position of fields in the descriptive type. From-SVN: r278948
2019-12-03utils.c (potential_alignment_gap): Delete.Eric Botcazou1-62/+28
* gcc-interface/utils.c (potential_alignment_gap): Delete. (rest_of_record_type_compilation): Do not call above function. Use the alignment of the field instead of that of its type, if need be. When the original field has variable size, always lower the alignment of the pointer type. Reset the bit-field status of the new field if it does not encode a bit-field. From-SVN: r278930
2019-12-03utils.c (fold_convert_size): New function.Eric Botcazou1-7/+15
* gcc-interface/utils.c (fold_convert_size): New function. (fold_bit_position): Invoke it to do further folding. From-SVN: r278929
2019-10-11decl.c (gnat_to_gnu_entity): New case to deal with the definition of named ↵Eric Botcazou1-6/+9
numbers. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Named_{Integer|Real}>: New case to deal with the definition of named numbers. <E_Variable>: Minor tweaks. Set DECL_IGNORED_P on the CONST_DECL if a corresponding variable is built. * gcc-interface/trans.c (gnat_to_gnu) <N_Integer_Literal>: Return error_mark_node instead of aborting on overflow for named numbers. <N_Number_Declaration>: Reuse the <N_Object_Declaration> case and deal with error_mark_node specifically. * gcc-interface/utils.c (create_var_decl): Do not set DECL_IGNORED_P on CONST_DECLs. (gnat_write_global_declarations): Output global constants. From-SVN: r276864
2019-10-04Mark C2x built-in functions as such.Joseph Myers1-0/+1
Various built-in functions that GCC has as extensions are now standard functions in C2x. This patch adds DEF_C2X_BUILTIN and uses it to mark them as such. Some of the so-marked functions were previously DEF_EXT_LIB_BUILTIN, while some DFP ones were DEF_GCC_BUILTIN (i.e. __builtin_* only); both sets become DEF_C2X_BUILTIN. This in turn requires flag_isoc2x to be defined in various front ends using builtins.def. As the semantics of the built-in functions should already be tested, the tests added only verify that they are declared in C2x mode but not in C11 mode. The test of DFP built-in functions being declared for C2x goes in gcc.dg/dfp/, as while such built-in functions currently don't depend on whether DFP is supported, that looks like a bug to me (see bug 91985), so it seems best for the tests not to depend on exactly how that bug might be fixed. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc: * builtins.def (DEF_C2X_BUILTIN): New macro. (exp10, exp10f, exp10l, fabsd32, fabsd64, fabsd128, nand32) (nand64, nand128, roundeven, roundevenf, roundevenl, strdup) (strndup): Use DEF_C2X_BUILTIN. * coretypes.h (enum function_class): Add function_c2x_misc. gcc/ada: * gcc-interface/utils.c (flag_isoc2x): New variable. gcc/brig: * brig-lang.c (flag_isoc2x): New variable. gcc/lto: * lto-lang.c (flag_isoc2x): New variable. gcc/testsuite: * gcc.dg/c11-builtins-1.c, gcc.dg/c2x-builtins-1.c, gcc.dg/dfp/c2x-builtins-dfp-1.c: New tests. From-SVN: r276588
2019-09-23trans.c (Regular_Loop_to_gnu): Do not rotate the loop if -Og is enabled.Eric Botcazou1-1/+1
* gcc-interface/trans.c (Regular_Loop_to_gnu): Do not rotate the loop if -Og is enabled. (build_return_expr): Do not perform NRV if -Og is enabled. (Subprogram_Body_to_gnu): Likewise. (gnat_to_gnu) <N_Simple_Return_Statement>: Likewise. (Handled_Sequence_Of_Statements_to_gnu): Do not inline finalizers if -Og is enabled. * gcc-interface/utils.c (convert_to_index_type): Return early if -Og is enabled. From-SVN: r276047
2019-08-30gigi.h (aggregate_type_contains_array_p): Declare.Eric Botcazou1-31/+38
* 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-30utils.c (build_template): Deal with parameters passed by pointer to ↵Eric Botcazou1-13/+16
component of multi-dimensional arrays. * gcc-interface/utils.c (build_template): Deal with parameters passed by pointer to component of multi-dimensional arrays. From-SVN: r275190
2019-06-29utils.c (unchecked_convert): Tweak comment.Eric Botcazou1-5/+32
* gcc-interface/utils.c (unchecked_convert): Tweak comment. Only skip dereferences when padding to have the same size on both sides. Do it for destination types with self-referential size too. From-SVN: r272821
2019-06-29decl.c (gnat_to_gnu_entity): If the type requires strict alignment, then set ↵Eric Botcazou1-14/+14
the RM size to the type size. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: If the type requires strict alignment, then set the RM size to the type size. Rework handling of alignment and sizes of tagged types in ASIS mode. (validate_size): Rename local variable and remove special handling for strict-alignment types. * gcc-interface/utils.c (finish_record_type): Constify local variables and use properly typed constants. From-SVN: r272820
2019-06-29expr.c (expand_expr_real_1): Apply the big-endian adjustment for bit-fields ↵Eric Botcazou1-20/+65
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-24utils.c (handle_nonnull_attribute): Quote attribute name.Martin Sebor1-7/+8
gcc/ada/ChangeLog: * gcc-interface/utils.c (handle_nonnull_attribute): Quote attribute name. gcc/c/ChangeLog: * c-typeck.c (build_binary_op): Hyphenate floating-point. gcc/testsuite/ChangeLog: * gcc.dg/Wfloat-equal-1.c: Adjust text of expected diagnostic. * gcc.dg/misc-column.c: Ditto. gcc/ChangeLog: * tree-pretty-print.h: Remove unnecessary punctuation characters from a diagnostic. * tree-ssa.c (release_defs_bitset): Correct preprocessor conditional. From-SVN: r272619
2019-05-28* gcc-interface/utils.c (handle_stack_protect_attribute): Move around.Eric Botcazou1-16/+16
From-SVN: r271694
2019-05-28implementation_defined_pragmas.rst (Machine_Attribute): Document additional ↵Eric Botcazou1-11/+235
optional parameters. * doc/gnat_rm/implementation_defined_pragmas.rst (Machine_Attribute): Document additional optional parameters. * sem_prag.adb (Analyze_Pragma) <Pragma_Machine_Attribute>: Accept more than one optional parameter. * gcc-interface/decl.c (prepend_one_attribute_pragma): Alphabetize the list of supported pragmas. Simplify the handling of parameters and add support for more than one optional parameter. * gcc-interface/utils.c (attr_cold_hot_exclusions): New constant. (gnat_internal_attribute_table): Add entry for no_icf, noipa, flatten, used, cold, hot, target and target_clones. (begin_subprog_body): Do not create the RTL for the subprogram here. (handle_noicf_attribute): New static function. (handle_noipa_attribute): Likewise. (handle_flatten_attribute): Likewise. (handle_used_attribute): Likewise. (handle_cold_attribute): Likewise. (handle_hot_attribute): Likewise. (handle_target_attribute): Likewise. (handle_target_clones_attribute): Likewise. From-SVN: r271693
2019-05-28decl.c (components_to_record): Set a name on the type created for the REP ↵Eric Botcazou1-19/+19
part, if any. * gcc-interface/decl.c (components_to_record): Set a name on the type created for the REP part, if any. * gcc-interface/utils.c (finish_record_type): Only take the maximum when merging sizes for a variant part at offset 0. (merge_sizes): Rename has_rep parameter into max. From-SVN: r271681
2019-05-28utils.c (gnat_internal_attribute_table): Add support for stack_protect ↵Eric Botcazou1-0/+19
attribute. * gcc-interface/utils.c (gnat_internal_attribute_table): Add support for stack_protect attribute. (handle_stack_protect_attribute): New static function. From-SVN: r271680
2019-05-27ada-builtin-types.def: New file.Eric Botcazou1-1/+10
* gcc-interface/ada-builtin-types.def: New file. * gcc-interface/ada-builtins.def: Likewise. * gcc-interface/ada-tree.h (BUILT_IN_LIKELY): New macro. (BUILT_IN_UNLIKELY): Likewise. * gcc-interface/trans.c (independent_iterations_p): Initialize the auto-vector to 16 elements. (Call_to_gnu): Remove local variable and change the vector of actual parameters to an auto-vector. Do not convert actual parameters to the argument type for front-end built-in functions. Add support for front-end built-in functions. (build_noreturn_cond): Use internal instead of built-in function. * gcc-interface/utils.c (c_builtin_type): Include ada-builtin-types.def (install_builtin_function_types): Likewise. (install_builtin_functions): Include ada-builtins.def first. From-SVN: r271658
2019-05-27utils.c (maybe_pad_type): Issue the warning for the specific case of ↵Eric Botcazou1-5/+5
component types preferably. * gcc-interface/utils.c (maybe_pad_type): Issue the warning for the specific case of component types preferably. From-SVN: r271655
2019-02-08trans.c (gnat_to_gnu): Minor tweak.Eric Botcazou1-16/+29
* gcc-interface/trans.c (gnat_to_gnu) <N_Aggregate>: Minor tweak. * gcc-interface/utils.c (convert): Do not pad when doing an unchecked conversion here. Use TREE_CONSTANT throughout the function. (unchecked_convert): Also pad if the source is a CONSTRUCTOR and the destination is a more aligned array type or a larger aggregate type, but not between original and packable versions of a type. From-SVN: r268679
2019-02-08utils.c (max_size): Be prepared for an operand with VOID_TYPE.Eric Botcazou1-4/+11
* gcc-interface/utils.c (max_size) <tcc_unary>: Be prepared for an operand with VOID_TYPE. From-SVN: r268675
2019-01-27repinfo.adb (List_Component_Layout): Remove superfluous space for zero-sized ↵Eric Botcazou1-50/+114
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
2019-01-08[Ada] Bump copyright years to 2019Pierre-Marie de Rodat1-1/+1
From-SVN: r267683
2018-12-11[Ada] Fix elaboration of record with 1-element dynamic arrayEric Botcazou1-5/+6
2018-12-11 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * einfo.ads (Is_Bit_Packed_Array): Fix values of component size. (Is_Packed): Likewise. * gcc-interface/utils.c (convert): Do not extract the value of a justified modular type if the destination type is a regular array. * gcc-interface/decl.c (gnat_to_gnu_component_type): Pass TYPE_DECL to validate_size wherever the array has packed components. From-SVN: r267005
2018-12-11[Ada] Almost always inline init. procedure of small and simple recordsEric Botcazou1-8/+11
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-11-08decl.c (components_to_record): Remove obsolete kludge.Eric Botcazou1-8/+18
* gcc-interface/decl.c (components_to_record): Remove obsolete kludge. * gcc-interface/utils.c (make_packable_type): Set TYPE_PACKED on the new type but do not take into account the setting on the old type for the new fields. Rename a local variable. (finish_record_type): Clear DECL_BIT_FIELD_TYPE on a variant part at offset 0, if any. (create_field_decl): Tweak comment. From-SVN: r265917
2018-10-22utils.c (unchecked_convert): Use local variables for the biased and reverse ↵Eric Botcazou1-35/+52
SSO attributes of both types. * gcc-interface/utils.c (unchecked_convert): Use local variables for the biased and reverse SSO attributes of both types. Further extend the processing of integral types in the presence of reverse SSO to all scalar types. From-SVN: r265381
2018-09-28calls.c (expand_call): Try to do a tail call for thunks at -O0 too.Eric Botcazou1-3/+1
* calls.c (expand_call): Try to do a tail call for thunks at -O0 too. * cgraph.h (struct cgraph_thunk_info): Add indirect_offset. (cgraph_node::create_thunk): Add indirect_offset parameter. (thunk_adjust): Likewise. * cgraph.c (cgraph_node::create_thunk): Add indirect_offset parameter and initialize the corresponding field with it. (cgraph_node::dump): Dump indirect_offset field. * cgraphclones.c (duplicate_thunk_for_node): Deal with indirect_offset. * cgraphunit.c (cgraph_node::analyze): Be prepared for external thunks. (thunk_adjust): Add indirect_offset parameter and deal with it. (cgraph_node::expand_thunk): Deal with the indirect_offset field and pass it to thunk_adjust. Do not call the target hook if it's non-zero or if the thunk is external or local. Fix formatting. Do not chain the RESULT_DECL to BLOCK_VARS. Pass the static chain to the target, if any, in the GIMPLE representation. * ipa-icf.c (sem_function::equals_wpa): Deal with indirect_offset. * lto-cgraph.c (lto_output_node): Write indirect_offset field. (input_node): Read indirect_offset field. * tree-inline.c (expand_call_inline): Pass indirect_offset field in the call to thunk_adjust. * tree-nested.c (struct nesting_info): Add thunk_p field. (create_nesting_tree): Set it. (convert_all_function_calls): Copy static chain from targets to thunks. (finalize_nesting_tree_1): Return early for thunks. (unnest_nesting_tree_1): Do not finalize thunks. (gimplify_all_functions): Do not gimplify thunks. cp/ * method.c (use_thunk): Adjust call to cgraph_node::create_thunk. ada/ * gcc-interface/decl.c (is_cplusplus_method): Do not require C++ convention on Interfaces. * gcc-interface/trans.c (Subprogram_Body_to_gnu): Try to create a bona-fide thunk and hand it over to the middle-end. (get_controlling_type): New function. (use_alias_for_thunk_p): Likewise. (thunk_labelno): New static variable. (make_covariant_thunk): New function. (maybe_make_gnu_thunk): Likewise. * gcc-interface/utils.c (finish_subprog_decl): Set DECL_CONTEXT of the result DECL here instead of... (end_subprog_body): ...here. Co-Authored-By: Pierre-Marie de Rodat <derodat@adacore.com> From-SVN: r264701
2018-09-27tree.h (tree_to_shwi): Add attribute nonnull and pure.Martin Sebor1-7/+9
gcc/ChangeLog: * tree.h (tree_to_shwi): Add attribute nonnull and pure. (tree_to_poly_int64, tree_to_uhwi, tree_to_poly_uint64): Same. (int_fits_type_p): Same. gcc/ada/ChangeLog: * gcc-interface/utils.c (make_packable_type): Introduce a temporary to avoid -Wnonnull. (unchecked_convert): Same. From-SVN: r264680
2018-09-26[Ada] Set Current_Error_Node directlyEric Botcazou1-1/+1
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-17decl.c (choices_to_gnu): Rename parameters.Eric Botcazou1-6/+6
* gcc-interface/decl.c (choices_to_gnu): Rename parameters. Deal with an operand of Character type. Factor out range generation to the end. Check that the bounds are literals and convert them to the type of the operand before building the ranges. * gcc-interface/utils.c (make_dummy_type): Minor tweak. (make_packable_type): Propagate TYPE_DEBUG_TYPE. (maybe_pad_type): Likewise. From-SVN: r262812
2018-07-17[Ada] Type mismatch warning for imported C++ classEric Botcazou1-4/+4
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-13DFix typoEric Botcazou1-1/+1
From-SVN: r262630
2018-07-13lang.opt (funsigned-char): New option.Eric Botcazou1-1/+1
* gcc-interface/lang.opt (funsigned-char): New option. * gcc-interface/misc.c (gnat_handle_option): Accept it. * gcc-interface/utils.c (finish_character_type): Tweak comment. From-SVN: r262629