aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg
AgeCommit message (Collapse)AuthorFilesLines
2023-03-03d: Allow vectors to be compared for identity [PR108946]Iain Buclaw10-20/+30
Vector equality and comparisons are now accepted by the language implementation, but identity wasn't. Implement it as an extra integer comparison of the bit-casted bitmask. PR d/108946 gcc/d/ChangeLog: * d-target.cc (Target::isVectorOpSupported): Allow identity ops. * expr.cc (ExprVisitor::visit (IdentityExp *)): Handle vector identity comparisons. gcc/testsuite/ChangeLog: * gdc.dg/simd2a.d: Update test. * gdc.dg/simd2b.d: Likewise. * gdc.dg/simd2c.d: Likewise. * gdc.dg/simd2d.d: Likewise. * gdc.dg/simd2e.d: Likewise. * gdc.dg/simd2f.d: Likewise. * gdc.dg/simd2g.d: Likewise. * gdc.dg/simd2h.d: Likewise. * gdc.dg/simd2i.d: Likewise. * gdc.dg/simd2j.d: Likewise.
2023-03-03d: Fix ICE on explicit immutable struct import [PR108877]Iain Buclaw2-0/+15
Const and immutable types are built as variants of the type they are derived from, and TYPE_STUB_DECL is not set for these variants. PR d/108877 gcc/d/ChangeLog: * imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call make_import on TYPE_MAIN_VARIANT. (ImportVisitor::visit (AggregateDeclaration *)): Likewise. (ImportVisitor::visit (ClassDeclaration *)): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/imports/pr108877a.d: New test. * gdc.dg/pr108877.d: New test.
2023-03-03d: Add test for PR d/108167 to the testsuite [PR108167]Iain Buclaw1-0/+5
The D front-end implementation got fixed in upstream, add test to the gdc testsuite to check we don't regress on it. PR d/108167 gcc/testsuite/ChangeLog: * gdc.dg/pr108167.d: New test.
2023-03-03d: vector float comparison doesn't result in 0 or -1 [PR108945]Iain Buclaw1-0/+12
When comparing two vectors, the type of vector was used as the result of the condition result. This meant that for floating point comparisons, each value would either be `0.0' or `-1.0' reinterpreted as an integer, not the expected integral bitmask values `0' and `-1'. Instead, use the comparison type determined by truth_type_for as the result of the comparison. If a reinterpret is later required by the final conversion for generating CmpExp, it is still only going to reinterpret one integer kind as another. PR d/108945 gcc/d/ChangeLog: * d-codegen.cc (build_boolop): Evaluate vector comparison as the truth_type_for vector type. gcc/testsuite/ChangeLog: * gdc.dg/pr108945.d: New test.
2023-02-21d: Merge upstream dmd, druntime 09faa4eacd, phobos 13ef27a56.Iain Buclaw10-60/+60
D front-end changes: - Import dmd v2.102.0-beta.1 - `static assert' now supports multiple message arguments. D runtime changes: - Import druntime v2.102.0-beta.1 - The default `Throwable.TraceInfo' generation now is `@nogc'. - `Object.factory' method has now been deprecated. Phobos changes: - Import phobos v2.102.0-beta.1 - Added float- and double-precision implementations for log function families in std.math. - `std.typecons.Unique' now calls `destroy` on struct types gcc/d/ChangeLog: * Make-lang.in (D_FRONTEND_OBJS): Add d/location.o. * d-lang.cc (d_init_options): Update for new front-end interface. (d_post_options): Call Loc::set after handling options. * dmd/MERGE: Merge upstream dmd 09faa4eacd. * dmd/VERSION: Bump version to v2.102.0-beta.1. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 09faa4eacd. * src/MERGE: Merge upstream phobos 13ef27a56. * testsuite/libphobos.exceptions/refcounted.d: Add test for chained reference counted exceptions. * testsuite/libphobos.shared/finalize.d: Add dg-warning for deprecated factory interfaces. * testsuite/libphobos.gc/issue22843.d: New test. gcc/testsuite/ChangeLog: * gdc.dg/simd2a.d: Update. * gdc.dg/simd2b.d: Update. * gdc.dg/simd2c.d: Update. * gdc.dg/simd2d.d: Update. * gdc.dg/simd2e.d: Update. * gdc.dg/simd2f.d: Update. * gdc.dg/simd2g.d: Update. * gdc.dg/simd2h.d: Update. * gdc.dg/simd2i.d: Update. * gdc.dg/simd2j.d: Update.
2023-02-21d: Set doing_semantic_analysis_p before calling functionSemantic3Iain Buclaw1-0/+53
As functions which have semantic analysis ran late may still require the use of CTFE built-ins to be evaluated. gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set doing_semantic_analysis_p before calling functionSemantic3. gcc/testsuite/ChangeLog: * gdc.dg/ctfeintrinsics.d: New test.
2023-01-16Update copyright years.Jakub Jelinek8-8/+8
2022-12-12d: Fix undefined reference to nested lambda in template (PR108055)Iain Buclaw4-0/+75
Sometimes, nested lambdas of templated functions get no code generation due to them being marked as instantianted outside of all modules being compiled in the current compilation unit. This despite enclosing template instances being marked as instantiated inside the current compilation unit. To fix, all enclosing templates are now checked in `function_defined_in_root_p'. Because of this change, `function_needs_inline_definition_p' has also been fixed up to only check whether the regular function definition itself is to be emitted in the current compilation unit. PR d/108055 gcc/d/ChangeLog: * decl.cc (function_defined_in_root_p): Check all enclosing template instances for definition in a root module. (function_needs_inline_definition_p): Replace call to function_defined_in_root_p with test for outer module `isRoot'. gcc/testsuite/ChangeLog: * gdc.dg/torture/imports/pr108055conv.d: New. * gdc.dg/torture/imports/pr108055spec.d: New. * gdc.dg/torture/imports/pr108055write.d: New. * gdc.dg/torture/pr108055.d: New test.
2022-12-11d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)Iain Buclaw4-0/+10
The visitor for lowering IMPORTED_DECLs did not have an override for dealing with importing OverloadSet symbols. This has now been implemented in the code generator. PR d/108050 gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl returning a TREE_LIST. * imports.cc (ImportVisitor::visit (OverloadSet *)): New override. gcc/testsuite/ChangeLog: * gdc.dg/imports/pr108050/mod1.d: New. * gdc.dg/imports/pr108050/mod2.d: New. * gdc.dg/imports/pr108050/package.d: New. * gdc.dg/pr108050.d: New test.
2022-11-30d: Fix ICE on named continue label in an unrolled loop [PR107592]Iain Buclaw1-0/+13
Continue labels in an unrolled loop require a unique label per iteration. Previously this used the Statement body node for each unrolled iteration to generate a new entry in the label hash table. This does not work when the continue label has an identifier, as said named label is pointing to the outer UnrolledLoopStatement node. What would happen is that during the lowering of `continue label', an automatic label associated with the unrolled loop would be generated, and a jump to that label inserted, but because it was never pushed by the visitor for the loop itself, it subsequently never gets emitted. To fix, correctly use the UnrolledLoopStatement as the key to look up and store the break/continue label pair, but remove the continue label from the value entry after every loop to force a new label to be generated by the next call to `push_continue_label' PR d/107592 gcc/d/ChangeLog: * toir.cc (IRVisitor::push_unrolled_continue_label): New method. (IRVisitor::pop_unrolled_continue_label): New method. (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of push_continue_label and pop_continue_label. gcc/testsuite/ChangeLog: * gdc.dg/pr107592.d: New test.
2022-11-05d: Adjust test to pass when compiling with -m32Iain Buclaw1-2/+2
Noticed when running on x86_64-linux-gnu with `-m32', this test triggered other errors. Adjusted the test to use a different register that is common between x86 and x86_64. gcc/testsuite/ChangeLog: * gdc.dg/attr_register2.d: Adjust test.
2022-11-05d: Add support for vector comparison operatorsIain Buclaw11-100/+60
The front-end added semantic support to permit comparing two vector expressions. This removes the restriction in the code generator, as well as the intrisics that previously exposed the same operation. gcc/d/ChangeLog: * d-target.cc (Target::isVectorOpSupported): Remove cases for comparison operators. * intrinsics.cc (maybe_set_intrinsic): Remove cases for vector comparison intrinsics. (maybe_warn_intrinsic_mismatch): Likewise. (expand_intrinsic_vec_cond): Remove. (maybe_expand_intrinsic): Remove cases for vector comparison intrinsics. * intrinsics.def (INTRINSIC_EQUALMASK): Remove. (INTRINSIC_NOTEQUALMASK): Remove. (INTRINSIC_GREATERMASK): Remove. (INTRINSIC_GREATEREQUALMASK): Remove. libphobos/ChangeLog: * libdruntime/gcc/simd.d (equalMask): Implement using generics. (notEqualMask): Likewise. (greaterMask): Likewise. (greaterOrEqualMask): Likewise. (notMask): Likewise. (andAndMask): Likewise. (orOrMask): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/Wbuiltin_declaration_mismatch2.d: Remove comparision tests. * gdc.dg/simd2a.d: Update comparison tests. * gdc.dg/simd2b.d: Likewise. * gdc.dg/simd2c.d: Likewise. * gdc.dg/simd2d.d: Likewise. * gdc.dg/simd2e.d: Likewise. * gdc.dg/simd2f.d: Likewise. * gdc.dg/simd2g.d: Likewise. * gdc.dg/simd2h.d: Likewise. * gdc.dg/simd2i.d: Likewise. * gdc.dg/simd2j.d: Likewise.
2022-10-29d: Merge upstream dmd, druntime e4f8919591, phobos 3ad507b51.Iain Buclaw21-98/+356
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-09-20replace "the the" typosMartin Liska1-1/+1
gcc/ada/ChangeLog: * exp_ch6.adb: Replace "the the" with "the". * sem_ch6.adb: Likewise. * sem_disp.ads: Likewise. gcc/ChangeLog: * ctfc.cc (ctf_add_string): Replace "the the" with "the". * doc/md.texi: Likewise. * gimple-range-infer.cc (non_null_loadstore): Likewise. gcc/fortran/ChangeLog: * gfortran.texi: Replace "the the" with "the". gcc/testsuite/ChangeLog: * g++.dg/warn/Wclass-memaccess.C: Replace "the the" with "the". * g++.dg/warn/Wconversion-real-integer2.C: Likewise. * gcc.target/powerpc/p9-extract-1.c: Likewise. * gcc.target/s390/s390.exp: Likewise. * gcc.target/s390/zvector/vec-cmp-2.c: Likewise. * gdc.dg/torture/simd_store.d: Likewise. * gfortran.dg/actual_array_offset_1.f90: Likewise. * gfortran.dg/pdt_15.f03: Likewise. * gfortran.dg/pointer_array_8.f90: Likewise.
2022-08-15d: Fix internal compiler error: Segmentation fault at gimple-expr.cc:88Iain Buclaw1-0/+28
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-09d: Fix undefined reference to pragma(inline) symbol (PR106563)Iain Buclaw5-0/+59
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-08d: Fix ICE in in add_stack_var, at cfgexpand.cc:476Iain Buclaw2-0/+14
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-06-29d: Fix error: aggregate value used where floating point was expectedIain Buclaw4-0/+126
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: Add SIMD intrinsics module and compiler built-ins.Iain Buclaw10-0/+1368
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-28d: Add `@simd` and `@simd_clones` attributes to compiler and libraryIain Buclaw2-0/+56
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-24d: Give consistent error message when attribute argument not a string constantIain Buclaw2-2/+2
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 Buclaw3-0/+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-15d: Add `@no_sanitize' attribute to compiler and library.Iain Buclaw2-0/+71
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 Buclaw3-0/+80
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/+4
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-13d: Match function declarations of gcc built-ins from any module.Iain Buclaw2-0/+54
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 Buclaw1-0/+18
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-04-04d: Compile simd_ctfe.d only on avx_runtime or vect_sizes_16B_8B targetsIain Buclaw1-1/+2
PR d/104740 gcc/testsuite/ChangeLog: * gdc.dg/simd_ctfe.d: Compile with target avx_runtime or vect_sizes_16B_8B.
2022-04-02d: Merge upstream dmd 47871363d, druntime, c52e28b7, phobos 99e9c1b77.Iain Buclaw1-0/+27
D front-end changes: - Import dmd v2.099.1-beta.1. - The address of NRVO variables is now stored in scoped closures when they have nested references. - Using `__traits(parameters)' in foreach loops now always returns the parameters to the function the foreach appears within. Previously, when used inside a `foreach' using an overloaded `opApply', the trait would yield the parameters to the delegate. - The deprecation period of unannotated `asm' blocks has been ended. - The `inout' attribute no longer implies the `return' attribute. - Added new `D_PreConditions', `D_PostConditions', and `D_Invariants' version identifiers. D runtime changes: - Import druntime v2.099.1-beta.1. Phobos changes: - Import phobos v2.099.1-beta.1. - `Nullable' in `std.typecons' can now act as a range. - std.experimental.logger default level changed to `info' instead of `warning'. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 47871363d. * d-builtins.cc (d_init_versions): Add predefined version identifiers D_PreConditions, D_PostConditions, and D_Invariants. * d-codegen.cc (d_build_call): Update for new front-end interface. (build_frame_type): Generate reference field for NRVO variables with nested references. (build_closure): Generate assignment of return address to closure. * d-tree.h (DECL_INSTANTIATED): Use DECL_LANG_FLAG_2. (bind_expr): Remove. * decl.cc (DeclVisitor::visit (FuncDeclaration *)): Update for new front-end interface. (get_symbol_decl): Likewise. (get_decl_tree): Check DECL_LANG_FRAME_FIELD before DECL_LANG_NRVO. Dereference the field when both are set. * expr.cc (ExprVisitor::visit (DeleteExp *)): Update for new front-end interface. * modules.cc (get_internal_fn): Likewise. * toir.cc (IRVisitor::visit (ReturnStatement *)): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime c52e28b7. * libdruntime/Makefile.am (DRUNTIME_DSOURCES_OPENBSD): Add core/sys/openbsd/pwd.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 99e9c1b77. * testsuite/libphobos.exceptions/message_with_null.d: New test. gcc/testsuite/ChangeLog: * gdc.dg/nrvo1.d: New test.
2022-03-21d: Fix internal compiler error: in build_complex, at tree.c:2358Iain Buclaw1-0/+14
The conversion from the special _Complex enum to native complex used build_complex, however the input value isn't necessarily a literal. PR d/105004 gcc/d/ChangeLog: * d-codegen.cc (build_struct_literal): Use complex_expr to build complex expressions from __c_complex types. gcc/testsuite/ChangeLog: * gdc.dg/pr105004.d: New test.
2022-02-28d: Merge upstream dmd cf63dd8e5, druntime caf14b0f, phobos 41aaf8c26.Iain Buclaw4-2/+53
D front-end changes: - Import dmd v2.099.0-rc.1. - The `main' can now return type `noreturn' and supports return inference. D Runtime changes: - Import druntime v2.099.0-rc.1. - C bindings for stat_t on powerpc-linux has been fixed. Phobos changes: - Import phobos v2.099.0-rc.1. gcc/d/ChangeLog: * d-target.cc (Target::_init): Initialize C type size fields. * dmd/MERGE: Merge upstream dmd cf63dd8e5. * dmd/VERSION: Update version to v2.099.0-rc.1. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime caf14b0f. * src/MERGE: Merge upstream phobos 41aaf8c26. gcc/testsuite/ChangeLog: * gdc.dg/torture/simd7413a.d: Update. * gdc.dg/ubsan/pr88957.d: Update. * gdc.dg/simd18489.d: New test. * gdc.dg/torture/simd21727.d: New test.
2022-02-20d: Merge upstream dmd cb49e99f8, druntime 55528bd1, phobos 1a3e80ec2.Iain Buclaw1-0/+12
D front-end changes: - Import dmd v2.099.0-beta.1. - It's now an error to use `alias this' for partial assignment. - The `delete' keyword has been removed from the language. - Using `this' and `super' as types has been removed from the language, the parser no longer specially handles this wrong code with an informative error. D Runtime changes: - Import druntime v2.099.0-beta.1. Phobos changes: - Import phobos v2.099.0-beta.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd cb49e99f8. * dmd/VERSION: Update version to v2.099.0-beta.1. * decl.cc (layout_class_initializer): Update call to NewExp::create. * expr.cc (ExprVisitor::visit (DeleteExp *)): Remove handling of deleting arrays and pointers. (ExprVisitor::visit (DotVarExp *)): Convert complex types to the front-end library type representing them. (ExprVisitor::visit (StringExp *)): Use getCodeUnit instead of charAt to get the value of each index in a string expression. * runtime.def (DELMEMORY): Remove. (DELARRAYT): Remove. * types.cc (TypeVisitor::visit (TypeEnum *)): Handle anonymous enums. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 55528bd1. * src/MERGE: Merge upstream phobos 1a3e80ec2. * testsuite/libphobos.hash/test_hash.d: Update. * testsuite/libphobos.betterc/test19933.d: New test.
2022-01-03Update copyright years.Jakub Jelinek8-8/+8
2021-11-30d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)Iain Buclaw38-284/+361
The D front-end is now itself written in D, in order to build GDC, you will need a working GDC compiler (GCC version 9.1 or later). GCC changes: - Add support for bootstrapping the D front-end. These add the required components in order to have a D front-end written in D itself. Because the compiler front-end only depends on the core runtime modules, only libdruntime is built for the bootstrap stages. D front-end changes: - Import dmd v2.098.0-beta.1. Druntime changes: - Import druntime v2.098.0-beta.1. Phobos changes: - Import phobos v2.098.0-beta.1. The jump from v2.076.1 to v2.098.0 covers nearly 4 years worth of development on the D programming language and run-time libraries. ChangeLog: * Makefile.def: Add bootstrap to libbacktrace, libphobos, zlib, and libatomic. * Makefile.in: Regenerate. * Makefile.tpl (POSTSTAGE1_HOST_EXPORTS): Fix command for GDC. (STAGE1_CONFIGURE_FLAGS): Add --with-libphobos-druntime-only if target-libphobos-bootstrap. (STAGE2_CONFIGURE_FLAGS): Likewise. * configure: Regenerate. * configure.ac: Add support for bootstrapping D front-end. config/ChangeLog: * acx.m4 (ACX_PROG_GDC): New m4 function. gcc/ChangeLog: * Makefile.in (GDC): New variable. (GDCFLAGS): New variable. * configure: Regenerate. * configure.ac: Add call to ACX_PROG_GDC. Substitute GDCFLAGS. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd b8384668f. * Make-lang.in (d-warn): Use strict warnings. (DMD_WARN_CXXFLAGS): Remove. (DMD_COMPILE): Remove. (CHECKING_DFLAGS): Define. (WARN_DFLAGS): Define. (ALL_DFLAGS): Define. (DCOMPILE.base): Define. (DCOMPILE): Define. (DPOSTCOMPILE): Define. (DLINKER): Define. (DLLINKER): Define. (D_FRONTEND_OBJS): Add new dmd front-end objects. (D_GENERATED_SRCS): Remove. (D_GENERATED_OBJS): Remove. (D_ALL_OBJS): Remove D_GENERATED_OBJS. (d21$(exeext)): Build using DLLINKER and -static-libphobos. (d.tags): Remove dmd/*.c and dmd/root/*.c. (d.mostlyclean): Remove D_GENERATED_SRCS, d/idgen$(build_exeext), d/impcnvgen$(build_exeext). (D_INCLUDES): Include $(srcdir)/d/dmd/res. (CFLAGS-d/id.o): Remove. (CFLAGS-d/impcnvtab.o): Remove. (d/%.o): Build using DCOMPILE and DPOSTCOMPILE. Update dependencies from d/dmd/%.c to d/dmd/%.d. (d/idgen$(build_exeext)): Remove. (d/impcnvgen$(build_exeext)): Remove. (d/id.c): Remove. (d/id.h): Remove. (d/impcnvtab.c): Remove. (d/%.dmdgen.o): Remove. (D_SYSTEM_H): Remove. (d/idgen.dmdgen.o): Remove. (d/impcnvgen.dmdgen.o): Remove. * config-lang.in (boot_language): New variable. * d-attribs.cc: Include dmd/expression.h. * d-builtins.cc: Include d-frontend.h. (build_frontend_type): Update for new front-end interface. (d_eval_constant_expression): Likewise. (d_build_builtins_module): Likewise. (maybe_set_builtin_1): Likewise. (d_build_d_type_nodes): Likewise. * d-codegen.cc (d_decl_context): Likewise. (declaration_reference_p): Likewise. (declaration_type): Likewise. (parameter_reference_p): Likewise. (parameter_type): Likewise. (get_array_length): Likewise. (build_delegate_cst): Likewise. (build_typeof_null_value): Likewise. (identity_compare_p): Likewise. (lower_struct_comparison): Likewise. (build_filename_from_loc): Likewise. (build_assert_call): Remove LIBCALL_SWITCH_ERROR. (build_bounds_index_condition): Call LIBCALL_ARRAYBOUNDS_INDEXP on bounds error. (build_bounds_slice_condition): Call LIBCALL_ARRAYBOUNDS_SLICEP on bounds error. (array_bounds_check): Update for new front-end interface. (checkaction_trap_p): Handle CHECKACTION_context. (get_function_type): Update for new front-end interface. (d_build_call): Likewise. * d-compiler.cc: Remove include of dmd/scope.h. (Compiler::genCmain): Remove. (Compiler::paintAsType): Update for new front-end interface. (Compiler::onParseModule): Likewise. * d-convert.cc (convert_expr): Remove call to LIBCALL_ARRAYCAST. (convert_for_rvalue): Update for new front-end interface. (convert_for_assignment): Likewise. (convert_for_condition): Likewise. (d_array_convert): Likewise. * d-diagnostic.cc (error): Remove. (errorSupplemental): Remove. (warning): Remove. (warningSupplemental): Remove. (deprecation): Remove. (deprecationSupplemental): Remove. (message): Remove. (vtip): New. * d-frontend.cc (global): Remove. (Global::_init): Remove. (Global::startGagging): Remove. (Global::endGagging): Remove. (Global::increaseErrorCount): Remove. (Loc::Loc): Remove. (Loc::toChars): Remove. (Loc::equals): Remove. (isBuiltin): Update for new front-end interface. (eval_builtin): Likewise. (getTypeInfoType): Likewise. (inlineCopy): Remove. * d-incpath.cc: Include d-frontend.h. (add_globalpaths): Call d_gc_malloc to allocate Strings. (add_filepaths): Likewise. * d-lang.cc: Include dmd/id.h, dmd/root/file.h, d-frontend.h. Remove include of dmd/mars.h, id.h. (entrypoint_module): Remove. (entrypoint_root_module): Remove. (deps_write_string): Update for new front-end interface. (deps_write): Likewise. (d_init_options): Call rt_init. Remove setting global params that are default initialized by the front-end. (d_handle_option): Handle OPT_fcheckaction_, OPT_fdump_c___spec_, OPT_fdump_c___spec_verbose, OPT_fextern_std_, OPT_fpreview, OPT_revert, OPT_fsave_mixins_, and OPT_ftransition. (d_post_options): Propagate dip1021 and dip1000 preview flags to dip25, and flag_diagnostics_show_caret to printErrorContext. (d_add_entrypoint_module): Remove. (d_parse_file): Update for new front-end interface. (d_type_promotes_to): Likewise. (d_types_compatible_p): Likewise. * d-longdouble.cc (CTFloat::zero): Remove. (CTFloat::one): Remove. (CTFloat::minusone): Remove. (CTFloat::half): Remove. * d-system.h (POSIX): Remove. (realpath): Remove. (isalpha): Remove. (isalnum): Remove. (isdigit): Remove. (islower): Remove. (isprint): Remove. (isspace): Remove. (isupper): Remove. (isxdigit): Remove. (tolower): Remove. (_mkdir): Remove. (INT32_MAX): Remove. (INT32_MIN): Remove. (INT64_MIN): Remove. (UINT32_MAX): Remove. (UINT64_MAX): Remove. * d-target.cc: Include calls.h. (target): Remove. (define_float_constants): Remove initialization of snan. (Target::_init): Update for new front-end interface. (Target::isVectorTypeSupported): Likewise. (Target::isVectorOpSupported): Remove cases for unordered operators. (TargetCPP::typeMangle): Update for new front-end interface. (TargetCPP::parameterType): Likewise. (Target::systemLinkage): Likewise. (Target::isReturnOnStack): Likewise. (Target::isCalleeDestroyingArgs): Define. (Target::preferPassByRef): Define. * d-tree.h (d_add_entrypoint_module): Remove. * decl.cc (gcc_attribute_p): Update for new front-end interface. (apply_pragma_crt): Define. (DeclVisitor::visit(PragmaDeclaration *)): Handle pragmas crt_constructor and crt_destructor. (DeclVisitor::visit(TemplateDeclaration *)): Update for new front-end interface. (DeclVisitor::visit): Likewise. (DeclVisitor::finish_vtable): Likewise. (get_symbol_decl): Error if template has more than one nesting context. Update for new front-end interface. (make_thunk): Update for new front-end interface. (get_vtable_decl): Likewise. * expr.cc (ExprVisitor::visit): Likewise. (build_return_dtor): Likewise. * imports.cc (ImportVisitor::visit): Likewise. * intrinsics.cc: Include dmd/expression.h. Remove include of dmd/mangle.h. (maybe_set_intrinsic): Update for new front-end interface. * intrinsics.def (INTRINSIC_ROL): Update intrinsic signature. (INTRINSIC_ROR): Likewise. (INTRINSIC_ROR_TIARG): Likewise. (INTRINSIC_TOPREC): Likewise. (INTRINSIC_TOPRECL): Likewise. (INTRINSIC_TAN): Update intrinsic module and signature. (INTRINSIC_ISNAN): Likewise. (INTRINSIC_ISFINITE): Likewise. (INTRINSIC_COPYSIGN): Define intrinsic. (INTRINSIC_COPYSIGNI): Define intrinsic. (INTRINSIC_EXP): Update intrinsic module. (INTRINSIC_EXPM1): Likewise. (INTRINSIC_EXP2): Likewise. (INTRINSIC_LOG): Likewise. (INTRINSIC_LOG2): Likewise. (INTRINSIC_LOG10): Likewise. (INTRINSIC_POW): Likewise. (INTRINSIC_ROUND): Likewise. (INTRINSIC_FLOORF): Likewise. (INTRINSIC_FLOOR): Likewise. (INTRINSIC_FLOORL): Likewise. (INTRINSIC_CEILF): Likewise. (INTRINSIC_CEIL): Likewise. (INTRINSIC_CEILL): Likewise. (INTRINSIC_TRUNC): Likewise. (INTRINSIC_FMIN): Likewise. (INTRINSIC_FMAX): Likewise. (INTRINSIC_FMA): Likewise. (INTRINSIC_VA_ARG): Update intrinsic signature. (INTRINSIC_VASTART): Likewise. * lang.opt (fcheck=): Add alternate aliases for contract switches. (fcheckaction=): New option. (check_action): New Enum and EnumValue entries. (fdump-c++-spec-verbose): New option. (fdump-c++-spec=): New option. (fextern-std=): New option. (extern_stdcpp): New Enum and EnumValue entries (fpreview=): New options. (frevert=): New options. (fsave-mixins): New option. (ftransition=): Update options. * modules.cc (get_internal_fn): Replace Prot with Visibility. (build_internal_fn): Likewise. (build_dso_cdtor_fn): Likewise. (build_module_tree): Remove check for __entrypoint module. * runtime.def (P5): Define. (ARRAYBOUNDS_SLICEP): Define. (ARRAYBOUNDS_INDEXP): Define. (NEWTHROW): Define. (ADCMP2): Remove. (ARRAYCAST): Remove. (SWITCH_STRING): Remove. (SWITCH_USTRING): Remove. (SWITCH_DSTRING): Remove. (SWITCH_ERROR): Remove. * toir.cc (IRVisitor::visit): Update for new front-end interface. (IRVisitor::check_previous_goto): Remove checks for case and default statements. (IRVisitor::visit(SwitchStatement *)): Remove handling of string switch conditions. * typeinfo.cc: Include d-frontend.h. (get_typeinfo_kind): Update for new front-end interface. (make_frontend_typeinfo): Likewise. (TypeInfoVisitor::visit): Likewise. (builtin_typeinfo_p): Likewise. (get_typeinfo_decl): Likewise. (build_typeinfo): Likewise. * types.cc (valist_array_p): Likewise. (make_array_type): Likewise. (merge_aggregate_types): Likewise. (TypeVisitor::visit(TypeBasic *)): Likewise. (TypeVisitor::visit(TypeFunction *)): Likewise. (TypeVisitor::visit(TypeStruct *)): Update comment. * verstr.h: Removed. * d-frontend.h: New file. gcc/po/ChangeLog: * EXCLUDES: Remove d/dmd sources from list. gcc/testsuite/ChangeLog: * gdc.dg/Wcastresult2.d: Update test. * gdc.dg/asm1.d: Likewise. * gdc.dg/asm2.d: Likewise. * gdc.dg/asm3.d: Likewise. * gdc.dg/gdc282.d: Likewise. * gdc.dg/imports/gdc170.d: Likewise. * gdc.dg/intrinsics.d: Likewise. * gdc.dg/pr101672.d: Likewise. * gdc.dg/pr90650a.d: Likewise. * gdc.dg/pr90650b.d: Likewise. * gdc.dg/pr94777a.d: Likewise. * gdc.dg/pr95250.d: Likewise. * gdc.dg/pr96869.d: Likewise. * gdc.dg/pr98277.d: Likewise. * gdc.dg/pr98457.d: Likewise. * gdc.dg/simd1.d: Likewise. * gdc.dg/simd2a.d: Likewise. * gdc.dg/simd2b.d: Likewise. * gdc.dg/simd2c.d: Likewise. * gdc.dg/simd2d.d: Likewise. * gdc.dg/simd2e.d: Likewise. * gdc.dg/simd2f.d: Likewise. * gdc.dg/simd2g.d: Likewise. * gdc.dg/simd2h.d: Likewise. * gdc.dg/simd2i.d: Likewise. * gdc.dg/simd2j.d: Likewise. * gdc.dg/simd7951.d: Likewise. * gdc.dg/torture/gdc309.d: Likewise. * gdc.dg/torture/pr94424.d: Likewise. * gdc.dg/torture/pr94777b.d: Likewise. * lib/gdc-utils.exp (gdc-convert-args): Handle new compiler options. (gdc-convert-test): Handle CXXFLAGS, EXTRA_OBJC_SOURCES, and ARG_SETS test directives. (gdc-do-test): Only import modules in the test run directory. * gdc.dg/pr94777c.d: New test. * gdc.dg/pr96156b.d: New test. * gdc.dg/pr96157c.d: New test. * gdc.dg/simd_ctfe.d: New test. * gdc.dg/torture/simd17344.d: New test. * gdc.dg/torture/simd20052.d: New test. * gdc.dg/torture/simd6.d: New test. * gdc.dg/torture/simd7.d: New test. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime e6caaab9. * libdruntime/Makefile.am (D_EXTRA_FLAGS): Build libdruntime with -fpreview=dip1000, -fpreview=fieldwise, and -fpreview=dtorfields. (ALL_DRUNTIME_SOURCES): Add DRUNTIME_DSOURCES_STDCXX. (DRUNTIME_DSOURCES): Update list of C binding modules. (DRUNTIME_DSOURCES_STDCXX): Likewise. (DRUNTIME_DSOURCES_LINUX): Likewise. (DRUNTIME_DSOURCES_OPENBSD): Likewise. (DRUNTIME_DISOURCES): Remove __entrypoint.di. * libdruntime/Makefile.in: Regenerated. * libdruntime/__entrypoint.di: Removed. * libdruntime/gcc/deh.d (_d_isbaseof): Update signature. (_d_createTrace): Likewise. (__gdc_begin_catch): Remove reference to the exception. (_d_throw): Increment reference count of thrown object before unwind. (__gdc_personality): Chain exceptions with Throwable.chainTogether. * libdruntime/gcc/emutls.d: Update imports. * libdruntime/gcc/sections/elf.d: Update imports. (DSO.moduleGroup): Update signature. * libdruntime/gcc/sections/macho.d: Update imports. (DSO.moduleGroup): Update signature. * libdruntime/gcc/sections/pecoff.d: Update imports. (DSO.moduleGroup): Update signature. * src/MERGE: Merge upstream phobos 5ab9ad256. * src/Makefile.am (D_EXTRA_DFLAGS): Add -fpreview=dip1000 and -fpreview=dtorfields flags. (PHOBOS_DSOURCES): Update list of std modules. * src/Makefile.in: Regenerate. * testsuite/lib/libphobos.exp (libphobos-dg-test): Handle assembly compile types. (dg-test): Override. (additional_prunes): Define. (libphobos-dg-prune): Filter any additional_prunes set by tests. * testsuite/libphobos.aa/test_aa.d: Update test. * testsuite/libphobos.druntime/druntime.exp (version_flags): Add -fversion=CoreUnittest. * testsuite/libphobos.druntime_shared/druntime_shared.exp (version_flags): Add -fversion=CoreUnittest -fversion=Shared. * testsuite/libphobos.exceptions/unknown_gc.d: Update test. * testsuite/libphobos.hash/test_hash.d: Update test. * testsuite/libphobos.phobos/phobos.exp (version_flags): Add -fversion=StdUnittest * testsuite/libphobos.phobos_shared/phobos_shared.exp (version_flags): Likewise. * testsuite/libphobos.shared/host.c: Update test. * testsuite/libphobos.shared/load.d: Update test. * testsuite/libphobos.shared/load_13414.d: Update test. * testsuite/libphobos.thread/fiber_guard_page.d: Update test. * testsuite/libphobos.thread/tlsgc_sections.d: Update test. * testsuite/testsuite_flags.in: Add -fpreview=dip1000 to --gdcflags. * testsuite/libphobos.shared/link_mod_collision.d: Removed. * testsuite/libphobos.shared/load_mod_collision.d: Removed. * testsuite/libphobos.betterc/betterc.exp: New test. * testsuite/libphobos.config/config.exp: New test. * testsuite/libphobos.gc/gc.exp: New test. * testsuite/libphobos.imports/imports.exp: New test. * testsuite/libphobos.lifetime/lifetime.exp: New test. * testsuite/libphobos.unittest/unittest.exp: New test.
2021-10-31d: Fix pr96435.d failing on SPARC and HPPAIain Buclaw1-1/+1
The value used to initialize the integer field in the union didn't account for BigEndian targets running this code. PR d/102959 gcc/testsuite/ChangeLog: * gdc.dg/torture/pr96435.d: Adjust for BigEndian.
2021-09-30libphobos: Define main function as extern(C) when compiling without D ↵Iain Buclaw1-0/+3
runtime (PR102476) The default supplied main function as read when compiling with `-fmain' has extern(D) linkage. However this does not work when mixing this option together with `-fno-druntime'. PR d/102476 gcc/testsuite/ChangeLog: * gdc.dg/pr102476.d: New test. libphobos/ChangeLog: * libdruntime/__main.di: Define main function as extern(C) when compiling without D runtime.
2021-09-12d: Don't include terminating null pointer in string expression conversion ↵Iain Buclaw1-0/+7
(PR102185) This gets re-added by the ExprVisitor when lowering StringExp back into a STRING_CST during the code generator pass. PR d/102185 gcc/d/ChangeLog: * d-builtins.cc (d_eval_constant_expression): Don't include terminating null pointer in string expression conversion. gcc/testsuite/ChangeLog: * gdc.dg/pr102185.d: New test.
2021-08-29d: ICE in gimple_register_canonical_type_1, at lto/lto-common.c:430 (PR102094)Iain Buclaw1-0/+18
User defined types have the TYPE_CXX_ODR_P flag set, but closure frames did not. This mismatch led to an ICE in the conflict detection for ODR and interoperable non-ODR types. As a given closure frame is tied explicitly to a function, it already conforms to ODR. PR d/102094 gcc/d/ChangeLog: * d-codegen.cc (build_frame_type): Set TYPE_CXX_ODR_P. gcc/testsuite/ChangeLog: * gdc.dg/lto/pr102094_0.d: New test.
2021-07-29d: Generate Object class if it doesn't exist during TypeInfo emission (PR101672)Iain Buclaw2-1/+20
Having a stub will prevent errors from occuring when compiling D code with an empty object.d. Though if it were to actually be used implicitly then an error should occur. PR d/101672 gcc/d/ChangeLog: * typeinfo.cc (make_frontend_typeinfo): Generate Object class if it doesn't exist. (check_typeinfo_type): Don't warn if there's no location. gcc/testsuite/ChangeLog: * gdc.dg/pr100967.d: Update test. * gdc.dg/pr101672.d: New test.
2021-07-29d: Return the correct value for C++ constructor calls (PR101664)Iain Buclaw3-0/+64
C++ constructors return void, even though the front-end semantic treats them as implicitly returning `this'. To handle this correctly, the object reference is cached and used as the result of the expression. PR d/101664 gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (CallExp *)): Use object expression as result for C++ constructor calls. gcc/testsuite/ChangeLog: * gdc.dg/extern-c++/extern-c++.exp: New. * gdc.dg/extern-c++/pr101664.d: New test. * gdc.dg/extern-c++/pr101664_1.cc: New test.
2021-07-29d: Ensure casting from bool results in either 0 or 1 (PR96435)Iain Buclaw1-0/+21
If casting from bool, the result is either 0 or 1, any other value violates @safe code, so enforce that it is never invalid. PR d/96435 gcc/d/ChangeLog: * d-convert.cc (convert_for_rvalue): New function. * d-tree.h (convert_for_rvalue): Declare. * expr.cc (ExprVisitor::visit (CastExp *)): Use convert_for_rvalue. (build_return_dtor): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr96435.d: New test.
2021-07-29d: Remove generated D header files on error (PR101657)Iain Buclaw1-0/+14
If an error occurs later during compilation, remember that we generated the headers, so that they can be removed before exit. PR d/101657 gcc/d/ChangeLog: * d-lang.cc (d_parse_file): Remove generated D header files on error. gcc/testsuite/ChangeLog: * gdc.dg/pr101657.d: New test.
2021-07-28d: Wrong evaluation order of binary expressions (PR101640)Iain Buclaw2-1/+12
The use of fold_build2 can in some cases swap the order of its operands if that is the more optimal thing to do. However this breaks semantic guarantee of left-to-right evaluation in D. PR d/101640 gcc/d/ChangeLog: * expr.cc (binary_op): Use build2 instead of fold_build2. gcc/testsuite/ChangeLog: * gdc.dg/pr96429.d: Update test. * gdc.dg/pr101640.d: New test.
2021-07-28d: fix ICE at convert_expr(tree_node*, Type*, Type*) (PR101490)Iain Buclaw1-0/+21
Both the front-end and code generator had a modulo by zero bug when testing if a conversion from a static array to dynamic array was valid. PR d/101490 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 27e388b4c. * d-codegen.cc (build_array_index): Handle void arrays same as byte. * d-convert.cc (convert_expr): Handle converting to zero-sized arrays. gcc/testsuite/ChangeLog: * gdc.dg/pr101490.d: New test.
2021-07-28d: Compile-time reflection for supported built-ins (PR101127)Iain Buclaw2-0/+15
In order to allow user-code to determine whether a back-end builtin is available without error, LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE has been defined to delay putting back-end builtin functions until the ISA that defines them has been declared. However in D, there is no global namespace. All builtins get pushed into the `gcc.builtins' module, which is constructed during the semantic analysis pass, which has already finished by the time target attributes are evaluated. So builtins are not pushed by the new langhook because they would be ultimately ignored. Builtins exposed to D code then can now only be altered by the command-line. PR d/101127 gcc/d/ChangeLog: * d-builtins.cc (d_builtin_function_ext_scope): New function. * d-lang.cc (LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE): Define. * d-tree.h (d_builtin_function_ext_scope): Declare. gcc/testsuite/ChangeLog: * gdc.dg/pr101127a.d: New test. * gdc.dg/pr101127b.d: New test.
2021-07-03d: Missed RVO optimization with non-POD structsIain Buclaw1-0/+39
The D front-end semantic pass sometimes declares a temporary inside a return expression. This is now detected with the RESULT_DECL replacing the temporary, allowing for RVO to be done. PR d/101273 gcc/d/ChangeLog: * toir.cc (IRVisitor::visit (ReturnStatement *)): Detect returns that use a temporary, and replace with return value. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr101273.d: New test.
2021-07-03d: RHS value lost when a target_expr modifies LHS in a cond_exprIain Buclaw1-0/+23
To prevent the RHS of an assignment modifying the LHS before the assignment proper, a target_expr is forced so that function calls that return with slot optimization modify the temporary instead. This did not work for conditional expressions however, to give one example. So now the RHS is always forced to a temporary. PR d/101282 gcc/d/ChangeLog: * d-codegen.cc (build_assign): Force target_expr on RHS for non-POD assignment expressions. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr101282.d: New test.
2021-06-10d: Fix ICE in TypeInfoDeclaration, at dmd/declaration.c (PR100967)Iain Buclaw1-0/+11
Generate a stub TypeInfo class even if the root Object class is missing. The front-end will take care of issuing an error and abort the compilation when running semantic on constructed TypeInfo objects. The errors issued by the code generation pass relating to missing or disabled RTTI has been consolidated into a single function, so that a meaningful error will be emitted before the front-end terminates. gcc/d/ChangeLog: PR d/100967 * d-frontend.cc (getTypeInfoType): Move TypeInfo checks to check_typeinfo_type and call new function. * d-tree.h (check_typeinfo_type): Declare. * typeinfo.cc: Include dmd/scope.h. (create_frontend_tinfo_types): Generate front-end types even if Object is missing. (build_typeinfo): Move TypeInfo checks to check_typeinfo_type and call new function. (check_typeinfo_type): New function. gcc/testsuite/ChangeLog: PR d/100967 * gdc.dg/pr100967.d: New test.
2021-06-04d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)Iain Buclaw4-0/+100
Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a TARGET_EXPR for an assignment, which later got passed to `build_assign', which stripped away the outer TARGET_EXPR, leaving a reference to a lone temporary with no declaration. This stripping away of the TARGET_EXPR also discarded any cleanups that may have been assigned to the expression as well. So now the reuse of TARGET_EXPR_SLOT has been removed, and `build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL slot. This has also been extended to `return_expr', to deal with possibility of a TARGET_EXPR being returned. gcc/d/ChangeLog: PR d/100882 * d-codegen.cc (build_assign): Construct initializations inside TARGET_EXPR_INITIAL. (compound_expr): Remove intermediate expressions that have no side-effects. (return_expr): Construct returns inside TARGET_EXPR_INITIAL. * expr.cc (ExprVisitor::visit (CallExp *)): Remove useless assignment to TARGET_EXPR_SLOT. gcc/testsuite/ChangeLog: PR d/100882 * gdc.dg/pr100882a.d: New test. * gdc.dg/pr100882b.d: New test. * gdc.dg/pr100882c.d: New test. * gdc.dg/torture/pr100882.d: New test.
2021-04-19d: Fix ICE in when formating a string with '%' or '`' characters (PR98457)Iain Buclaw1-0/+9
The percentage character was being confused for a format specifier in pp_format(), whilst the backtick character was confused for the beginning of a quoted string in expand_d_format(). Both are now properly escaped to avoid the ICE. gcc/d/ChangeLog: PR d/98457 * d-diagnostic.cc (expand_d_format): Handle escaped backticks. (escape_d_format): New funtion. (verror): Call escape_d_format on prefixing strings. (vdeprecation): Likewise. gcc/testsuite/ChangeLog: PR d/98457 * gdc.dg/pr98457.d: New test.