aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
AgeCommit message (Collapse)AuthorFilesLines
2020-04-01d: Merge UDAs between function prototype and definitions (PR90136)Iain Buclaw7-51/+88
This change fixes the symbol merging in get_symbol_decl to also consider prototypes. This allows the ability to set user defined attributes on the prototype of a function, which then get applied to the definition, if found later in the compilation. The lowering of UDAs to GCC attributes has been commonized into a single function called apply_user_attributes. gcc/d/ChangeLog: PR d/90136 * d-attribs.cc: Include dmd/attrib.h. (build_attributes): Redeclare as static. (apply_user_attributes): New function. * d-tree.h (class UserAttributeDeclaration): Remove. (build_attributes): Remove. (apply_user_attributes): Declare. (finish_aggregate_type): Remove attrs argument. * decl.cc (get_symbol_decl): Merge declaration prototypes with definitions. Use apply_user_attributes. * modules.cc (layout_moduleinfo_fields): Remove last argument to finish_aggregate_type. * typeinfo.cc (layout_classinfo_interfaces): Likewise. * types.cc (layout_aggregate_members): Likewise. (finish_aggregate_type): Remove attrs argument. (TypeVisitor::visit (TypeEnum *)): Use apply_user_attributes. (TypeVisitor::visit (TypeStruct *)): Remove last argument to finish_aggregate_type. Use apply_user_attributes. (TypeVisitor::visit (TypeClass *)): Likewise. gcc/testsuite/ChangeLog: PR d/90136 * gdc.dg/pr90136a.d: New test. * gdc.dg/pr90136b.d: New test. * gdc.dg/pr90136c.d: New test.
2020-03-31d: Add always_inline to the internal attribute table.Iain Buclaw2-0/+21
This attribute is not directly accessible from user code, rather it is indirectly added from the @forceinline attribute. Even so, a handler should be present for it to prevent false positive warnings. Said warnings are not something that could happen currently, but will become a problem from fixing PR90136 later. gcc/d/ChangeLog: * d-attribs.cc (d_langhook_common_attribute_table): Add always_inline. (handle_always_inline_attribute): New function.
2020-03-31d: Use memset to fill alignment holes with zeroes.Iain Buclaw3-47/+25
This patch removes the manual insertion of padding for fields in constructed struct literals, and instead uses memset() on the declaration being initialized. When compiling optimized builds, the intent is usually missed, and alignment holes end up with non-zero values in them anyway. gcc/d/ChangeLog: PR d/94424 * d-codegen.cc (build_alignment_field): Remove. (build_struct_literal): Don't insert alignment padding. * expr.cc (ExprVisitor::visit (AssignExp *)): Call memset before assigning struct literals. gcc/testsuite/ChangeLog: PR d/94424 * gdc.dg/pr94424.d: New test.
2020-03-31d: Use d_comdat_linkage on generated internal decl.Iain Buclaw2-1/+6
This adds weak linkage to internal TypeInfo data on top of the existing DECL_COMDAT, which helps in the unlikely event that two of the same TypeInfo data ends up in multiple places. gcc/d/ChangeLog: * typeinfo.cc (TypeInfoVisitor::internal_reference): Call d_comdat_linkage on generated decl.
2020-03-29testsuite: Move C++ tests in gdc.test into own subdirectory.Iain Buclaw1-1/+1
Tests have been moved into runnable_cxx as part of upstream dmd 3e10e2dd2. The extra flags required for tests that mix C++ and D are now limited to only a small subset of tests, rather than applied to all tests across gdc.dg and gdc.test. Reviewed-on: https://github.com/dlang/dmd/pull/10980 gcc/testsuite/ChangeLog: * gdc.test/runnable_cxx/runnable_cxx.exp: New file. * lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx. * lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if GDC_INCLUDE_CXX_FLAGS is true. (gdc_link_flags): Likewise. (gdc_init): Move setting of default gdc test flags to... (gdc_target_compile): ...here.
2020-03-22d: Generate phony targets for content imported files (PR93038)Iain Buclaw2-21/+24
This is in addition to the last change which started including them in the make dependency list. gcc/d/ChangeLog: 2020-03-22 Iain Buclaw <ibuclaw@gdcproject.org> PR d/93038 * d-lang.cc (deps_write): Generate phony targets for content imported files. gcc/testsuite/ChangeLog: 2020-03-22 Iain Buclaw <ibuclaw@gdcproject.org> PR d/93038 * gdc.dg/pr93038b.d: New test.
2020-03-22d: Fix missing dependencies in depfile for imported files (PR93038)Iain Buclaw2-20/+38
A new field for tracking imported files was added to the front-end, this makes use of it by writing all such files in the make dependency list. gcc/d/ChangeLog: 2020-03-22 Iain Buclaw <ibuclaw@gdcproject.org> PR d/93038 * d-lang.cc (deps_write): Add content imported files to the make dependency list. gcc/testsuite/ChangeLog: 2020-03-22 Iain Buclaw <ibuclaw@gdcproject.org> PR d/93038 * gdc.dg/fileimports/pr93038.txt: New test. * gdc.dg/pr93038.d: New test.
2020-03-22d: Fix typo in ChangeLog for last changeIain Buclaw1-1/+1
2020-03-21d: Fix ICE in add_symbol_to_partition_1, at lto/lto-partition.c:215Iain Buclaw2-19/+40
This patch addresses two problems with TypeInfo initializer generation. 1. D array fields pointing to compiler generated data are referencing public symbols with no unique prefix, which can lead to duplicate definition errors in some hard to reduce cases. To avoid name clashes, all symbols that are generated for TypeInfo initializers now use the assembler name of the TypeInfo decl as a prefix. 2. An ICE would occur during LTO pass because these same decls are considered to be part of the same comdat group as the TypeInfo decl that it's referred by, despite itself being neither marked public nor comdat. This resulted in decls being added to the LTRANS partition out of order, triggering an assert when add_symbol_to_partition_1 attempted to add them again. To remedy, TREE_PUBLIC and DECL_COMDAT are now set on all generated symbols. gcc/d/ChangeLog: 2020-03-21 Iain Buclaw <ibuclaw@gdcproject.org> PR d/94290 * typeinfo.cc (class TypeInfoVisitor): Replace type_ field with decl_. (TypeInfoVisitor::TypeInfoVisitor): Set decl_. (TypeInfoVisitor::result): Update. (TypeInfoVisitor::internal_reference): New function. (TypeInfoVisitor::layout_string): Use internal_reference. (TypeInfoVisitor::visit (TypeInfoTupleDeclaration *)): Likewise. (layout_typeinfo): Construct TypeInfoVisitor with typeinfo decl. (layout_classinfo): Likewise.
2020-03-20d: Fix SEGV in hash_table<odr_name_hasher, false, ↵Iain Buclaw4-5/+71
xcallocator>::find_slot_with_hash This patch fixes LTO bug with the D front-end. As DECL_ASSEMBLER_NAME is set on the TYPE_DECL, so TYPE_CXX_ODR_P must also be set on the type. The addition of merge_aggregate_types is not strictly needed now, but it fixes a problem introduced in newer versions of the dmd front-end where templated types could be sent more than once to the D code generator. gcc/d/ChangeLog: 2020-03-20 Iain Buclaw <ibuclaw@gdcproject.org> PR lto/91027 * d-tree.h (struct GTY): Add daggregate field. (IDENTIFIER_DAGGREGATE): Define. (d_mangle_decl): Add declaration. * decl.cc (mangle_decl): Remove static linkage, rename to... (d_mangle_decl): ...this, update all callers. * types.cc (merge_aggregate_types): New function. (TypeVisitor::visit (TypeStruct *)): Call merge_aggregate_types, set IDENTIFIER_DAGGREGATE and TYPE_CXX_ODR_P. (TypeVisitor::visit (TypeClass *)): Likewise.
2020-03-19d/dmd: Merge upstream dmd d1a606599Iain Buclaw4-2/+3
Fixes long standing regression in the D front-end implemention, and adds a new field to allow retrieving a list of all content imports from the code generator. Reviewed-on: https://github.com/dlang/dmd/pull/10913 https://github.com/dlang/dmd/pull/10933
2020-03-18Fix up duplicated duplicated words in commentsJakub Jelinek3-2/+8
Another set of duplicated word fixes for things I've missed last time. These include e.g. *.cc files I forgot about, or duplicated words at the start or end of line. 2020-03-18 Jakub Jelinek <jakub@redhat.com> * asan.c (get_mem_refs_of_builtin_call): Fix up duplicated word issue in a comment. * config/arc/arc.c (frame_stack_add): Likewise. * gimple-loop-versioning.cc (loop_versioning::analyze_arbitrary_term): Likewise. * ipa-predicate.c (predicate::remap_after_inlining): Likewise. * tree-ssa-strlen.h (handle_printf_call): Likewise. * tree-ssa-strlen.c (is_strlen_related_p): Likewise. * optinfo-emit-json.cc (optrecord_json_writer::add_record): Likewise. analyzer/ * sm-malloc.cc (malloc_state_machine::on_stmt): Fix up duplicated word issue in a comment. * region-model.cc (region_model::make_region_for_unexpected_tree_code, region_model::delete_region_and_descendents): Likewise. * engine.cc (class exploded_cluster): Likewise. * diagnostic-manager.cc (class path_builder): Likewise. cp/ * constraint.cc (resolve_function_concept_check, subsumes_constraints, strictly_subsumes): Fix up duplicated word issue in a comment. * coroutines.cc (build_init_or_final_await, captures_temporary): Likewise. * logic.cc (dnf_size_r, cnf_size_r): Likewise. * pt.c (append_type_to_template_for_access_check): Likewise. d/ * expr.cc (ExprVisitor::visit (CatAssignExp *)): Fix up duplicated word issue in a comment. * d-target.cc (Target::FPTypeProperties<T>::max): Likewise. fortran/ * class.c (generate_finalization_wrapper): Fix up duplicated word issue in a comment. * trans-types.c (gfc_get_nodesc_array_type): Likewise.
2020-03-16d: Fix assignment to anonymous union member corrupts sibling members in structIain Buclaw2-3/+13
gcc/d/ChangeLog: PR d/92309 * types.cc (fixup_anonymous_offset): Don't set DECL_FIELD_OFFSET on anonymous fields. gcc/testsuite/ChangeLog: PR d/92309 * gdc.dg/pr92309.d: New test.
2020-03-16d: Fix multiple definition error when using mixins and interfaces.Iain Buclaw2-2/+11
gcc/d/ChangeLog: PR d/92216 * decl.cc (make_thunk): Don't set TREE_PUBLIC on thunks if the target function is external to the current compilation. gcc/testsuite/ChangeLog: PR d/92216 * gdc.dg/imports/pr92216.d: New. * gdc.dg/pr92216.d: New test.
2020-03-16d/dmd: Merge upstream dmd b061bd744Iain Buclaw2-4/+28
Fixes an ICE in the parser, and deprecates a previously allowed style of syntax that deviated from GNU-style extended asm. Reviewed-on: https://github.com/dlang/dmd/pull/10916 gcc/testsuite/ChangeLog: 2020-03-16 Iain Buclaw <ibuclaw@gdcproject.org> * gdc.dg/asm1.d: Add new test for ICE in asm parser. * gdc.dg/asm5.d: New test.
2020-03-13d/dmd: Merge upstream dmd e9420cfbfIain Buclaw29-322/+1681
1. Implement DIP 1010 - (Static foreach) Support for 'static foreach' has been added. 'static foreach' is a conditional compilation construct that is to 'foreach' what 'static if' is to 'if'. It is a convenient way to generate declarations and statements by iteration. import std.conv: to; static foreach(i; 0 .. 10) { // a 'static foreach' body does not introduce a nested scope // (similar to 'static if'). // The following mixin declaration is at module scope: // declares 10 variables x0, x1, ..., x9 mixin('enum x' ~ to!string(i) ~ ' = i;'); } import std.range: iota; // all aggregate types that can be iterated with a standard 'foreach' // loop are also supported by static foreach: static foreach(i; iota(10)) { // we access the declarations generated in the first 'static foreach' pragma(msg, "x", i, ": ", mixin(`x` ~ to!string(i))); static assert(mixin(`x` ~ to!string(i)) == i); } void main() { import std.conv: text; import std.typecons: tuple; import std.algorithm: map; import std.stdio: writeln; // 'static foreach' has both declaration and statement forms // (similar to 'static if'). static foreach(x; iota(3).map!(i => tuple(text("x", i), i))) { // generates three local variables x0, x1 and x2. mixin(text(`int `,x[0],` = x[1];`)); scope(exit) // this is within the scope of 'main' { writeln(mixin(x[0])); } } writeln(x0," ",x1," ",x2); // first runtime output } 2. Aliases can be created directly from a '__trait'. Aliases can be created directly from the traits that return symbol(s) or tuples. This includes 'getMember', 'allMembers', 'derivedMembers', 'parent', 'getOverloads', 'getVirtualFunctions', 'getVirtualMethods', 'getUnitTests', 'getAttributes' and finally 'getAliasThis'. Previously an 'AliasSeq' was necessary in order to alias their return. Now the grammar allows to write shorter declarations: struct Foo { static int a; } alias oldWay = AliasSeq!(__traits(getMember, Foo, "a"))[0]; alias newWay = __traits(getMember, Foo, "a"); To permit this it was more interesting to include '__trait' in the basic types rather than just changing the alias syntax. So additionally, wherever a type appears a '__trait' can be used, for example in a variable declaration: struct Foo { static struct Bar {} } const(__traits(getMember, Foo, "Bar")) fooBar; static assert(is(typeof(fooBar) == const(Foo.Bar))); 3. fix Issue 10100 - Identifiers with double underscores and allMembers The identifer whitelist has been converted into a blacklist of all possible internal D language declarations. Reviewed-on: https://github.com/dlang/dmd/pull/10791
2020-01-01Update copyright years.Jakub Jelinek35-34/+36
From-SVN: r279813
2020-01-01gcc.c (process_command): Update copyright notice dates.Jakub Jelinek3-325/+334
* gcc.c (process_command): Update copyright notice dates. * gcov-dump.c (print_version): Ditto. * gcov.c (print_version): Ditto. * gcov-tool.c (print_version): Ditto. * gengtype.c (create_file): Ditto. * doc/cpp.texi: Bump @copying's copyright year. * doc/cppinternals.texi: Ditto. * doc/gcc.texi: Ditto. * doc/gccint.texi: Ditto. * doc/gcov.texi: Ditto. * doc/install.texi: Ditto. * doc/invoke.texi: Ditto. gcc/fortran/ * gfortranspec.c (lang_specific_driver): Update copyright notice dates. * gfc-internals.texi: Bump @copying's copyright year. * gfortran.texi: Ditto. * intrinsic.texi: Ditto. * invoke.texi: Ditto. gcc/d/ * gdc.texi: Bump @copyrights-d year. gcc/go/ * gccgo.texi: Bump @copyrights-go year. gcc/ada/ * gnat_ugn.texi: Bump @copying's copyright year. * gnat_rm.texi: Likewise. libitm/ * libitm.texi: Bump @copying's copyright year. libgomp/ * libgomp.texi: Bump @copying's copyright year. libquadmath/ * libquadmath.texi: Bump @copying's copyright year. From-SVN: r279811
2019-11-14Remove build_{same_sized_,}truth_vector_typeRichard Sandiford2-1/+6
build_same_sized_truth_vector_type was confusingly named, since for SVE and AVX512 the returned vector isn't the same byte size (although it does have the same number of elements). What it really returns is the "truth" vector type for a given data vector type. The more general truth_type_for provides the same thing when passed a vector and IMO has a more descriptive name, so this patch replaces all uses of build_same_sized_truth_vector_type with that. It does the same for a call to build_truth_vector_type, leaving truth_type_for itself as the only remaining caller. It's then more natural to pass build_truth_vector_type the original vector type rather than its size and nunits, especially since the given size isn't the size of the returned vector. This in turn allows a future patch to simplify the interface of get_mask_mode. Doing this also fixes a bug in which truth_type_for would pass a size of zero for BLKmode vector types. 2019-11-14 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree.h (build_truth_vector_type): Delete. (build_same_sized_truth_vector_type): Likewise. * tree.c (build_truth_vector_type): Rename to... (build_truth_vector_type_for): ...this. Make static and take a vector type as argument. (truth_type_for): Update accordingly. (build_same_sized_truth_vector_type): Delete. * tree-vect-generic.c (expand_vector_divmod): Use truth_type_for instead of build_same_sized_truth_vector_type. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vect_record_loop_mask, vect_get_loop_mask): Likewise. * tree-vect-patterns.c (build_mask_conversion): Likeise. * tree-vect-slp.c (vect_get_constant_vectors): Likewise. * tree-vect-stmts.c (vect_get_vec_def_for_operand): Likewise. (vect_build_gather_load_calls, vectorizable_call): Likewise. (scan_store_can_perm_p, vectorizable_scan_store): Likewise. (vectorizable_store, vectorizable_condition): Likewise. (get_mask_type_for_scalar_type, get_same_sized_vectype): Likewise. (vect_get_mask_type_for_stmt): Use truth_type_for instead of build_truth_vector_type. * config/aarch64/aarch64-sve-builtins.cc (gimple_folder::convert_pred): Use truth_type_for instead of build_same_sized_truth_vector_type. * config/rs6000/rs6000-call.c (fold_build_vec_cmp): Likewise. gcc/c/ * c-typeck.c (build_conditional_expr): Use truth_type_for instead of build_same_sized_truth_vector_type. (build_vec_cmp): Likewise. gcc/cp/ * call.c (build_conditional_expr_1): Use truth_type_for instead of build_same_sized_truth_vector_type. * typeck.c (build_vec_cmp): Likewise. gcc/d/ * d-codegen.cc (build_boolop): Use truth_type_for instead of build_same_sized_truth_vector_type. From-SVN: r278232
2019-11-13Add C2x *_NORM_MAX constants to <float.h>.Joseph Myers2-1/+6
C2x adds <float.h> constants FLT_NORM_MAX, DBL_NORM_MAX and LDBL_NORM_MAX. These are for the maximum "normalized" finite floating-point number, where the given definition of normalized is that all possible values with MANT_DIG significand digits (leading one not zero) can be represented with that exponent. The effect of that definition is that these macros are the same as the corresponding MAX macros for all formats except IBM long double, where the NORM_MAX value has exponent 1 smaller than the MAX one so that all 106 digits can be 1. This patch adds those macros to GCC. They are only defined for float, double and long double; C2x does not include such macros for DFP types, and while the integration of TS 18661-3 into C2x has not yet occurred, the draft proposed text does not add them for the _FloatN / _FloatNx types (where they would always be the same as the MAX macros). Bootstrapped with no regressions on x86_64-pc-linux-gnu. Also tested compilation of the new test for powerpc-linux-gnu to confirm the check of LDBL_NORM_MAX in the IBM long double case does get properly optimized out. gcc: * ginclude/float.c [__STDC_VERSION__ > 201710L] (FLT_NORM_MAX, DBL_NORM_MAX, LDBL_NORM_MAX): Define. * real.c (get_max_float): Add norm_max argument. * real.h (get_max_float): Update prototype. * builtins.c (fold_builtin_interclass_mathfn): Update calls to get_max_float. gcc/c-family: * c-cppbuiltin.c (builtin_define_float_constants): Also define NORM_MAX constants. Update call to get_max_float. (LAZY_HEX_FP_VALUES_CNT): Update value to include NORM_MAX constants. gcc/d: * d-target.cc (define_float_constants): Update call to get_max_float. gcc/testsuite: * gcc.dg/c11-float-3.c, gcc.dg/c2x-float-1.c: New tests. From-SVN: r278145
2019-11-04[D] Remove unchecked to_constant in VECTOR_TYPE handlingRichard Sandiford2-11/+19
The SVE port now tries to register variable-length VECTOR_TYPEs at start-up, so it's no longer possible to use the asserting to_constant on the number of vector elements. This patch punts on variable element counts instead, just like we do for other things that the frontend doesn't recognise. The brace indentation matches the surrounding style. 2019-11-04 Richard Sandiford <richard.sandiford@arm.com> gcc/d/ * d-builtins.cc (build_frontend_type): Cope with variable TYPE_VECTOR_SUBPARTS. From-SVN: r277793
2019-08-23re PR middle-end/91283 (gcc.dg/torture/c99-contract-1.c FAILs)Jakub Jelinek2-2/+8
PR middle-end/91283 * common.opt (fexcess-precision=): Add Optimization flag. Use flag_excess_precision variable instead of flag_excess_precision_cmdline. * flags.h (class target_flag_state): Remove x_flag_excess_precision member. (flag_excess_precision): Don't define. * langhooks.c (lhd_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. Remove comment. * opts.c (set_fast_math_flags): Use frontend_set_flag_excess_precision and x_flag_excess_precision instead of frontend_set_flag_excess_precision_cmdline and x_flag_excess_precision_cmdline. (fast_math_flags_set_p): Use x_flag_excess_precision instead of x_flag_excess_precision_cmdline. * toplev.c (init_excess_precision): Remove. (lang_dependent_init_target): Don't call it. ada/ * gcc-interface/misc.c (gnat_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. brig/ * brig-lang.c (brig_langhook_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. c-family/ * c-common.c (c_ts18661_flt_eval_method): Use flag_excess_precision instead of flag_excess_precision_cmdline. * c-cppbuiltin.c (c_cpp_flt_eval_method_iec_559): Likewise. * c-opts.c (c_common_post_options): Likewise. d/ * d-lang.cc (d_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. fortran/ * options.c (gfc_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. Remove comment. go/ * go-lang.c (go_langhook_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. lto/ * lto-lang.c (lto_post_options): Set flag_excess_precision instead of flag_excess_precision_cmdline. Remove comment. From-SVN: r274850
2019-08-21re PR d/91339 (libphobos: ftbfs when the path contains '~')Iain Buclaw2-2/+3
PR d/91339 d/dmd: Merge upstream dmd b37a537d3 Fixes the error: cannot find source code for runtime library file 'object.d' when the path contains '~'. Reviewed-on: https://github.com/dlang/dmd/pull/10309 From-SVN: r274771
2019-08-21d: Partially fix ICE: in register_moduleinfo, at d/modules.cc:40Iain Buclaw2-1/+10
gcc/d/ChangeLog: PR d/88722 * modules.cc: Include diagnostic.h. (register_moduleinfo): Use sorry instead of gcc_assert for targets without named sections. From-SVN: r274769
2019-08-21d/dmd: Merge upstream dmd 375ed10aaIain Buclaw5-13/+30
Don't crash when compiling for 16-bit platforms. Reviewed-on: https://github.com/dlang/dmd/pull/10306 gcc/d/ChangeLog: * d-target.cc: Include diagnostic.h. (Target::_init): Set Tsize_t and Tptrdiff_t as D ushort and short if the target pointer size is 2. Add sorry if the pointer size is not either 2, 4, or 8. From-SVN: r274768
2019-08-21d: Fix ICE: Segmentation fault in build_function_type at gcc/tree.c:8539Iain Buclaw2-0/+28
gcc/d/ChangeLog: PR d/90446 * d-lang.cc (d_type_for_mode): Check for all internal __intN types. (d_type_for_size): Likewise. From-SVN: r274767
2019-08-21d: Fix internal compiler error: in d_build_c_type_nodes, at d/d-builtins.cc:783Iain Buclaw2-6/+11
gcc/d/ChangeLog: PR d/90445 * d-builtins.cc (d_build_c_type_nodes): Test UINTMAX_TYPE for setting uintmax_type_node. Set signed_size_type_node as the signed_type_for size_type_node. From-SVN: r274766
2019-08-21d: Fix internal compiler error: in d_init_builtins, at d/d-builtins.cc:1121Iain Buclaw2-36/+70
gcc/d/ChangeLog: PR d/90444 * d-builtins.cc (build_frontend_type): Build anonymous RECORD_TYPE nodes as well, push all fields to the struct members. (d_build_builtins_module): Push anonymous va_list structs to the builtins module, naming them __builtin_va_list. (d_init_builtins): Use sorry instead of gcc_unreachable if va_list did not succeed in being represented as a D type. From-SVN: r274765
2019-08-13Use checking forms of DECL_FUNCTION_CODE (PR 91421)Richard Sandiford2-4/+6
We were shoe-horning all built-in enumerations (including frontend and target-specific ones) into a field of type built_in_function. This was accessed as either an lvalue or an rvalue using DECL_FUNCTION_CODE. The obvious danger with this (as was noted by several ??? comments) is that the ranges have nothing to do with each other, and targets can easily have more built-in functions than generic code. But my patch to make the field bigger was the straw that finally made the problem visible. This patch therefore: - replaces the field with a plain unsigned int - turns DECL_FUNCTION_CODE into an rvalue-only accessor that checks that the function really is BUILT_IN_NORMAL - adds corresponding DECL_MD_FUNCTION_CODE and DECL_FE_FUNCTION_CODE accessors for BUILT_IN_MD and BUILT_IN_FRONTEND respectively - adds DECL_UNCHECKED_FUNCTION_CODE for places that need to access the underlying field (should be low-level code only) - adds new helpers for setting the built-in class and function code - makes DECL_BUILT_IN_CLASS an rvalue-only accessor too, since all assignments should go through the new helpers 2019-08-13 Richard Sandiford <richard.sandiford@arm.com> gcc/ PR middle-end/91421 * tree-core.h (function_decl::function_code): Change type to unsigned int. * tree.h (DECL_FUNCTION_CODE): Rename old definition to... (DECL_UNCHECKED_FUNCTION_CODE): ...this. (DECL_BUILT_IN_CLASS): Make an rvalue macro only. (DECL_FUNCTION_CODE): New function. Assert that the built-in class is BUILT_IN_NORMAL. (DECL_MD_FUNCTION_CODE, DECL_FE_FUNCTION_CODE): New functions. (set_decl_built_in_function, copy_decl_built_in_function): Likewise. (fndecl_built_in_p): Change the type of the "name" argument to unsigned int. * builtins.c (expand_builtin): Move DECL_FUNCTION_CODE use after check for DECL_BUILT_IN_CLASS. * cgraphclones.c (build_function_decl_skip_args): Use set_decl_built_in_function. * ipa-param-manipulation.c (ipa_modify_formal_parameters): Likewise. * ipa-split.c (split_function): Likewise. * langhooks.c (add_builtin_function_common): Likewise. * omp-simd-clone.c (simd_clone_create): Likewise. * tree-streamer-in.c (unpack_ts_function_decl_value_fields): Likewise. * config/darwin.c (darwin_init_cfstring_builtins): Likewise. (darwin_fold_builtin): Use DECL_MD_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * fold-const.c (operand_equal_p): Compare DECL_UNCHECKED_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * lto-streamer-out.c (hash_tree): Use DECL_UNCHECKED_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * tree-streamer-out.c (pack_ts_function_decl_value_fields): Likewise. * print-tree.c (print_node): Use DECL_MD_FUNCTION_CODE when printing DECL_BUILT_IN_MD. Handle DECL_BUILT_IN_FRONTEND. * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin) (aarch64_fold_builtin, aarch64_gimple_fold_builtin): Use DECL_MD_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * config/aarch64/aarch64.c (aarch64_builtin_reciprocal): Likewise. * config/alpha/alpha.c (alpha_expand_builtin, alpha_fold_builtin): (alpha_gimple_fold_builtin): Likewise. * config/arc/arc.c (arc_expand_builtin): Likewise. * config/arm/arm-builtins.c (arm_expand_builtin): Likewise. * config/avr/avr-c.c (avr_resolve_overloaded_builtin): Likewise. * config/avr/avr.c (avr_expand_builtin, avr_fold_builtin): Likewise. * config/bfin/bfin.c (bfin_expand_builtin): Likewise. * config/c6x/c6x.c (c6x_expand_builtin): Likewise. * config/frv/frv.c (frv_expand_builtin): Likewise. * config/gcn/gcn.c (gcn_expand_builtin_1): Likewise. (gcn_expand_builtin): Likewise. * config/i386/i386-builtins.c (ix86_builtin_reciprocal): Likewise. (fold_builtin_cpu): Likewise. * config/i386/i386-expand.c (ix86_expand_builtin): Likewise. * config/i386/i386.c (ix86_fold_builtin): Likewise. (ix86_gimple_fold_builtin): Likewise. * config/ia64/ia64.c (ia64_fold_builtin): Likewise. (ia64_expand_builtin): Likewise. * config/iq2000/iq2000.c (iq2000_expand_builtin): Likewise. * config/mips/mips.c (mips_expand_builtin): Likewise. * config/msp430/msp430.c (msp430_expand_builtin): Likewise. * config/nds32/nds32-intrinsic.c (nds32_expand_builtin_impl): Likewise. * config/nios2/nios2.c (nios2_expand_builtin): Likewise. * config/nvptx/nvptx.c (nvptx_expand_builtin): Likewise. * config/pa/pa.c (pa_expand_builtin): Likewise. * config/pru/pru.c (pru_expand_builtin): Likewise. * config/riscv/riscv-builtins.c (riscv_expand_builtin): Likewise. * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/rs6000/rs6000-call.c (htm_expand_builtin): Likewise. (altivec_expand_dst_builtin, altivec_expand_builtin): Likewise. (rs6000_gimple_fold_builtin, rs6000_expand_builtin): Likewise. * config/rs6000/rs6000.c (rs6000_builtin_md_vectorized_function) (rs6000_builtin_reciprocal): Likewise. * config/rx/rx.c (rx_expand_builtin): Likewise. * config/s390/s390-c.c (s390_resolve_overloaded_builtin): Likewise. * config/s390/s390.c (s390_expand_builtin): Likewise. * config/sh/sh.c (sh_expand_builtin): Likewise. * config/sparc/sparc.c (sparc_expand_builtin): Likewise. (sparc_fold_builtin): Likewise. * config/spu/spu-c.c (spu_resolve_overloaded_builtin): Likewise. * config/spu/spu.c (spu_expand_builtin): Likewise. * config/stormy16/stormy16.c (xstormy16_expand_builtin): Likewise. * config/tilegx/tilegx.c (tilegx_expand_builtin): Likewise. * config/tilepro/tilepro.c (tilepro_expand_builtin): Likewise. * config/xtensa/xtensa.c (xtensa_fold_builtin): Likewise. (xtensa_expand_builtin): Likewise. gcc/ada/ PR middle-end/91421 * gcc-interface/trans.c (gigi): Call set_decl_buillt_in_function. (Call_to_gnu): Use DECL_FE_FUNCTION_CODE instead of DECL_FUNCTION_CODE. gcc/c/ PR middle-end/91421 * c-decl.c (merge_decls): Use copy_decl_built_in_function. gcc/c-family/ PR middle-end/91421 * c-common.c (resolve_overloaded_builtin): Use copy_decl_built_in_function. gcc/cp/ PR middle-end/91421 * decl.c (duplicate_decls): Use copy_decl_built_in_function. * pt.c (declare_integer_pack): Use set_decl_built_in_function. gcc/d/ PR middle-end/91421 * intrinsics.cc (maybe_set_intrinsic): Use set_decl_built_in_function. gcc/jit/ PR middle-end/91421 * jit-playback.c (new_function): Use set_decl_built_in_function. gcc/lto/ PR middle-end/91421 * lto-common.c (compare_tree_sccs_1): Use DECL_UNCHECKED_FUNCTION_CODE instead of DECL_FUNCTION_CODE. * lto-symtab.c (lto_symtab_merge_p): Likewise. From-SVN: r274404
2019-08-11d: Fix ICE: gimplification failed (gimplify.c at 13436)Iain Buclaw2-1/+6
The expression that caused the ICE ++(a += 1.0); The D front-end rewrites and applies implicit type conversions so the expression gets simplified as (int)((double) a += 1.0) += 1 The codegen pass would subsequently generate the following invalid code (int)(double) a = (int)((double) a + 1.0) + 1 The LHS expression `(int)(double) a', represented as a FIX_TRUNC_EXPR being what trips as it is not a valid lvalue for assignment. While LHS casts are stripped away, convert_expr adds a double cast because it converts the expression to its original type before converting it to its target type. There is no valid reason why this is done, so it has been removed. gcc/d/ChangeLog: PR d/90601 * d-convert.cc (convert_expr): Don't convert an expression to its original front-end type before converting to its target type. gcc/testsuite/ChangeLog: PR d/90601 * gdc.dg/pr90601.d: New test. From-SVN: r274263
2019-08-10d: Fix internal compiler error: in add_expr, at tree.c:7794Iain Buclaw2-3/+11
gcc/d/ChangeLog: PR d/91238 * d-codegen.cc (build_address): If taking the address of a CALL_EXPR, wrap it in a TARGET_EXPR. gcc/testsuite/ChangeLog: PR d/91238 * gdc.dg/pr91238.d: New test. From-SVN: r274253
2019-08-10Assorted ChangeLog cleanups.Jakub Jelinek1-12/+12
From-SVN: r274250
2019-08-10Fix ODR violation in d/runtime.ccIain Buclaw2-4/+12
gcc/d/ChangeLog: PR d/90893 * runtime.cc (enum libcall_type): Rename to... (enum d_libcall_type): ...this. (get_libcall_type): Use d_libcall_type. (build_libcall_decl): Likewise. From-SVN: r274249
2019-06-16re PR d/90603 (ICE in functionParameters, at d/dmd/expression.c:1553)Iain Buclaw16-49/+94
PR d/90603 d/dmd: Merge upstream dmd 792f0fdf2 Fixes segmentation fault in functionParameters, and other related semantic bugs in forward or recursively referenced declarations. Reviewed-on: https://github.com/dlang/dmd/pull/10046 From-SVN: r272366
2019-06-16re PR d/90863 (ICE in StatementSemanticVisitor::visit, at ↵Iain Buclaw3-3/+5
d/dmd/statementsem.c:1992) PR d/90863 d/dmd: Merge upstream dmd 6e44734cc Fixes segmentation fault in StatementSemanticVisitor::visit. Reviewed-on: https://github.com/dlang/dmd/pull/10033 From-SVN: r272352
2019-06-16re PR d/90559 (Out of memory because of negative length)Iain Buclaw7-47/+50
PR d/90559 d/dmd: Merge upstream dmd 7afcc60c3 Partially fixes out of memory because of negative length. Reviewed-on: https://github.com/dlang/dmd/pull/10025 gcc/d/ChangeLog: 2019-06-16 Iain Buclaw <ibuclaw@gdcproject.org> PR d/90559 * d-target.cc (Target::_init): Reduce max static data size to INT_MAX. From-SVN: r272351
2019-06-16d/dmd: Merge upstream dmd f8e38c001Iain Buclaw2-6/+40
Fixes bug where foreach(int) doesn't work on BigEndian targets by deprecating the use of index types smaller than a size_t/ptrdiff_t. Reviewed-on: https://github.com/dlang/dmd/pull/10009 From-SVN: r272350
2019-06-16d/dmd: Merge upstream dmd 974650488Iain Buclaw3-1/+7
Adds static function VarDeclaration::create to the dmd C++ interface. Reviewed-on: https://github.com/dlang/dmd/pull/10008 From-SVN: r272349
2019-06-16re PR d/90560 (ICE in visit, at d/dmd/dcast.c:1872)Iain Buclaw2-3/+2
PR d/90560 d/dmd: Merge upstream dmd c6887d9bb Fixes segmentation fault in castTo::CastTo::visit. Reviewed-on: https://github.com/dlang/dmd/pull/10007 From-SVN: r272348
2019-06-16re PR d/90762 (ICE in resolvePropertiesX, at d/dmd/expression.c:251)Iain Buclaw2-6/+12
PR d/90762 d/dmd: Merge upstream dmd b0cd59177 Fixes segmentation fault in resolvePropertiesX. Reviewed-on: https://github.com/dlang/dmd/pull/10006 From-SVN: r272347
2019-06-16re PR d/90761 (ICE in visit, at d/dmd/dcast.c:883)Iain Buclaw2-1/+19
PR d/90761 d/dmd: Merge upstream dmd d912f4e49 Fixes segmentation fault in implicitConvTo::ImplicitConvTo::visit. Reviewed-on: https://github.com/dlang/dmd/pull/10005 From-SVN: r272346
2019-06-16re PR d/90651 (ICE in FuncDeclaration::semantic3, at d/dmd/func.c:1524)Iain Buclaw6-35/+103
PR d/90651 d/dmd: Merge upstream dmd 0f6cbbcad Fixes segmentation fault in FuncDeclaration::semantic3. Reviewed-on: https://github.com/dlang/dmd/pull/10003 gcc/d/ChangeLog: 2019-06-16 Iain Buclaw <ibuclaw@gdcproject.org> * typeinfo.cc (object_module): New variable. (make_frontend_typeinfo): Update signature. Set temporary on generated TypeInfo classes. (create_tinfo_types): Set object_module. Move generation of front-end typeinfo into ... (create_frontend_tinfo_types): ... New function. (layout_typeinfo): Call create_frontend_tinfo_types. (layout_classinfo): Likewise. (layout_cpp_typeinfo): Likewise. (create_typeinfo): Likewise. From-SVN: r272345
2019-06-16re PR d/90650 (ICE in fold_convert_loc, at fold-const.c:2552)Iain Buclaw4-1/+21
PR d/90650 d/dmd: Merge upstream dmd ab03e2918 Fixes internal compiler error in fold_convert_loc. Reviewed-on: https://github.com/dlang/dmd/pull/9996 gcc/testsuite/ChangeLog: 2019-06-16 Iain Buclaw <ibuclaw@gdcproject.org> PR d/90650 * gdc.dg/pr90650a.d: New test. * gdc.dg/pr90650b.d: New test. From-SVN: r272344
2019-06-16re PR d/90604 (ICE in sizemask, at d/dmd/mtype.c:2542)Iain Buclaw2-4/+4
PR d/90604 d/dmd: Merge upstream dmd f30c5dc79 Fixes internal compiler error in Type::sizemask. Reviewed-on: https://github.com/dlang/dmd/pull/9998 From-SVN: r272343
2019-06-16re PR d/90602 (ICE: null field)Iain Buclaw2-4/+11
PR d/90602 d/dmd: Merge upstream dmd 420cce2a6 Fixes internal compiler error during CTFE. Reviewed-on: https://github.com/dlang/dmd/pull/9997 From-SVN: r272342
2019-06-16re PR d/90661 (ICE in AlignDeclaration::syntaxCopy, at d/dmd/attrib.c:670)Iain Buclaw2-2/+3
PR d/90661 d/dmd: Merge upstream dmd c74e624c9 Fixes segmentation fault in AlignDeclaration::syntaxCopy. Reviewed-on: https://github.com/dlang/dmd/pull/10001 From-SVN: r272341
2019-06-16re PR d/90651 (ICE in FuncDeclaration::semantic3, at d/dmd/func.c:1524)Iain Buclaw2-2/+3
PR d/90651 d/dmd: Merge upstream dmd 78dc31152 Fixes bug where the object module was not always implicitly imported. Reviewed-on: https://github.com/dlang/dmd/pull/9999 From-SVN: r272340
2019-06-16re PR d/90660 (ICE in TypeQualified::resolveHelper, at d/dmd/mtype.c:6738)Iain Buclaw2-1/+5
PR d/90660 d/dmd: Merge upstream dmd bbc5ea66a Fixes segmentation fault in TypeQualified::resolveHelper. Reviewed-on: https://github.com/dlang/dmd/pull/10000 From-SVN: r272339
2019-06-11toir.cc (pop_label): Only queue labels in a vector.Richard Biener2-7/+30
2019-06-11 Richard Biener <rguenthe@suse.de> d/90778 * toir.cc (pop_label): Only queue labels in a vector. (cmp_labels): Label decl comparator. (pop_binding_level): Pop labels in DECL_UID order to avoid debug info differences. From-SVN: r272146
2019-05-28[PATCH] Commonize anon-name generationNathan Sidwell2-7/+7
https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01699.html * tree.h (IDENTIFIER_ANON_P): New. (anon_aggrname_format, anon_aggname_p): Don't declare. (make_anon_name): Declare. * lto-streamer-out.c (DFS::DFS_write_tree_body): Use IDENTIFIER_ANON_P. (hash_tree): Likewise. * tree-streamer-out.c (write_ts_decl_minimal_tree): Likewise. * tree.c (anon_aggrname_p, anon_aggrname_format): Delete. (anon_cnt, make_anon_name): New. gcc/cp/ * cp-tree.h (make_anon_name): Drop declaration. (TYPE_UNNAMED_P): Use IDENTIFIER_ANON_P. * cp-lang.c (cxx_dwarf_name): Likewise. * class.c (find_flexarrays): Likewise. * decl.c (name_unnamed_type, xref_tag_1): Likewise. * error.c (dump_aggr_type): Likewise. * pt.c (push_template_decl_real): Likewise. * name-lookup.c (consider_binding_level): Likewise. (anon_cnt, make_anon_name): Delete. gcc/d/ * types.cc (fixup_anonymous_offset): Use IDENTIFIER_ANON_P. (layout_aggregate_members): Use make_anon_name. From-SVN: r271702