aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
AgeCommit message (Collapse)AuthorFilesLines
2021-09-13Daily bump.GCC Administrator1-0/+6
2021-09-12d: Don't include terminating null pointer in string expression conversion ↵Iain Buclaw1-1/+1
(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-30Daily bump.GCC Administrator1-0/+65
2021-08-29d: Call the assertp and boundsp variants for assert and array contract failures.Iain Buclaw6-109/+173
gcc/d/ChangeLog: * d-codegen.cc: Include dmd/module.h. (build_filename_from_loc): New function. (d_assert_call): Rename to... (build_assert_call): ...this. (build_array_bounds_call): Call arrayboundsp variant of the array bounds failure callback. (build_bounds_condition): Rename to... (build_bounds_index_condition): ...this. Update signature. (build_bounds_slice_condition): New function. (checkaction_trap_p): New function. (d_assert_call): Call assertp variant of assert failure callback. * d-tree.h (class IndexExp): Declare. (class SliceExp): Declare. (build_bounds_condition): Remove. (build_assert_call): Declare. (build_bounds_index_condition): Declare. (build_bounds_slice_condition): Declare. (checkaction_trap_p): Declare. (d_assert_call): Remove. * expr.cc (ExprVisitor::visit(IndexExp *)): Call build_bounds_index_condition. (ExprVisitor::visit(SliceExp *)): Call build_bounds_slice_condition. (ExprVisitor::visit(AssertExp *)): Update setting of libcall. * runtime.cc (enum d_libcall_type): Add LCT_IMMUTABLE_CHARPTR. (get_libcall_type): Handle LCT_IMMUTABLE_CHARPTR. * runtime.def (ASSERT): Rename to... (ASSERTP): ...this. Update signature. (UNITTEST): Rename to... (UNITTESTP): ...this. Update signature. (ARRAY_BOUNDS): Rename to... (ARRAYBOUNDSP): ...this. Updates signature. * toir.cc (IRVisitor::visit(SwitchErrorStatement *)): Update call.
2021-08-29d: Update comment for TypeInfoVisitor::layout_baseIain Buclaw1-2/+1
gcc/d/ChangeLog: * typeinfo.cc (class TypeInfoVisitor::layout_base): Update comment.
2021-08-29d: Use `int` to store class and struct flagsIain Buclaw1-3/+3
gcc/d/ChangeLog: * typeinfo.cc (TypeInfoVisitor::visit(TypeInfoClassDeclaration *)): Use int to store type flags. (TypeInfoVisitor::visit(TypeInfoStructDeclaration *)): Likewise.
2021-08-29d: Get __c_wchar_t type from build_frontend_typeIain Buclaw1-1/+2
gcc/d/ChangeLog: * types.cc (TypeVisitor::visit(TypeEnum*)): Get wchar_t type from build_frontend_type.
2021-08-29d: Convert convert_for_rvalue switch statement into if conditionIain Buclaw1-3/+1
gcc/d/ChangeLog: * d-convert.cc (convert_for_rvalue): Convert switch statement into if condition.
2021-08-29d: Use POINTER_SIZE for testing whether to predefine D_LP64Iain Buclaw1-1/+1
gcc/d/ChangeLog: * d-builtins.cc (d_init_versions): Use POINTER_SIZE for testing whether to predefine D_LP64.
2021-08-29d: ICE in gimple_register_canonical_type_1, at lto/lto-common.c:430 (PR102094)Iain Buclaw1-0/+1
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-08-26Daily bump.GCC Administrator1-0/+7
2021-08-25diagnostics: Support for -finput-charset [PR93067]Lewis Hyatt1-0/+19
Adds the logic to handle -finput-charset in layout_get_source_line(), so that source lines are converted from their input encodings prior to being output by diagnostics machinery. Also adds the ability to strip a UTF-8 BOM similarly. gcc/c-family/ChangeLog: PR other/93067 * c-opts.c (c_common_input_charset_cb): New function. (c_common_post_options): Call new function diagnostic_initialize_input_context(). gcc/d/ChangeLog: PR other/93067 * d-lang.cc (d_input_charset_callback): New function. (d_init): Call new function diagnostic_initialize_input_context(). gcc/fortran/ChangeLog: PR other/93067 * cpp.c (gfc_cpp_post_options): Call new function diagnostic_initialize_input_context(). gcc/ChangeLog: PR other/93067 * coretypes.h (typedef diagnostic_input_charset_callback): Declare. * diagnostic.c (diagnostic_initialize_input_context): New function. * diagnostic.h (diagnostic_initialize_input_context): Declare. * input.c (default_charset_callback): New function. (file_cache::initialize_input_context): New function. (file_cache_slot::create): Added ability to convert the input according to the input context. (file_cache::file_cache): Initialize the new input context. (class file_cache_slot): Added new m_alloc_offset member. (file_cache_slot::file_cache_slot): Initialize the new member. (file_cache_slot::~file_cache_slot): Handle potentially offset buffer. (file_cache_slot::maybe_grow): Likewise. (file_cache_slot::needs_read_p): Handle NULL fp, which is now possible. (file_cache_slot::get_next_line): Likewise. * input.h (class file_cache): Added input context member. libcpp/ChangeLog: PR other/93067 * charset.c (init_iconv_desc): Adapt to permit PFILE argument to be NULL. (_cpp_convert_input): Likewise. Also move UTF-8 BOM logic to... (cpp_check_utf8_bom): ...here. New function. (cpp_input_conversion_is_trivial): New function. * files.c (read_file_guts): Allow PFILE argument to be NULL. Add INPUT_CHARSET argument as an alternate source of this information. (read_file): Pass the new argument to read_file_guts. (cpp_get_converted_source): New function. * include/cpplib.h (struct cpp_converted_source): Declare. (cpp_get_converted_source): Declare. (cpp_input_conversion_is_trivial): Declare. (cpp_check_utf8_bom): Declare. gcc/testsuite/ChangeLog: PR other/93067 * gcc.dg/diagnostic-input-charset-1.c: New test. * gcc.dg/diagnostic-input-utf8-bom.c: New test.
2021-08-03Daily bump.GCC Administrator1-0/+98
2021-07-30d: Remove dead code from binary_op.Iain Buclaw1-8/+0
The front-end ensures that both sides have been casted to the same type before being given to the lowering pass. gcc/d/ChangeLog: * expr.cc (binary_op): Remove dead code.
2021-07-30d: Always layout initializer for the m_RTInfo field in TypeInfo_ClassIain Buclaw1-0/+2
Makes it explicit that the default value is set to NULL. gcc/d/ChangeLog: * typeinfo.cc (TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Always layout initializer for the m_RTInfo field.
2021-07-30d: Don't generate a PREDICT_EXPR when assert contracts are turned off.Iain Buclaw1-9/+3
This expression is just discarded by add_stmt, so never reaches the middle-end. gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (AssertExp *)): Don't generate PREDICT_EXPR.
2021-07-30d: Clarify comment for generating static array assignment with literal.Iain Buclaw1-3/+3
The code block is done as an optimization to elide a call to the runtime library helpers _d_arrayctor or _d_arrayassign. gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (AssignExp *)): Clarify comment for generating static array assignment with literal.
2021-07-30d: Only handle named enums in enum_initializer_declIain Buclaw1-5/+2
Anonymous enums neither generate an initializer nor typeinfo symbol, so it's safe to assert that all enum declarations passed to this function always have an identifier. gcc/d/ChangeLog: * decl.cc (enum_initializer_decl): Only handle named enums.
2021-07-30d: Set COMDAT and visibility of thunks only if they are public.Iain Buclaw1-3/+6
It is not expected to have a member function that can be non-public, but this guards against any internal errors that might occur should that ever change in the front-end. gcc/d/ChangeLog: * decl.cc (make_thunk): Set COMDAT and visibility of thunks only if they are public.
2021-07-30d: Factor aggregate_initializer_decl to set the sinit for aggregate ↵Iain Buclaw1-14/+15
declarations. The self-hosted implementation of the D front-end changes the type of `sinit' to a void pointer, which requires an explicit cast to `tree'. gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (StructDeclaration *)): Don't use sinit for declaration directly. (DeclVisitor::visit (ClassDeclaration *)): Likewise. (aggregate_initializer_decl): Likewise. Set sinit after creating.
2021-07-30d: Use Identifier::idPool to generate anonymous field name.Iain Buclaw1-3/+7
The self-hosted implementation of the D front-end does not export Identifier::generateId, so handle name generation inline instead. gcc/d/ChangeLog: * d-builtins.cc (build_frontend_type): Use Identifier::idPool to generate anonymous field name.
2021-07-30d: Use hasMonitor to determine whether to emit a __monitor field in D classesIain Buclaw2-8/+15
This helper introduced by the front-end is a better gate, and allows the front-end to change rules for what gets a monitor in the future. gcc/d/ChangeLog: * types.cc (layout_aggregate_type): Call hasMonitor. * typeinfo.cc (TypeInfoVisitor::layout_base): Likewise. (layout_cpp_typeinfo): Likewise. Don't emit vtable unless have_typeinfo_p.
2021-07-30d: Insert null terminator in obstack buffersIain Buclaw1-1/+5
Covers cases where functions that handle the extracted strings ignore the explicit length. This isn't something that's known to happen in the current front-end, but the self-hosted front-end has been observed to do this in its conversions between D and C-style strings. gcc/d/ChangeLog: * d-lang.cc (deps_add_target): Insert null terminator in buffer. (deps_write): Likewise. (d_parse_file): Likewise.
2021-07-30d: Drop any field or parameter types that got cached before conversion failed.Iain Buclaw1-1/+8
This ensures there are no dangling references to AST members that have been freed, either explcitly or by the garbage collector. gcc/d/ChangeLog: * d-builtins.cc (build_frontend_type): Restore builtin_converted_decls length on conversion failure.
2021-07-30d: Factor d_nested_class and d_nested_struct into single function.Iain Buclaw1-40/+14
Both do the exact same operation, just on different AST nodes. gcc/d/ChangeLog: * d-codegen.cc (d_nested_class): Rename to ... (get_outer_function): ... this. Handle all aggregate declarations. (d_nested_struct): Remove. (find_this_tree): Use get_outer_function. (get_framedecl): Likewise.
2021-07-29d: Generate Object class if it doesn't exist during TypeInfo emission (PR101672)Iain Buclaw1-2/+21
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 Buclaw1-0/+13
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 Buclaw3-5/+45
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/+19
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-29d: Don't escape quoted format strings in escape_d_format (PR101656)Iain Buclaw1-1/+13
If the format string is enclosed by two '`' characters, then don't escape the first and laster characters. PR d/101656 gcc/d/ChangeLog: * d-diagnostic.cc (escape_d_format): Don't escape quoted format strings.
2021-07-29Daily bump.GCC Administrator1-0/+29
2021-07-28d: Wrong evaluation order of binary expressions (PR101640)Iain Buclaw1-1/+1
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 Buclaw4-26/+22
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: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast ↵Iain Buclaw2-3/+3
(PR101441) Backports fix from upstream to allow __FUNCTION__ and __PRETTY_FUNCTION__ to be used as C string literals. Reviewed-on: https://github.com/dlang/dmd/pull/12923 PR d/101441 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd f8c1ca928.
2021-07-28d: Compile-time reflection for supported built-ins (PR101127)Iain Buclaw3-0/+18
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-28d: Change in DotTemplateExp type semantics leading to regression (PR101619)Iain Buclaw3-1/+15
By giving dot templates a type, meant that properry resolving silently started passing for code that should never have passed. The simple fix is to provide implementations for checkType and checkValue that give an error about dot templates having neither a value nor type. Reviewed-on: https://github.com/dlang/dmd/pull/12920 PR d/101619 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 1d8386a63.
2021-07-04Daily bump.GCC Administrator1-0/+6
2021-07-03d: Missed RVO optimization with non-POD structsIain Buclaw1-2/+30
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-03Daily bump.GCC Administrator1-0/+6
2021-07-03d: RHS value lost when a target_expr modifies LHS in a cond_exprIain Buclaw1-0/+7
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-12Daily bump.GCC Administrator1-0/+5
2021-06-11d: foreach over a tuple doesn't work on 16-bit targets (PR100999)Iain Buclaw6-36/+54
Improves semantic passes in the front-end around the `foreach' and `static foreach' statements to be more resilient to compiling in a minimal D runtime environment. Checking of the index type has been improved as well so now there won't be needless compiler errors when using 8 or 16-bit integers as index types when the size fits the expected loop range. gcc/d/ChangeLog: PR d/100999 * dmd/MERGE: Merge upstream dmd 7a3808254. libphobos/ChangeLog: PR d/100999 * src/MERGE: Merge upstream phobos 55bb17543.
2021-06-11Daily bump.GCC Administrator1-0/+13
2021-06-10d: Fix ICE in TypeInfoDeclaration, at dmd/declaration.c (PR100967)Iain Buclaw3-38/+34
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-10Daily bump.GCC Administrator1-0/+10
2021-06-09d: TypeInfo error when using slice copy on Structs (PR100964)Iain Buclaw2-3/+6
Known limitation: does not work for struct with postblit or dtor. Reviewed-on: https://github.com/dlang/dmd/pull/12648 gcc/d/ChangeLog: PR d/100964 * dmd/MERGE: Merge upstream dmd 4a4e46a6f.
2021-06-09d: Respect explicit align(N) type alignment (PR100935)Iain Buclaw2-2/+5
It was previously the natural type alignment, defined as the maximum of the field alignments for an aggregate. Make sure an explicit align(N) overrides it. Reviewed-on: https://github.com/dlang/dmd/pull/12646 gcc/d/ChangeLog: PR d/100935 * dmd/MERGE: Merge upstream dmd f3fdeb578.
2021-06-05Daily bump.GCC Administrator1-0/+11
2021-06-04d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)Iain Buclaw2-12/+31
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-05-19Daily bump.GCC Administrator1-0/+16