aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
AgeCommit message (Collapse)AuthorFilesLines
2022-10-30Daily bump.GCC Administrator1-0/+29
2022-10-29d: Merge upstream dmd, druntime e4f8919591, phobos 3ad507b51.Iain Buclaw50-1236/+1441
D front-end changes: - Import dmd v2.101.0-beta.1. - Add predefined version `D_Optimized' when compiling with `-O'. - Shortened method syntax (DIP1043) is now enabled by default. - Array literals assigned to `scope' array variables are now allocated on the stack. - Implement `@system' variables (DIP1035), available behind the preview feature flag `-fpreview=systemvariables'. D runtime changes: - Import druntime v2.101.0-beta.1. Phobos changes: - Import phobos v2.101.0-beta.1. - Added `std.typecons.SafeRefCounted', that can be used in `@safe' code with `-fpreview=dip1000'. gcc/d/ChangeLog: * d-attribs.cc (apply_user_attributes): Update for new front-end interface. * d-builtins.cc (d_init_versions): Predefine `D_Optimized' with compiling with optimizations enabled. * d-lang.cc (d_handle_option): Update for new front-end interface. Handle new option `-fpreview=systemvariables'. * dmd/MERGE: Merge upstream dmd e4f8919591. * dmd/VERSION: Bump version to v2.101.0-beta.1. * expr.cc (ExprVisitor::visit (AssignExp *)): Treat construction of static arrays from a call expression as a simple assignment. (ExprVisitor::visit (ArrayLiteralExp *)): Handle array literals with `scope' storage. * gdc.texi: Update documentation of `-fpreview=' options. * lang.opt (fpreview=shortenedmethods): Remove. (fpreview=systemvariables): New option. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime e4f8919591. * src/MERGE: Merge upstream phobos 3ad507b51. gcc/testsuite/ChangeLog: * gdc.dg/simd19630.d: Move tests with errors to ... * gdc.dg/simd19630b.d: ... here. New test. * gdc.dg/simd19630c.d: New test. * gdc.dg/simd_ctfe.d: Removed. * gdc.dg/simd18867.d: New test. * gdc.dg/simd19788.d: New test. * gdc.dg/simd21469.d: New test. * gdc.dg/simd21672.d: New test. * gdc.dg/simd23077.d: New test. * gdc.dg/simd23084.d: New test. * gdc.dg/simd23085.d: New test. * gdc.dg/torture/simd19632.d: New test. * gdc.dg/torture/simd20041.d: New test. * gdc.dg/torture/simd21673.d: New test. * gdc.dg/torture/simd21676.d: New test. * gdc.dg/torture/simd22438.d: New test. * gdc.dg/torture/simd23009.d: New test. * gdc.dg/torture/simd23077.d: New test. * gdc.dg/torture/simd8.d: New test. * gdc.dg/torture/simd9.d: New test. * gdc.dg/torture/simd_prefetch.d: New test.
2022-10-29d: Make TARGET_D_MINFO_SECTION hooks in elfos.h the language default.Iain Buclaw2-12/+15
Removes the last of all TARGET_D_* macro definitions in common target headers. Now everything is either defined in the D language front-end, or D-specific target headers. gcc/ChangeLog: * config/darwin-d.cc (TARGET_D_MINFO_START_NAME): Rename to ... (TARGET_D_MINFO_SECTION_START): ...this. (TARGET_D_MINFO_END_NAME): Rename to ... (TARGET_D_MINFO_SECTION_END): ... this. * config/elfos.h (TARGET_D_MINFO_SECTION): Remove. (TARGET_D_MINFO_START_NAME): Remove. (TARGET_D_MINFO_END_NAME): Remove. * config/i386/cygwin-d.cc (TARGET_D_MINFO_SECTION): Remove. (TARGET_D_MINFO_START_NAME): Remove. (TARGET_D_MINFO_END_NAME): Remove. * config/i386/winnt-d.cc (TARGET_D_MINFO_SECTION): Remove. (TARGET_D_MINFO_START_NAME): Remove. (TARGET_D_MINFO_END_NAME): Remove. * doc/tm.texi: Regenerate. * doc/tm.texi.in (TARGET_D_MINFO_START_NAME): Rename to ... (TARGET_D_MINFO_SECTION_START): ...this. (TARGET_D_MINFO_END_NAME): Rename to ... (TARGET_D_MINFO_SECTION_END): ...this. gcc/d/ChangeLog: * d-target.def (d_minfo_section): Expand documentation of hook. Default initialize to "minfo". (d_minfo_start_name): Rename to ... (d_minfo_section_start): ... this. Default initialize to "__start_minfo". (d_minfo_end_name): Rename to ... (d_minfo_section_end): ... this. Default initialize to "__stop_minfo". * modules.cc (register_moduleinfo): Use new targetdm hook names.
2022-09-28Daily bump.GCC Administrator1-0/+12
2022-09-27d: Merge upstream dmd d579c467c1, phobos 88aa69b14.Iain Buclaw43-1251/+1284
D front-end changes: - Throwing from contracts of `nothrow' functions has been deprecated, as this breaks the guarantees of `nothrow'. - Added language support for initializing the interior pointer of associative arrays using `new' keyword. Phobos changes: - The std.digest.digest module has been removed. - The std.xml module has been removed. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd d579c467c1. * decl.cc (layout_struct_initializer): Update for new front-end interface. * expr.cc (ExprVisitor::visit (AssignExp *)): Remove lowering of array assignments. (ExprVisitor::visit (NewExp *)): Add new lowering of new'ing associative arrays to an _aaNew() library call. * runtime.def (ARRAYSETASSIGN): Remove. (AANEW): Define. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime d579c467c1. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Remove rt/arrayassign.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 88aa69b14. * src/Makefile.am (PHOBOS_DSOURCES): Remove std/digest/digest.d, std/xml.d. * src/Makefile.in: Regenerate.
2022-09-16Daily bump.GCC Administrator1-0/+5
2022-09-15Move void_list_node init to common codeRichard Biener1-1/+0
All frontends replicate this, so move it. gcc/ * tree.cc (build_common_tree_nodes): Initialize void_list_node here. gcc/ada/ * gcc-interface/trans.cc (gigi): Do not initialize void_list_node. gcc/c-family/ * c-common.h (build_void_list_node): Remove. * c-common.cc (c_common_nodes_and_builtins): Do not initialize void_list_node. gcc/c/ * c-decl.cc (build_void_list_node): Remove. gcc/cp/ * decl.cc (cxx_init_decl_processing): Inline last build_void_list_node call. (build_void_list_node): Remove. gcc/d/ * d-builtins.cc (d_build_c_type_nodes): Do not initialize void_list_node. gcc/fortran/ * f95-lang.cc (gfc_init_decl_processing): Do not initialize void_list_node. gcc/go/ * go-lang.cc (go_langhook_init): Do not initialize void_list_node. gcc/jit/ * dummy-frontend.cc (jit_langhook_init): Do not initialize void_list_node. gcc/lto/ * lto-lang.cc (lto_build_c_type_nodes): Do not initialize void_list_node.
2022-08-28Daily bump.GCC Administrator1-0/+11
2022-08-28d: Merge upstream dmd 817610b16d, phobos b578dfad9Iain Buclaw40-507/+914
D front-end changes: - Import latest bug fixes to mainline. Phobos changes: - Import latest bug fixes to mainline. - std.logger module has been moved out of experimental. - Removed std.experimental.typecons module. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 817610b16d. * d-ctfloat.cc (CTFloat::parse): Update for new front-end interface. * d-lang.cc (d_parse_file): Likewise. * expr.cc (ExprVisitor::visit (AssignExp *)): Remove handling of array assignments to non-trivial static and dynamic arrays. * runtime.def (ARRAYASSIGN): Remove. (ARRAYASSIGN_L): Remove. (ARRAYASSIGN_R): Remove. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 817610b16d. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/internal/array/arrayassign.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos b578dfad9. * src/Makefile.am (PHOBOS_DSOURCES): Remove std/experimental/typecons.d. Add std/logger package. * src/Makefile.in: Regenerate.
2022-08-17Daily bump.GCC Administrator1-0/+6
2022-08-16d: Update DIP links in gdc documentation to point at upstream repositoryIain Buclaw1-6/+10
The wiki links probably worked at some point in the distant past, but now the official location of tracking all D Improvement Proposals is on the upstream dlang/DIPs GitHub repository. PR d/106638 gcc/d/ChangeLog: * gdc.texi: Update DIP links to point at upstream dlang/DIPs repository.
2022-08-16Daily bump.GCC Administrator1-0/+34
2022-08-15d: Defer compiling inline definitions until after the module has finished.Iain Buclaw3-11/+32
This is to prevent the case of when generating the methods of a struct type, we don't accidentally emit an inline function that references it, as the outer struct itself would still be incomplete. gcc/d/ChangeLog: * d-tree.h (d_defer_declaration): Declare. * decl.cc (function_needs_inline_definition_p): Defer checking DECL_UNINLINABLE and DECL_DECLARED_INLINE_P. (maybe_build_decl_tree): Call d_defer_declaration instead of build_decl_tree. * modules.cc (deferred_inline_declarations): New variable. (build_module_tree): Set deferred_inline_declarations and a handle declarations pushed to it. (d_defer_declaration): New function.
2022-08-15d: Fix internal compiler error: Segmentation fault at gimple-expr.cc:88Iain Buclaw3-1/+36
Because complex types are deprecated in the language, the new way to expose native complex types is by defining an enum with a basetype of a library-defined struct that is implicitly treated as-if it is native. As casts are not implicitly added by the front-end when downcasting from enum to its underlying type, we must insert an explicit cast during the code generation pass. PR d/106623 gcc/d/ChangeLog: * d-codegen.cc (underlying_complex_expr): New function. (d_build_call): Handle passing native complex objects as the library-defined equivalent. * d-tree.h (underlying_complex_expr): Declare. * expr.cc (ExprVisitor::visit (DotVarExp *)): Call underlying_complex_expr instead of build_vconvert. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr106623.d: New test.
2022-08-15d: Build internal TypeInfo types when module name is "object"Iain Buclaw2-2/+13
If for whatever reason the module declaration doesn't exist in the object file, ensure that the internal definitions for TypeInfo and TypeInfo_Class are still created, otherwise an ICE could occur later if they are required for a run-time helper call. gcc/d/ChangeLog: * d-compiler.cc (Compiler::onParseModule): Call create_tinfo_types when module name is object. * typeinfo.cc (create_tinfo_types): Add guard for multiple invocations.
2022-08-15d: Field names of anonymous delegates should be same as regular delegate types.Iain Buclaw1-2/+2
Doesn't change anything in the code generation or ABI, but makes it consistent with regular delegates as names would match up when inspecting tree dumps. gcc/d/ChangeLog: * d-codegen.cc (build_delegate_cst): Give anonymous delegate field names same as per ABI spec.
2022-08-10Daily bump.GCC Administrator1-0/+14
2022-08-09d: Fix undefined reference to pragma(inline) symbol (PR106563)Iain Buclaw1-19/+102
Functions that are declared `pragma(inline)' should be treated as if they are defined in every translation unit they are referenced from, regardless of visibility protection. Ensure they always get DECL_ONE_ONLY linkage, and start emitting them into other modules that import them. PR d/106563 gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set semanticRun before generating its symbol. (function_defined_in_root_p): New function. (function_needs_inline_definition_p): New function. (maybe_build_decl_tree): New function. (get_symbol_decl): Call maybe_build_decl_tree before returning symbol. (start_function): Use function_defined_in_root_p instead of inline test for locally defined symbols. (set_linkage_for_decl): Check for inline functions before private or protected symbols. gcc/testsuite/ChangeLog: * gdc.dg/torture/torture.exp (srcdir): New proc. * gdc.dg/torture/imports/pr106563math.d: New test. * gdc.dg/torture/imports/pr106563regex.d: New test. * gdc.dg/torture/imports/pr106563uni.d: New test. * gdc.dg/torture/pr106563.d: New test.
2022-08-09Daily bump.GCC Administrator1-0/+5
2022-08-08d: Fix ICE in in add_stack_var, at cfgexpand.cc:476Iain Buclaw1-0/+2
The type that triggers the ICE never got completed by the semantic analysis pass. Checking for size forces it to be done, or issue a compile-time error. PR d/106555 gcc/d/ChangeLog: * d-target.cc (Target::isReturnOnStack): Check for return type size. gcc/testsuite/ChangeLog: * gdc.dg/imports/pr106555.d: New test. * gdc.dg/pr106555.d: New test.
2022-08-04Daily bump.GCC Administrator1-0/+15
2022-08-03d: Merge upstream dmd d7772a2369, phobos 5748ca43f.Iain Buclaw34-385/+810
In upstream dmd, the compiler front-end and run-time have been merged together into one repository. Both dmd and libdruntime now track that. D front-end changes: - Deprecated `scope(failure)' blocks that contain `return' statements. - Deprecated using integers for `version' or `debug' conditions. - Deprecated returning a discarded void value from a function. - `new' can now allocate an associative array. D runtime changes: - Added avx512f detection to core.cpuid module. Phobos changes: - Changed std.experimental.logger.core.sharedLog to return shared(Logger). gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd d7772a2369. * dmd/VERSION: Bump version to v2.100.1. * d-codegen.cc (get_frameinfo): Check whether decision to generate closure changed since semantic finished. * d-lang.cc (d_handle_option): Remove handling of -fdebug=level and -fversion=level. * decl.cc (DeclVisitor::visit (VarDeclaration *)): Generate evaluation of noreturn variable initializers before throw. * expr.cc (ExprVisitor::visit (AssignExp *)): Don't generate assignment for noreturn types, only evaluate for side effects. * lang.opt (fdebug=): Undocument -fdebug=level. (fversion=): Undocument -fversion=level. libphobos/ChangeLog: * configure: Regenerate. * configure.ac (libtool_VERSION): Update to 4:0:0. * libdruntime/MERGE: Merge upstream druntime d7772a2369. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/internal/array/duplication.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 5748ca43f. * testsuite/libphobos.gc/nocollect.d:
2022-07-07Daily bump.GCC Administrator1-0/+9
2022-07-06d: Merge upstream dmd 56589f0f4, druntime 651389b5, phobos 1516ecad9.Iain Buclaw11-32/+149
D front-end changes: - Import latest bug fixes to mainline. D runtime changes: - Import latest bug fixes to mainline. Phobos changes: - Import latest bug fixes to mainline. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 56589f0f4. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 651389b5. * src/MERGE: Merge upstream phobos 1516ecad9.
2022-07-06d: Build the D sources in the front-end with -fno-exceptionsIain Buclaw1-1/+5
The D front-end does not use exceptions, but it still requires RTTI for some lowerings of convenience language features. Enforce it with by building with `-fno-exceptions'. gcc/d/ChangeLog: * Make-lang.in (NOEXCEPTION_DFLAGS): Define. (ALL_DFLAGS): Add NO_EXCEPTION_DFLAGS.
2022-06-30Daily bump.GCC Administrator1-0/+47
2022-06-29d: Fix error: aggregate value used where floating point was expectedIain Buclaw3-3/+52
Casting from vector to static array is permitted, and the frontend generates a reinterpret cast, but casting back the other way resulted in an error. This has been fixed to be properly handled in the code generation pass of VectorExp, and the conversion for lvalue and rvalue handling done in convert_expr and convert_for_rvalue respectively. PR d/106139 gcc/d/ChangeLog: * d-convert.cc (convert_expr): Handle casting from array to vector. (convert_for_rvalue): Rewrite vector to array casts of the same element type into a constructor. (convert_for_assignment): Return calling convert_for_rvalue. * expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a vector expression from a static array. * toir.cc (IRVisitor::visit (ReturnStatement *)): Call convert_for_rvalue on return value. gcc/testsuite/ChangeLog: * gdc.dg/pr106139a.d: New test. * gdc.dg/pr106139b.d: New test. * gdc.dg/pr106139c.d: New test. * gdc.dg/pr106139d.d: New test.
2022-06-29d: Fix build on aarch64-suse-linuxIain Buclaw1-5/+5
The variables being used to get the result out of TYPE_VECTOR_SUBPARTS were being flagged by -Werror=maybe-uninitialized. As they have already been checked for being constant earlier, use `to_constant' instead. gcc/d/ChangeLog: * intrinsics.cc (build_shuffle_mask_type): Use to_constant when getting the number of subparts from a vector type. (expand_intrinsic_vec_shufflevector): Likewise.
2022-06-29d: Add SIMD intrinsics module and compiler built-ins.Iain Buclaw2-0/+610
Vectors in D are exposed by the use of the `__vector(T[N])' type, and whilst most unary and binary operations work as you'd expect, there are some operations that are not possible without doing the operation unrolled, or calling some target-specific built-in, or with inline asm. This introduces a new `gcc.simd' module that introduces the following. - Prefetching has been exposed by a convenient `prefetch' function in the library. - Loading and storing from an unaligned address have been exposed by `loadUnaligned' and `storeUnaligned' intrinsics. - Vector permutations have been exposed by `shuffle`, and `shufflevector' intrinsics. - Converting between two vectors with a different element type has been exposed by a `convertvector' intrinsic. - The ternary operator has been exposed with a `blendvector' intrinsic. - Comparison operators have been exposed by `equalMask', `notEqualMask', `greaterMask', and `greaterEqualMask' intrinsics. - Logic operators have been exposed by convenient `notMask', `andAndMask', and `orOrMask' functions in the library. To be compatible with the LLVM D compiler's own SIMD intrinsic module, there is also the addition of an `extractelement' and `insertelement' convenience functions, and an alternative interface for calling the `shufflevector' function. The addition of these intrinsics lowers the boundary for users working in SIMD to get the desired codegen they want out of the compiler. Most of what is present here - apart from tests - is the adding of machinery in the intrinsics suite of functions to do validation on templated intrinsics. Whilst these are still matched from the library by their generic (untyped) signature, there is a still an assumption that what has been instantiated and handed down to the code generator is valid, because why would these definitions be found outside of the in-tree D runtime library? The majority of intrinsics are not templates, so the test on the mangled signature string still guarantees all types are as we expect them to be. However there are still a small handful of other templated intrinsics (core.bitop.{rol,ror}, core.math.toPrec, std.math.traits.isNaN, ...) that are currently unchecked, so would benefit from being included into this built-in checking function at some point in the future. gcc/d/ChangeLog: * intrinsics.cc: Include diagnostic.h, langhooks.h, vec-perm-indices.h. (maybe_set_intrinsic): Add cases for new simd intrinsics. (warn_mismatched_return_type): New function. (warn_mismatched_argument): New function. (build_shuffle_mask_type): New function. (maybe_warn_intrinsic_mismatch): New function. (expand_intrinsic_vec_cond): New function. (expand_intrinsic_vec_convert): New function. (expand_intrinsic_vec_blend): New function. (expand_intrinsic_vec_shuffle): New function. (expand_intrinsic_vec_shufflevector): New function. (expand_intrinsic_vec_load_unaligned): New function. (expand_intrinsic_vec_store_unaligned): New function. (maybe_expand_intrinsic): Check signature of intrinsic before handing off to front-end lowering. Add cases for new simd intrinsics. * intrinsics.def (INTRINSIC_LOADUNALIGNED): Define intrinsic. (INTRINSIC_STOREUNALIGNED): Define intrinsic. (INTRINSIC_SHUFFLE): Define intrinsic. (INTRINSIC_SHUFFLEVECTOR): Define intrinsic. (INTRINSIC_CONVERTVECTOR): Define intrinsic. (INTRINSIC_BLENDVECTOR): Define intrinsic. (INTRINSIC_EQUALMASK): Define intrinsic. (INTRINSIC_NOTEQUALMASK): Define intrinsic. (INTRINSIC_GREATERMASK): Define intrinsic. (INTRINSIC_GREATEREQUALMASK): Define intrinsic. libphobos/ChangeLog: * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add gcc/simd.d. * libdruntime/Makefile.in: Regenerate. * libdruntime/gcc/simd.d: New file. gcc/testsuite/ChangeLog: * gdc.dg/Wbuiltin_declaration_mismatch.d: Rename to... * gdc.dg/Wbuiltin_declaration_mismatch1.d: ...this. * gdc.dg/Wbuiltin_declaration_mismatch2.d: New test. * gdc.dg/torture/simd_blendvector.d: New test. * gdc.dg/torture/simd_cond.d: New test. * gdc.dg/torture/simd_convertvector.d: New test. * gdc.dg/torture/simd_load.d: New test. * gdc.dg/torture/simd_logical.d: New test. * gdc.dg/torture/simd_shuffle.d: New test. * gdc.dg/torture/simd_shufflevector.d: New test. * gdc.dg/torture/simd_store.d: New test.
2022-06-29Daily bump.GCC Administrator1-0/+16
2022-06-28d: Use create_tmp_var_raw and get_callee_fndeclIain Buclaw3-19/+7
A couple of small patterns that repeat are generating a temporary, and getting a function out of a CALL_EXPR. There are convenience functions for these in the common parts of gcc, use them instead. gcc/d/ChangeLog: * d-codegen.cc: Include gimple-expr.h. (force_target_expr): Use create_tmp_var_raw. * decl.cc: Inlucde gimple-expr.h. (build_local_temp): Use create_tmp_var_raw. * intrinsics.cc (expand_intrinsic_rotate): Use get_callee_fndecl. (maybe_expand_intrinsic): Likewise.
2022-06-28d: Add `@simd` and `@simd_clones` attributes to compiler and libraryIain Buclaw1-0/+65
The `@simd` attribute is equivalent to `__attribute__((simd))`, and `@simd_clones` is a convenience alias to allow specifying whether the compiler should generated masked or non-masked simd clones. gcc/d/ChangeLog: * d-attribs.cc (handle_omp_declare_simd_attribute): New function. (d_handle_simd_attribute): New function. (d_langhook_common_attribute_table): Add 'omp declare simd' attribute. (d_langhook_attribute_table): Add simd attribute. libphobos/ChangeLog: * libdruntime/gcc/attributes.d (simd): Define. gcc/testsuite/ChangeLog: * gdc.dg/attr_simd1.d: New test. * gdc.dg/attr_simd2.d: New test.
2022-06-25Daily bump.GCC Administrator1-0/+40
2022-06-24d: Give consistent error message when attribute argument not a string constantIain Buclaw1-5/+6
gcc/d/ChangeLog: * d-attribs.cc (d_handle_section_attribute): Update error message. (d_handle_symver_attribute): Likewise. (d_handle_no_sanitize_attribute): Likewise. (d_handle_visibility_attribute): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/attr_section1.d: Update dg-error. * gdc.dg/attr_visibility1.d: Likewise.
2022-06-24d: Add `@register' attribute to compiler and library.Iain Buclaw5-12/+88
The `@register` attribute specifies that a local or `__gshared` variable is to be given a register storage-class in the C sense of the term, and will be placed into a register named `registerName`. The variable needs to boiled down to a data type that fits the target register. It also cannot have either thread-local or `extern` storage. It is an error to take the address of a register variable. PR d/105413 gcc/d/ChangeLog: * d-attribs.cc (d_handle_register_attribute): New function. (d_langhook_attribute_table): Add register attribute. * d-codegen.cc (d_mark_addressable): Error if taken address of register variable. (build_frame_type): Error if register variable has non-local references. * d-tree.h (d_mark_addressable): Add complain parameter. * decl.cc (get_symbol_decl): Mark register varibles DECL_REGISTER. Error when register variable declared thread-local or extern. * expr.cc (ExprVisitor::visit (IndexExp *)): Don't complain about marking register vectors as addressable in an ARRAY_REF. libphobos/ChangeLog: * libdruntime/gcc/attributes.d (register): Define. gcc/testsuite/ChangeLog: * gdc.dg/attr_register1.d: New test. * gdc.dg/attr_register2.d: New test. * gdc.dg/attr_register3.d: New test.
2022-06-24d: Construct indexes of ARRAY_TYPE using ARRAY_REF.Iain Buclaw4-11/+35
This is a small simplification over `((T *)&array)[index]', which also allows eliding an unneccesary marking of TREE_ADDRESSABLE when the array expression is a parameter or variable declaration. gcc/d/ChangeLog: * d-codegen.cc (build_array_index): Rename to... (build_pointer_index): ...this. * d-tree.h (build_array_index): Rename declaration to... (build_pointer_index): ...this. * expr.cc (ExprVisitor::visit (IndexExp *)): Construct indexes of ARRAY_TYPE using ARRAY_REF. (ExprVisitor::visit (SliceExp *)): Update. * intrinsics.cc (expand_intrinsic_bt): Update.
2022-06-24d: Merge upstream dmd 529110f66, druntime 148608b7.Iain Buclaw19-212/+305
D front-end changes: - Import latest bug fixes to mainline. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 529110f66. * decl.cc (DeclVisitor::visit (TupleDeclaration *)): Update for new front-end interface. * types.cc (layout_aggregate_members): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 148608b7.
2022-06-23Daily bump.GCC Administrator1-0/+7
2022-06-22d: Merge upstream dmd 6203135dc, druntime e150cca1, phobos a4a18d21c.Iain Buclaw14-82/+181
D front-end changes: - Input parameters can now be applied on extern(C++) functions to bind to `const &' when the `-fpreview=in' flag is in effect. D runtime changes: - Run-time flag `--DRT-oncycle=deprecate' has been removed. Phobos changes: - Removed std.experimental.logger's capability to set the minimal LogLevel at compile time. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 6203135dc. * typeinfo.cc (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Update for new front-end interface. (SpeculativeTypeVisitor::visit (TypeStruct *)): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime e150cca1. * src/MERGE: Merge upstream phobos a4a18d21c. * testsuite/libphobos.cycles/cycles.exp (cycle_test_list): Update expected result of deprecate test.
2022-06-16Daily bump.GCC Administrator1-0/+58
2022-06-15d: Add `@no_sanitize' attribute to compiler and library.Iain Buclaw1-0/+52
The `@no_sanitize' attribute disables a particular sanitizer for this function, analogous to `__attribute__((no_sanitize))'. The library also defines `@noSanitize' to be compatible with the LLVM D compiler's `ldc.attributes'. gcc/d/ChangeLog: * d-attribs.cc (d_langhook_attribute_table): Add no_sanitize. (d_handle_no_sanitize_attribute): New function. libphobos/ChangeLog: * libdruntime/gcc/attributes.d (no_sanitize): Define. (noSanitize): Define. gcc/testsuite/ChangeLog: * gdc.dg/asan/attr_no_sanitize1.d: New test. * gdc.dg/ubsan/attr_no_sanitize2.d: New test.
2022-06-15d: Add `@visibility' and `@hidden' attributes.Iain Buclaw5-32/+127
The `@visibility' attribute is functionality the same as `__attribute__((visibility))', and `@hidden' is a convenience alias to `@visibility("hidden")' defined in the `gcc.attributes' module. As the visibility of a symbol is also indirectly controlled by the `export' keyword, the handling of this in the code generation pass has been improved so that conflicts will be appropriately diagnosed. gcc/d/ChangeLog: * d-attribs.cc (d_langhook_attribute_table): Add visibility. (insert_type_attribute): Use decl_attributes instead of merge_attributes. (insert_decl_attribute): Likewise. (apply_user_attributes): Do nothing when no UDAs applied. (d_handle_visibility_attribute): New function. * d-gimplify.cc (d_gimplify_binary_expr): Adjust. * d-tree.h (set_visibility_for_decl): Declare. * decl.cc (get_symbol_decl): Move setting of visibility flags to... (set_visibility_for_decl): ... here. New function. * types.cc (TypeVisitor::visit (TypeStruct *)): Call set_visibility_for_decl(). (TypeVisitor::visit (TypeClass *)): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/attr_visibility1.d: New test. * gdc.dg/attr_visibility2.d: New test. * gdc.dg/attr_visibility3.d: New test. libphobos/ChangeLog: * libdruntime/gcc/attributes.d (visibility): Define. (hidden): Define.
2022-06-15d: Set TYPE_ARTIFICIAL on internal TypeInfo typesIain Buclaw1-0/+1
Prevents them from triggering warnings when compiling with `-Wpadded'. gcc/d/ChangeLog: * typeinfo.cc (make_internal_typeinfo): Set TYPE_ARTIFICIAL. gcc/testsuite/ChangeLog: * gdc.dg/Wpadded.d: New test.
2022-06-15d: Delay completing aggregate and enum types until after attributes have ↵Iain Buclaw6-70/+159
been applied. Because of forward/recursive references, the TYPE_SIZE, TYPE_ALIGN, and TYPE_MODE of structs and enums were set before laying out its members. This adds a new macro TYPE_FORWARD_REFERENCES for storing those forward references against the incomplete type, laying them out after the type has been completed. Construction of the TYPE_DECL has also been moved on earlier in the type generation pass, which will allow the possibility of adding gdc-specific type attributes to the D front-end in the future. gcc/d/ChangeLog: * d-attribs.cc (apply_user_attributes): Set ATTR_FLAG_TYPE_IN_PLACE only on incomplete types. * d-codegen.cc (copy_aggregate_type): Set TYPE_STUB_DECL after copy. * d-compiler.cc (Compiler::onParseModule): Adjust. * d-tree.h (AGGREGATE_OR_ENUM_TYPE_CHECK): Define. (TYPE_FORWARD_REFERENCES): Define. * decl.cc (gcc_attribute_p): Update documentation. (DeclVisitor::visit (StructDeclaration *)): Exit before building type node if gcc.attributes symbol. (DeclVisitor::visit (ClassDeclaration *)): Build type node and add TYPE_NAME to current binding level before emitting anything else. (DeclVisitor::visit (InterfaceDeclaration *)): Likewise. (DeclVisitor::visit (EnumDeclaration *)): Likewise. (build_type_decl): Move rest_of_decl_compilation() call to finish_aggregate_type(). * types.cc (insert_aggregate_field): Move layout_decl() call to finish_aggregate_type(). (insert_aggregate_bitfield): Likewise. (layout_aggregate_members): Adjust. (finish_incomplete_fields): New function. (finish_aggregate_type): Handle forward referenced field types. Call rest_of_type_compilation() after completing the aggregate. (TypeVisitor::visit (TypeEnum *)): Don't set size and alignment until after apply_user_attributes(). Call rest_of_type_compilation() after completing the enumeral. (TypeVisitor::visit (TypeStruct *)): Call build_type_decl() before apply_user_attributes(). Don't set size, alignment, and mode until after apply_user_attributes(). (TypeVisitor::visit (TypeClass *)): Call build_type_decl() before applly_user_attributes().
2022-06-14Daily bump.GCC Administrator1-0/+31
2022-06-13d: Match function declarations of gcc built-ins from any module.Iain Buclaw3-31/+149
Declarations of recognised gcc built-in functions are now matched from any module. Previously, only the `core.stdc' package was scanned. In addition to matching of the symbol, any user-applied `@attributes' or `pragma(mangle)' name will be applied to the built-in decl as well. Because there would now be no control over where built-in declarations are coming from, the warning option `-Wbuiltin-declaration-mismatch' has been implemented in the D front-end too. gcc/d/ChangeLog: * d-builtins.cc: Include builtins.h. (gcc_builtins_libfuncs): Remove. (strip_type_modifiers): New function. (matches_builtin_type): New function. (covariant_with_builtin_type_p): New function. (maybe_set_builtin_1): Set front-end built-in if identifier matches gcc built-in name. Apply user-specified attributes and assembler name overrides to the built-in. Warn about built-in declaration mismatches. (d_builtin_function): Set IDENTIFIER_DECL_TREE of built-in functions. * d-compiler.cc (Compiler::onParseModule): Scan all modules for any identifiers that match built-in function names. * lang.opt (Wbuiltin-declaration-mismatch): New option. gcc/testsuite/ChangeLog: * gdc.dg/Wbuiltin_declaration_mismatch.d: New test. * gdc.dg/builtins.d: New test.
2022-06-13d: Improve TypeInfo errors when compiling in -fno-rtti modeIain Buclaw3-30/+45
The existing TypeInfo errors can be cryptic. This alters the diagnostic to include which expression is requiring `object.TypeInfo'. gcc/d/ChangeLog: * d-tree.h (check_typeinfo_type): Add Expression* parameter. (build_typeinfo): Likewise. Declare new override. * expr.cc (ExprVisitor): Call build_typeinfo with Expression*. * typeinfo.cc (check_typeinfo_type): Include expression in the diagnostic message. (build_typeinfo): New override. gcc/testsuite/ChangeLog: * gdc.dg/rtti1.d: New test.
2022-06-13d: Merge upstream dmd 821ed393d, druntime 454471d8, phobos 1206fc94f.Iain Buclaw24-317/+525
D front-end changes: - Import latest bug fixes to mainline. D runtime changes: - Fix duplicate Elf64_Dyn definitions on Solaris. - _d_newThrowable has been converted to a template. Phobos changes: - Import latest bug fixes to mainline. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 821ed393d. * expr.cc (ExprVisitor::visit (NewExp *)): Remove handled of allocating `@nogc' throwable object. * runtime.def (NEWTHROW): Remove. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 454471d8. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/sync/package.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 1206fc94f.
2022-06-03Daily bump.GCC Administrator1-0/+5
2022-06-02diagnostics: add SARIF output formatDavid Malcolm1-0/+11
This patch adds support to gcc's diagnostic subsystem for emitting diagnostics in SARIF, aka the Static Analysis Results Interchange Format: https://sarifweb.azurewebsites.net/ by extending -fdiagnostics-format= to add two new options: -fdiagnostics-format=sarif-stderr and: -fdiagnostics-format=sarif-file The patch targets SARIF v2.1.0 This is a JSON-based format suited for capturing the results of static analysis tools (like GCC's -fanalyzer), but it can also be used for plain GCC warnings and errors. SARIF supports per-event metadata in diagnostic paths such as ["acquire", "resource"] and ["release", "lock"] (specifically, the threadFlowLocation "kinds" property: SARIF v2.1.0 section 3.38.8), so the patch extends GCC"s diagnostic_event subclass with a "struct meaning" with similar purpose. The patch implements this for -fanalyzer so that the various state-machine-based warnings set these in the SARIF output. The heart of the implementation is in the new file diagnostic-format-sarif.cc. Much of the rest of the patch is interface classes, isolating the diagnostic subsystem (which has no knowledge of e.g. tree or langhook) from the "client" code in the compiler proper cc1 etc). The patch adds a langhook for specifying the SARIF v2.1.0 "artifact.sourceLanguage" property, based on the list in SARIF v2.1.0 Appendix J. The patch adds automated DejaGnu tests to our testsuite via new scan-sarif-file and scan-sarif-file-not directives (although these merely use regexps, rather than attempting to use a proper JSON parser). I've tested the patch by hand using the validator at: https://sarifweb.azurewebsites.net/Validation and the react-based viewer at: https://microsoft.github.io/sarif-web-component/ which successfully shows most of the information (although not paths, and not CWE IDs), and I've fixed all validation errors I've seen (though bugs no doubt remain). I've also tested the generated SARIF using the VS Code extension linked to from the SARIF website; I'm a novice with VS Code, but it seems to be able to handle my generated SARIF files (e.g. showing the data in the SARIF tab, and showing squiggly underlines under issues, and when I click on them, it visualizes the events in the path inline within the source window). Has anyone written an Emacs mode for SARIF files? (pretty please) gcc/ChangeLog: * Makefile.in (OBJS): Add tree-diagnostic-client-data-hooks.o and tree-logical-location.o. (OBJS-libcommon): Add diagnostic-format-sarif.o; reorder. (CFLAGS-tree-diagnostic-client-data-hooks.o): Add TARGET_NAME. * common.opt (fdiagnostics-format=): Add sarif-stderr and sarif-file. (sarif-stderr, sarif-file): New enum values. * diagnostic-client-data-hooks.h: New file. * diagnostic-format-sarif.cc: New file. * diagnostic-path.h (enum diagnostic_event::verb): New enum. (enum diagnostic_event::noun): New enum. (enum diagnostic_event::property): New enum. (struct diagnostic_event::meaning): New struct. (diagnostic_event::get_logical_location): New vfunc. (diagnostic_event::get_meaning): New vfunc. (simple_diagnostic_event::get_logical_location): New vfunc impl. (simple_diagnostic_event::get_meaning): New vfunc impl. * diagnostic.cc: Include "diagnostic-client-data-hooks.h". (diagnostic_initialize): Initialize m_client_data_hooks. (diagnostic_finish): Clean up m_client_data_hooks. (diagnostic_event::meaning::dump_to_pp): New. (diagnostic_event::meaning::maybe_get_verb_str): New. (diagnostic_event::meaning::maybe_get_noun_str): New. (diagnostic_event::meaning::maybe_get_property_str): New. (get_cwe_url): Make non-static. (diagnostic_output_format_init): Handle DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. * diagnostic.h (enum diagnostics_output_format): Add DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. (class diagnostic_client_data_hooks): New forward decl. (class logical_location): New forward decl. (diagnostic_context::m_client_data_hooks): New field. (diagnostic_output_format_init_sarif_stderr): New decl. (diagnostic_output_format_init_sarif_file): New decl. (get_cwe_url): New decl. * doc/invoke.texi (-fdiagnostics-format=): Add sarif-stderr and sarif-file. * doc/sourcebuild.texi (Scan a particular file): Add scan-sarif-file and scan-sarif-file-not. * langhooks-def.h (lhd_get_sarif_source_language): New decl. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): New macro. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE. * langhooks.cc (lhd_get_sarif_source_language): New. * langhooks.h (lang_hooks::get_sarif_source_language): New field. * logical-location.h: New file. * plugin.cc (struct for_each_plugin_closure): New. (for_each_plugin_cb): New. (for_each_plugin): New. * plugin.h (for_each_plugin): New decl. * tree-diagnostic-client-data-hooks.cc: New file. * tree-diagnostic.cc: Include "diagnostic-client-data-hooks.h". (tree_diagnostics_defaults): Populate m_client_data_hooks. * tree-logical-location.cc: New file. * tree-logical-location.h: New file. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/analyzer/ChangeLog: * checker-path.cc (checker_event::get_meaning): New. (function_entry_event::get_meaning): New. (state_change_event::get_desc): Add dump of meaning of the event to the -fanalyzer-verbose-state-changes output. (state_change_event::get_meaning): New. (cfg_edge_event::get_meaning): New. (call_event::get_meaning): New. (return_event::get_meaning): New. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New. * checker-path.h: Include "tree-logical-location.h". (checker_event::checker_event): Construct m_logical_loc. (checker_event::get_logical_location): New. (checker_event::get_meaning): New decl. (checker_event::m_logical_loc): New. (function_entry_event::get_meaning): New decl. (state_change_event::get_meaning): New decl. (cfg_edge_event::get_meaning): New decl. (call_event::get_meaning): New decl. (return_event::get_meaning): New decl. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New decl. * pending-diagnostic.h: Include "diagnostic-path.h". (pending_diagnostic::get_meaning_for_state_change): New vfunc. * sm-file.cc (file_diagnostic::get_meaning_for_state_change): New vfunc impl. * sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change): Likewise. * sm-sensitive.cc (exposure_through_output_file::get_meaning_for_state_change): Likewise. * sm-taint.cc (taint_diagnostic::get_meaning_for_state_change): Likewise. * varargs.cc (va_list_sm_diagnostic::get_meaning_for_state_change): Likewise. gcc/c/ChangeLog: * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (c_get_sarif_source_language): New. * c-tree.h (c_get_sarif_source_language): New decl. gcc/cp/ChangeLog: * cp-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (cp_get_sarif_source_language): New. gcc/d/ChangeLog: * d-lang.cc (d_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/fortran/ChangeLog: * f95-lang.cc (gfc_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/go/ChangeLog: * go-lang.cc (go_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/objc/ChangeLog: * objc-act.h (objc_get_sarif_source_language): New decl. * objc-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (objc_get_sarif_source_language): New. gcc/testsuite/ChangeLog: * c-c++-common/diagnostic-format-sarif-file-1.c: New test. * c-c++-common/diagnostic-format-sarif-file-2.c: New test. * c-c++-common/diagnostic-format-sarif-file-3.c: New test. * c-c++-common/diagnostic-format-sarif-file-4.c: New test. * gcc.dg/analyzer/file-meaning-1.c: New test. * gcc.dg/analyzer/malloc-meaning-1.c: New test. * gcc.dg/analyzer/malloc-sarif-1.c: New test. * gcc.dg/plugin/analyzer_gil_plugin.c (gil_diagnostic::get_meaning_for_state_change): New vfunc impl. * gcc.dg/plugin/diagnostic-test-paths-5.c: New test. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-paths-5.c to tests for diagnostic_plugin_test_paths.c. * lib/gcc-dg.exp: Load scansarif.exp. * lib/scansarif.exp: New test. libatomic/ChangeLog: * testsuite/lib/libatomic.exp: Add load_gcc_lib of scansarif.exp. libgomp/ChangeLog: * testsuite/lib/libgomp.exp: Add load_gcc_lib of scansarif.exp. libitm/ChangeLog: * testsuite/lib/libitm.exp: Add load_gcc_lib of scansarif.exp. libphobos/ChangeLog: * testsuite/lib/libphobos-dg.exp: Add load_gcc_lib of scansarif.exp. Signed-off-by: David Malcolm <dmalcolm@redhat.com>