aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
AgeCommit message (Collapse)AuthorFilesLines
2024-06-10Fix crash on access-to-incomplete typeEric Botcazou1-0/+22
This just adds the missing guard. gcc/ada/ PR ada/114708 * exp_util.adb (Finalize_Address): Add guard for incomplete types. gcc/testsuite/ * gnat.dg/incomplete8.adb: New test.
2024-06-10Add testcase for PR ada/114398Eric Botcazou1-0/+80
gcc/testsuite/ PR ada/114398 * gnat.dg/access11.adb: New test.
2024-03-07Fix bogus error on allocator for array type with Dynamic_PredicateEric Botcazou1-0/+15
This is a regression present on all active branches: the compiler gives a bogus error on an allocator for an unconstrained array type declared with a Dynamic_Predicate because Apply_Predicate_Check is invoked directly on a subtype reference, which it cannot handle. This moves the check to the resulting access value (after dereference) like in Expand_Allocator_Expression. gcc/ada/ PR ada/113979 * exp_ch4.adb (Expand_N_Allocator): In the subtype indication case, call Apply_Predicate_Check on the resulting access value if needed. gcc/testsuite/ * gnat.dg/predicate15.adb: New test.
2024-02-27Fix internal error on non-byte-aligned reference in GIMPLE DSEEric Botcazou2-0/+62
This is a regression present on the mainline, 13 and 12 branches. For the attached Ada case, it's a tree checking failure on the mainline at -O: +===========================GNAT BUG DETECTED==============================+ | 14.0.1 20240226 (experimental) [master r14-9171-g4972f97a265] GCC error:| | tree check: expected tree that contains 'decl common' structure, | | have 'component_ref' in tree_could_trap_p, at tree-eh.cc:2733 | | Error detected around /home/eric/cvs/gcc/gcc/testsuite/gnat.dg/opt104.adb: Time is a 10-byte record and Packed_Rec.T is placed at bit-offset 65 because of the packing. so tree-ssa-dse.cc:setup_live_bytes_from_ref has computed a const_size of 88 from ref->offset of 65 and ref->max_size of 80. Then in tree-ssa-dse.cc:compute_trims: 411 int last_live = bitmap_last_set_bit (live); (gdb) next 412 if (ref->size.is_constant (&const_size)) (gdb) 414 int last_orig = (const_size / BITS_PER_UNIT) - 1; (gdb) 418 *trim_tail = last_orig - last_live; (gdb) call debug_bitmap (live) n_bits = 256, set = {0 1 2 3 4 5 6 7 8 9 10 } (gdb) p last_live $33 = 10 (gdb) p const_size $34 = 80 (gdb) p last_orig $35 = 9 (gdb) p *trim_tail $36 = -1 In other words, compute_trims is overlooking the alignment adjustments that setup_live_bytes_from_ref applied earlier. Moveover it reads: /* We use sbitmaps biased such that ref->offset is bit zero and the bitmap extends through ref->size. So we know that in the original bitmap bits 0..ref->size were true. We don't actually need the bitmap, just the REF to compute the trims. */ but setup_live_bytes_from_ref used ref->max_size instead of ref->size. It appears that all the callers of compute_trims assume that ref->offset is byte aligned and that the trimmed bytes are relative to ref->size, so the patch simply adds an early return if either condition is not fulfilled. gcc/ * tree-ssa-dse.cc (compute_trims): Fix description. Return early if either ref->offset is not byte aligned or ref->size is not known to be equal to ref->max_size. (maybe_trim_complex_store): Fix description. (maybe_trim_constructor_store): Likewise. (maybe_trim_partially_dead_store): Likewise. gcc/testsuite/ * gnat.dg/opt104.ads, gnat.dg/opt104.adb: New test.
2024-02-26Finalization of object allocated by anonymous access designating local typeEric Botcazou1-0/+58
The finalization of objects dynamically allocated through an anonymous access type is deferred to the enclosing library unit in the current implementation and a warning is given on each of them. However this cannot be done if the designated type is local, because this would generate dangling references to the local finalization routine, so the finalization needs to be dropped in this case and the warning adjusted. gcc/ada/ PR ada/113893 * exp_ch7.adb (Build_Anonymous_Master): Do not build the master for a local designated type. * exp_util.adb (Build_Allocate_Deallocate_Proc): Force Needs_Fin to false if no finalization master is attached to an access type and assert that it is anonymous in this case. * sem_res.adb (Resolve_Allocator): Mention that the object might not be finalized at all in the warning given when the type is an anonymous access-to-controlled type. gcc/testsuite/ * gnat.dg/access10.adb: New test.
2024-02-15Skip gnat.dg/div_zero.adb on RISC-VAndreas Schwab1-1/+1
Like AArch64 and POWER, RISC-V does not support trap on zero divide. gcc/testsuite/ * gnat.dg/div_zero.adb: Skip on RISC-V.
2024-02-01xfail gnat.dg/trampoline3.adb scan-assembler-not check on hppa*-*-*John David Anglin1-1/+1
We still require an executable stack for trampolines on hppa*-*-*. 2024-02-01 John David Anglin <danglin@gcc.gnu.org> gcc/testsuite/ChangeLog: * gnat.dg/trampoline3.adb: xfail scan-assembler-not check on hppa*-*-*.
2024-01-09Fix internal error on function call returning extension of limited interfaceEric Botcazou3-0/+63
The problem occurs when this function call is the expression of a return in a function returning the limited interface; in this peculiar case, there is a mismatch between the callee, which has BIP formals but is not a BIP call, and the caller, which is a BIP function, that is spotted by an assertion. This is fixed by restoring the semantics of Is_Build_In_Place_Function_Call, which returns again true only for calls to BIP functions, introducing the Is_Function_Call_With_BIP_Formals predicate, which also returns true for calls to functions with BIP formals that are not BIP functions, and moving down the assertion in Expand_Simple_Function_Return. gcc/ada/ PR ada/112781 * exp_ch6.ads (Is_Build_In_Place_Function): Adjust description. * exp_ch6.adb (Is_True_Build_In_Place_Function_Call): Delete. (Is_Function_Call_With_BIP_Formals): New predicate. (Is_Build_In_Place_Function_Call): Restore original semantics. (Expand_Call_Helper): Adjust conditions guarding the calls to Add_Dummy_Build_In_Place_Actuals to above renaming. (Expand_N_Extended_Return_Statement): Adjust to above renaming. (Expand_Simple_Function_Return): Likewise. Move the assertion to after the transformation into an extended return statement. (Make_Build_In_Place_Call_In_Allocator): Remove unreachable code. (Make_Build_In_Place_Call_In_Assignment): Likewise. gcc/testsuite/ * gnat.dg/bip_prim_func2.adb: New test. * gnat.dg/bip_prim_func2_pkg.ads, gnat.dg/bip_prim_func2_pkg.adb: New helper package.
2024-01-09Fix internal error on anonymous access type equalityEric Botcazou1-0/+10
This is a small regression present on the mainline and 13 branch, in the form of an internal error in gigi on anonymous access type equality. We now need to also accept them for anonymous access types that point to compatible object subtypes in the language sense. gcc/ada/ * gcc-interface/utils2.cc (build_binary_op) <EQ_EXPR>: Relax assertion for regular pointer types. gcc/testsuite/ * gnat.dg/specs/anon4.ads: New test.
2024-01-03Update copyright years.Jakub Jelinek4-4/+4
2023-12-07strub: enable conditional supportAlexandre Oliva16-0/+16
Targets that don't expose callee stacks to callers, such as nvptx, as well as -fsplit-stack compilations, violate fundamental assumptions of the current strub implementation. This patch enables targets to disable strub, and disables it when -fsplit-stack is enabled. When strub support is disabled, the testsuite will now skip strub tests, and libgcc will not build the strub runtime components. for gcc/ChangeLog * target.def (have_strub_support_for): New hook. * doc/tm.texi.in: Document it. * doc/tm.texi: Rebuild. * ipa-strub.cc: Include target.h. (strub_target_support_p): New. (can_strub_p): Call it. Test for no flag_split_stack. (pass_ipa_strub::adjust_at_calls_call): Check for target support. * config/nvptx/nvptx.cc (TARGET_HAVE_STRUB_SUPPORT_FOR): Disable. * doc/sourcebuild.texi (strub): Document new effective target. for gcc/testsuite/ChangeLog * c-c++-common/strub-split-stack.c: New. * c-c++-common/strub-unsupported.c: New. * c-c++-common/strub-unsupported-2.c: New. * c-c++-common/strub-unsupported-3.c: New. * lib/target-supports.exp (check_effective_target_strub): New. * c-c++-common/strub-O0.c: Require effective target strub. * c-c++-common/strub-O1.c: Likewise. * c-c++-common/strub-O2.c: Likewise. * c-c++-common/strub-O2fni.c: Likewise. * c-c++-common/strub-O3.c: Likewise. * c-c++-common/strub-O3fni.c: Likewise. * c-c++-common/strub-Og.c: Likewise. * c-c++-common/strub-Os.c: Likewise. * c-c++-common/strub-all1.c: Likewise. * c-c++-common/strub-all2.c: Likewise. * c-c++-common/strub-apply1.c: Likewise. * c-c++-common/strub-apply2.c: Likewise. * c-c++-common/strub-apply3.c: Likewise. * c-c++-common/strub-apply4.c: Likewise. * c-c++-common/strub-at-calls1.c: Likewise. * c-c++-common/strub-at-calls2.c: Likewise. * c-c++-common/strub-defer-O1.c: Likewise. * c-c++-common/strub-defer-O2.c: Likewise. * c-c++-common/strub-defer-O3.c: Likewise. * c-c++-common/strub-defer-Os.c: Likewise. * c-c++-common/strub-internal1.c: Likewise. * c-c++-common/strub-internal2.c: Likewise. * c-c++-common/strub-parms1.c: Likewise. * c-c++-common/strub-parms2.c: Likewise. * c-c++-common/strub-parms3.c: Likewise. * c-c++-common/strub-relaxed1.c: Likewise. * c-c++-common/strub-relaxed2.c: Likewise. * c-c++-common/strub-short-O0-exc.c: Likewise. * c-c++-common/strub-short-O0.c: Likewise. * c-c++-common/strub-short-O1.c: Likewise. * c-c++-common/strub-short-O2.c: Likewise. * c-c++-common/strub-short-O3.c: Likewise. * c-c++-common/strub-short-Os.c: Likewise. * c-c++-common/strub-strict1.c: Likewise. * c-c++-common/strub-strict2.c: Likewise. * c-c++-common/strub-tail-O1.c: Likewise. * c-c++-common/strub-tail-O2.c: Likewise. * c-c++-common/strub-var1.c: Likewise. * c-c++-common/torture/strub-callable1.c: Likewise. * c-c++-common/torture/strub-callable2.c: Likewise. * c-c++-common/torture/strub-const1.c: Likewise. * c-c++-common/torture/strub-const2.c: Likewise. * c-c++-common/torture/strub-const3.c: Likewise. * c-c++-common/torture/strub-const4.c: Likewise. * c-c++-common/torture/strub-data1.c: Likewise. * c-c++-common/torture/strub-data2.c: Likewise. * c-c++-common/torture/strub-data3.c: Likewise. * c-c++-common/torture/strub-data4.c: Likewise. * c-c++-common/torture/strub-data5.c: Likewise. * c-c++-common/torture/strub-indcall1.c: Likewise. * c-c++-common/torture/strub-indcall2.c: Likewise. * c-c++-common/torture/strub-indcall3.c: Likewise. * c-c++-common/torture/strub-inlinable1.c: Likewise. * c-c++-common/torture/strub-inlinable2.c: Likewise. * c-c++-common/torture/strub-ptrfn1.c: Likewise. * c-c++-common/torture/strub-ptrfn2.c: Likewise. * c-c++-common/torture/strub-ptrfn3.c: Likewise. * c-c++-common/torture/strub-ptrfn4.c: Likewise. * c-c++-common/torture/strub-pure1.c: Likewise. * c-c++-common/torture/strub-pure2.c: Likewise. * c-c++-common/torture/strub-pure3.c: Likewise. * c-c++-common/torture/strub-pure4.c: Likewise. * c-c++-common/torture/strub-run1.c: Likewise. * c-c++-common/torture/strub-run2.c: Likewise. * c-c++-common/torture/strub-run3.c: Likewise. * c-c++-common/torture/strub-run4.c: Likewise. * c-c++-common/torture/strub-run4c.c: Likewise. * c-c++-common/torture/strub-run4d.c: Likewise. * c-c++-common/torture/strub-run4i.c: Likewise. * g++.dg/strub-run1.C: Likewise. * g++.dg/torture/strub-init1.C: Likewise. * g++.dg/torture/strub-init2.C: Likewise. * g++.dg/torture/strub-init3.C: Likewise. * gnat.dg/strub_attr.adb: Likewise. * gnat.dg/strub_ind.adb: Likewise. * gnat.dg/strub_access.adb: Likewise. * gnat.dg/strub_access1.adb: Likewise. * gnat.dg/strub_disp.adb: Likewise. * gnat.dg/strub_disp1.adb: Likewise. * gnat.dg/strub_ind1.adb: Likewise. * gnat.dg/strub_ind2.adb: Likewise. * gnat.dg/strub_intf.adb: Likewise. * gnat.dg/strub_intf1.adb: Likewise. * gnat.dg/strub_intf2.adb: Likewise. * gnat.dg/strub_renm.adb: Likewise. * gnat.dg/strub_renm1.adb: Likewise. * gnat.dg/strub_renm2.adb: Likewise. * gnat.dg/strub_var.adb: Likewise. * gnat.dg/strub_var1.adb: Likewise. for libgcc/ChangeLog * configure.ac: Check for strub support. * configure: Rebuilt. * Makefile.in: Compile strub.c conditionally.
2023-12-05Introduce strub: machine-independent stack scrubbingAlexandre Oliva20-0/+743
This patch adds the strub attribute for function and variable types, command-line options, passes and adjustments to implement it, documentation, and tests. Stack scrubbing is implemented in a machine-independent way: functions with strub enabled are modified so that they take an extra stack watermark argument, that they update with their stack use, and the caller can then zero it out once it regains control, whether by return or exception. There are two ways to go about it: at-calls, that modifies the visible interface (signature) of the function, and internal, in which the body is moved to a clone, the clone undergoes the interface change, and the function becomes a wrapper, preserving its original interface, that calls the clone and then clears the stack used by it. Variables can also be annotated with the strub attribute, so that functions that read from them get stack scrubbing enabled implicitly, whether at-calls, for functions only usable within a translation unit, or internal, for functions whose interfaces must not be modified. There is a strict mode, in which functions that have their stack scrubbed can only call other functions with stack-scrubbing interfaces, or those explicitly marked as callable from strub contexts, so that an entire call chain gets scrubbing, at once or piecemeal depending on optimization levels. In the default mode, relaxed, this requirement is not enforced by the compiler. The implementation adds two IPA passes, one that assigns strub modes early on, another that modifies interfaces and adds calls to the builtins that jointly implement stack scrubbing. Another builtin, that obtains the stack pointer, is added for use in the implementation of the builtins, whether expanded inline or called in libgcc. There are new command-line options to change operation modes and to force the feature disabled; it is enabled by default, but it has no effect and is implicitly disabled if the strub attribute is never used. There are also options meant to use for testing the feature, enabling different strubbing modes for all (viable) functions. for gcc/ChangeLog * Makefile.in (OBJS): Add ipa-strub.o. (GTFILES): Add ipa-strub.cc. * builtins.def (BUILT_IN_STACK_ADDRESS): New. (BUILT_IN___STRUB_ENTER): New. (BUILT_IN___STRUB_UPDATE): New. (BUILT_IN___STRUB_LEAVE): New. * builtins.cc: Include ipa-strub.h. (STACK_STOPS, STACK_UNSIGNED): Define. (expand_builtin_stack_address): New. (expand_builtin_strub_enter): New. (expand_builtin_strub_update): New. (expand_builtin_strub_leave): New. (expand_builtin): Call them. * common.opt (fstrub=*): New options. * doc/extend.texi (strub): New type attribute. (__builtin_stack_address): New function. (Stack Scrubbing): New section. * doc/invoke.texi (-fstrub=*): New options. (-fdump-ipa-*): New passes. * gengtype-lex.l: Ignore multi-line pp-directives. * ipa-inline.cc: Include ipa-strub.h. (can_inline_edge_p): Test strub_inlinable_to_p. * ipa-split.cc: Include ipa-strub.h. (execute_split_functions): Test strub_splittable_p. * ipa-strub.cc, ipa-strub.h: New. * passes.def: Add strub_mode and strub passes. * tree-cfg.cc (gimple_verify_flow_info): Note on debug stmts. * tree-pass.h (make_pass_ipa_strub_mode): Declare. (make_pass_ipa_strub): Declare. (make_pass_ipa_function_and_variable_visibility): Fix formatting. * tree-ssa-ccp.cc (optimize_stack_restore): Keep restores before strub leave. * attribs.cc: Include ipa-strub.h. (decl_attributes): Support applying attributes to function type, rather than pointer type, at handler's request. (comp_type_attributes): Combine strub_comptypes and target comp_type results. * doc/tm.texi.in (TARGET_STRUB_USE_DYNAMIC_ARRAY): New. (TARGET_STRUB_MAY_USE_MEMSET): New. * doc/tm.texi: Rebuilt. * cgraph.h (symtab_node::reset): Add preserve_comdat_group param, with a default. * cgraphunit.cc (symtab_node::reset): Use it. for gcc/c-family/ChangeLog * c-attribs.cc: Include ipa-strub.h. (handle_strub_attribute): New. (c_common_attribute_table): Add strub. for gcc/ada/ChangeLog * gcc-interface/trans.cc: Include ipa-strub.h. (gigi): Make internal decls for targets of compiler-generated calls strub-callable too. (build_raise_check): Likewise. * gcc-interface/utils.cc: Include ipa-strub.h. (handle_strub_attribute): New. (gnat_internal_attribute_table): Add strub. for gcc/testsuite/ChangeLog * c-c++-common/strub-O0.c: New. * c-c++-common/strub-O1.c: New. * c-c++-common/strub-O2.c: New. * c-c++-common/strub-O2fni.c: New. * c-c++-common/strub-O3.c: New. * c-c++-common/strub-O3fni.c: New. * c-c++-common/strub-Og.c: New. * c-c++-common/strub-Os.c: New. * c-c++-common/strub-all1.c: New. * c-c++-common/strub-all2.c: New. * c-c++-common/strub-apply1.c: New. * c-c++-common/strub-apply2.c: New. * c-c++-common/strub-apply3.c: New. * c-c++-common/strub-apply4.c: New. * c-c++-common/strub-at-calls1.c: New. * c-c++-common/strub-at-calls2.c: New. * c-c++-common/strub-defer-O1.c: New. * c-c++-common/strub-defer-O2.c: New. * c-c++-common/strub-defer-O3.c: New. * c-c++-common/strub-defer-Os.c: New. * c-c++-common/strub-internal1.c: New. * c-c++-common/strub-internal2.c: New. * c-c++-common/strub-parms1.c: New. * c-c++-common/strub-parms2.c: New. * c-c++-common/strub-parms3.c: New. * c-c++-common/strub-relaxed1.c: New. * c-c++-common/strub-relaxed2.c: New. * c-c++-common/strub-short-O0-exc.c: New. * c-c++-common/strub-short-O0.c: New. * c-c++-common/strub-short-O1.c: New. * c-c++-common/strub-short-O2.c: New. * c-c++-common/strub-short-O3.c: New. * c-c++-common/strub-short-Os.c: New. * c-c++-common/strub-strict1.c: New. * c-c++-common/strub-strict2.c: New. * c-c++-common/strub-tail-O1.c: New. * c-c++-common/strub-tail-O2.c: New. * c-c++-common/torture/strub-callable1.c: New. * c-c++-common/torture/strub-callable2.c: New. * c-c++-common/torture/strub-const1.c: New. * c-c++-common/torture/strub-const2.c: New. * c-c++-common/torture/strub-const3.c: New. * c-c++-common/torture/strub-const4.c: New. * c-c++-common/torture/strub-data1.c: New. * c-c++-common/torture/strub-data2.c: New. * c-c++-common/torture/strub-data3.c: New. * c-c++-common/torture/strub-data4.c: New. * c-c++-common/torture/strub-data5.c: New. * c-c++-common/torture/strub-indcall1.c: New. * c-c++-common/torture/strub-indcall2.c: New. * c-c++-common/torture/strub-indcall3.c: New. * c-c++-common/torture/strub-inlinable1.c: New. * c-c++-common/torture/strub-inlinable2.c: New. * c-c++-common/torture/strub-ptrfn1.c: New. * c-c++-common/torture/strub-ptrfn2.c: New. * c-c++-common/torture/strub-ptrfn3.c: New. * c-c++-common/torture/strub-ptrfn4.c: New. * c-c++-common/torture/strub-pure1.c: New. * c-c++-common/torture/strub-pure2.c: New. * c-c++-common/torture/strub-pure3.c: New. * c-c++-common/torture/strub-pure4.c: New. * c-c++-common/torture/strub-run1.c: New. * c-c++-common/torture/strub-run2.c: New. * c-c++-common/torture/strub-run3.c: New. * c-c++-common/torture/strub-run4.c: New. * c-c++-common/torture/strub-run4c.c: New. * c-c++-common/torture/strub-run4d.c: New. * c-c++-common/torture/strub-run4i.c: New. * g++.dg/strub-run1.C: New. * g++.dg/torture/strub-init1.C: New. * g++.dg/torture/strub-init2.C: New. * g++.dg/torture/strub-init3.C: New. * gnat.dg/strub_attr.adb, gnat.dg/strub_attr.ads: New. * gnat.dg/strub_ind.adb, gnat.dg/strub_ind.ads: New. for libgcc/ChangeLog * Makefile.in (LIB2ADD): Add strub.c. * libgcc2.h (__strub_enter, __strub_update, __strub_leave): Declare. * strub.c: New. * libgcc-std.ver.in (__strub_enter): Add to GCC_14.0.0. (__strub_update, __strub_leave): Likewise.
2023-11-21ada: Small consistency fix for -gnatwv warningEric Botcazou1-0/+1
The goal is to arrange for the warning to be issued consistently between objects whose address is taken and objects whose address is not taken. gcc/ada/ * sem_warn.adb (Check_References.Type_OK_For_No_Value_Assigned): New predicate. (Check_References): For Warn_On_No_Value_Assigned, use the same test on the type in the address-not-taken and default cases. gcc/testsuite/ChangeLog: * gnat.dg/warn25.adb: Add xfail.
2023-11-16Fix warning on new Ada testcaseEric Botcazou1-1/+2
gcc/testsuite/ * gnat.dg/varsize4.adb (Func): Initialize Byte_Read parameter.
2023-11-16Fix internal error on function returning dynamically-sized typeEric Botcazou3-0/+33
This is a tree sharing issue for the internal return type synthesized for a function returning a dynamically-sized type and taking an Out or In/Out parameter passed by copy. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Also create a TYPE_DECL for the return type built for the CI/CO mechanism. gcc/testsuite/ * gnat.dg/varsize4.ads, gnat.dg/varsize4.adb: New test. * gnat.dg/varsize4_pkg.ads: New helper.
2023-11-10Handle constant CONSTRUCTORs in operand_compareEric Botcazou2-0/+51
This teaches operand_compare to compare constant CONSTRUCTORs, which is quite helpful for so-called fat pointers in Ada, i.e. objects that are semantically pointers but are represented by structures made up of two pointers. This is modeled on the implementation present in the ICF pass. gcc/ * fold-const.cc (operand_compare::operand_equal_p) <CONSTRUCTOR>: Deal with nonempty constant CONSTRUCTORs. (operand_compare::hash_operand) <CONSTRUCTOR>: Hash DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET for FIELD_DECLs. gcc/testsuite/ * gnat.dg/opt103.ads, gnat.dg/opt103.adb: New test.
2023-11-09Fix PR ada/111813 (Inconsistent limit in Ada.Calendar.Formatting)Simon Wright1-0/+26
The description of the second Value function (returning Duration) (ARM 9.6.1(87) doesn't place any limitation on the Elapsed_Time parameter's value, beyond "Constraint_Error is raised if the string is not formatted as described for Image, or the function cannot interpret the given string as a Duration value". It would seem reasonable that Value and Image should be consistent, in that any string produced by Image should be accepted by Value. Since Image must produce a two-digit representation of the Hours, there's an implication that its Elapsed_Time parameter should be less than 100.0 hours (the ARM merely says that in that case the result is implementation-defined). The current implementation of Value raises Constraint_Error if the Elapsed_Time parameter is greater than or equal to 24 hours. This patch removes the restriction, so that the Elapsed_Time parameter must only be less than 100.0 hours. 2023-10-15 Simon Wright <simon@pushface.org> PR ada/111813 gcc/ada/ * libgnat/a-calfor.adb (Value (2)): Allow values of parameter Elapsed_Time greater than or equal to 24 hours, by doing the hour calculations in Natural rather than Hour_Number (0 .. 23). Calculate the result directly rather than by using Seconds_Of (whose Hour parameter is of type Hour_Number). If an exception occurs of type Constraint_Error, re-raise it rather than raising a new CE. gcc/testsuite/ * gnat.dg/calendar_format_value.adb: New test.
2023-10-20Control flow redundancy hardeningAlexandre Oliva1-0/+76
This patch introduces an optional hardening pass to catch unexpected execution flows. Functions are transformed so that basic blocks set a bit in an automatic array, and (non-exceptional) function exit edges check that the bits in the array represent an expected execution path in the CFG. Functions with multiple exit edges, or with too many blocks, call an out-of-line checker builtin implemented in libgcc. For simpler functions, the verification is performed in-line. -fharden-control-flow-redundancy enables the pass for eligible functions, --param hardcfr-max-blocks sets a block count limit for functions to be eligible, and --param hardcfr-max-inline-blocks tunes the "too many blocks" limit for in-line verification. -fhardcfr-skip-leaf makes leaf functions non-eligible. Additional -fhardcfr-check-* options are added to enable checking at exception escape points, before potential sibcalls, hereby dubbed returning calls, and before noreturn calls and exception raises. A notable case is the distinction between noreturn calls expected to throw and those expected to terminate or loop forever: the default setting for -fhardcfr-check-noreturn-calls, no-xthrow, performs checking before the latter, but the former only gets checking in the exception handler. GCC can only tell between them by explicit marking noreturn functions expected to raise with the newly-introduced expected_throw attribute, and corresponding ECF_XTHROW flag. for gcc/ChangeLog * tree-core.h (ECF_XTHROW): New macro. * tree.cc (set_call_expr): Add expected_throw attribute when ECF_XTHROW is set. (build_common_builtin_node): Add ECF_XTHROW to __cxa_end_cleanup and _Unwind_Resume or _Unwind_SjLj_Resume. * calls.cc (flags_from_decl_or_type): Check for expected_throw attribute to set ECF_XTHROW. * gimple.cc (gimple_build_call_from_tree): Propagate ECF_XTHROW from decl flags to gimple call... (gimple_call_flags): ... and back. * gimple.h (GF_CALL_XTHROW): New gf_mask flag. (gimple_call_set_expected_throw): New. (gimple_call_expected_throw_p): New. * Makefile.in (OBJS): Add gimple-harden-control-flow.o. * builtins.def (BUILT_IN___HARDCFR_CHECK): New. * common.opt (fharden-control-flow-redundancy): New. (-fhardcfr-check-returning-calls): New. (-fhardcfr-check-exceptions): New. (-fhardcfr-check-noreturn-calls=*): New. (Enum hardcfr_check_noreturn_calls): New. (fhardcfr-skip-leaf): New. * doc/invoke.texi: Document them. (hardcfr-max-blocks, hardcfr-max-inline-blocks): New params. * flag-types.h (enum hardcfr_noret): New. * gimple-harden-control-flow.cc: New. * params.opt (-param=hardcfr-max-blocks=): New. (-param=hradcfr-max-inline-blocks=): New. * passes.def (pass_harden_control_flow_redundancy): Add. * tree-pass.h (make_pass_harden_control_flow_redundancy): Declare. * doc/extend.texi: Document expected_throw attribute. for gcc/ada/ChangeLog * gcc-interface/trans.cc (gigi): Mark __gnat_reraise_zcx with ECF_XTHROW. (build_raise_check): Likewise for all rcheck subprograms. for gcc/c-family/ChangeLog * c-attribs.cc (handle_expected_throw_attribute): New. (c_common_attribute_table): Add expected_throw. for gcc/cp/ChangeLog * decl.cc (push_throw_library_fn): Mark with ECF_XTHROW. * except.cc (build_throw): Likewise __cxa_throw, _ITM_cxa_throw, __cxa_rethrow. for gcc/testsuite/ChangeLog * c-c++-common/torture/harden-cfr.c: New. * c-c++-common/harden-cfr-noret-never-O0.c: New. * c-c++-common/torture/harden-cfr-noret-never.c: New. * c-c++-common/torture/harden-cfr-noret-noexcept.c: New. * c-c++-common/torture/harden-cfr-noret-nothrow.c: New. * c-c++-common/torture/harden-cfr-noret.c: New. * c-c++-common/torture/harden-cfr-notail.c: New. * c-c++-common/torture/harden-cfr-returning.c: New. * c-c++-common/torture/harden-cfr-tail.c: New. * c-c++-common/torture/harden-cfr-abrt-always.c: New. * c-c++-common/torture/harden-cfr-abrt-never.c: New. * c-c++-common/torture/harden-cfr-abrt-no-xthrow.c: New. * c-c++-common/torture/harden-cfr-abrt-nothrow.c: New. * c-c++-common/torture/harden-cfr-abrt.c: New. * c-c++-common/torture/harden-cfr-always.c: New. * c-c++-common/torture/harden-cfr-never.c: New. * c-c++-common/torture/harden-cfr-no-xthrow.c: New. * c-c++-common/torture/harden-cfr-nothrow.c: New. * c-c++-common/torture/harden-cfr-bret-always.c: New. * c-c++-common/torture/harden-cfr-bret-never.c: New. * c-c++-common/torture/harden-cfr-bret-noopt.c: New. * c-c++-common/torture/harden-cfr-bret-noret.c: New. * c-c++-common/torture/harden-cfr-bret-no-xthrow.c: New. * c-c++-common/torture/harden-cfr-bret-nothrow.c: New. * c-c++-common/torture/harden-cfr-bret-retcl.c: New. * c-c++-common/torture/harden-cfr-bret.c: New. * g++.dg/harden-cfr-throw-always-O0.C: New. * g++.dg/harden-cfr-throw-returning-O0.C: New. * g++.dg/torture/harden-cfr-noret-always-no-nothrow.C: New. * g++.dg/torture/harden-cfr-noret-never-no-nothrow.C: New. * g++.dg/torture/harden-cfr-noret-no-nothrow.C: New. * g++.dg/torture/harden-cfr-throw-always.C: New. * g++.dg/torture/harden-cfr-throw-never.C: New. * g++.dg/torture/harden-cfr-throw-no-xthrow.C: New. * g++.dg/torture/harden-cfr-throw-no-xthrow-expected.C: New. * g++.dg/torture/harden-cfr-throw-nothrow.C: New. * g++.dg/torture/harden-cfr-throw-nocleanup.C: New. * g++.dg/torture/harden-cfr-throw-returning.C: New. * g++.dg/torture/harden-cfr-throw.C: New. * gcc.dg/torture/harden-cfr-noret-no-nothrow.c: New. * gcc.dg/torture/harden-cfr-tail-ub.c: New. * gnat.dg/hardcfr.adb: New. for libgcc/ChangeLog * Makefile.in (LIB2ADD): Add hardcfr.c. * hardcfr.c: New.
2023-09-25Add missing return in gori_compute::logical_combineEric Botcazou3-0/+32
The varying case currently falls through to the 1/true case. gcc/ * gimple-range-gori.cc (gori_compute::logical_combine): Add missing return statement in the varying case. gcc/testsuite/ * gnat.dg/opt102.adb:New test. * gnat.dg/opt102_pkg.adb, gnat.dg/opt102_pkg.ads: New helper.
2023-09-19ada: TSS finalize address subprogram generation for constrained...Richard Wai1-0/+60
...subtypes of unconstrained synchronized private extensions should take care to designate the corresponding record of the underlying concurrent type. When generating TSS finalize address subprograms for class-wide types of constrained root types, it follows the parent chain looking for the first "non-constrained" type. It is possible that such a type is a private extension with the “synchronized” keyword, in which case the underlying type is a concurrent type. When that happens, the designated type of the finalize address subprogram should be the corresponding record’s class-wide-type. gcc/ada/ChangeLog: * exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Expanded comments explaining why TSS Finalize_Address is not generated for concurrent class-wide types. * exp_ch7.adb (Make_Finalize_Address_Stmts): Handle cases where the underlying non-constrained parent type is a concurrent type, and adjust the designated type to be the corresponding record’s class-wide type. gcc/testsuite/ChangeLog: * gnat.dg/sync_tag_finalize.adb: New test. Signed-off-by: Richard Wai <richard@annexi-strayline.com>
2023-09-19ada: Private extensions with the keyword "synchronized" are always limited.Richard Wai2-0/+101
GNAT was relying on synchronized private type extensions deriving from a concurrent interface to determine its limitedness. This does not cover the case where such an extension derives a limited interface. RM-7.6(6/2) makes is clear that "synchronized" in a private extension implies the derived type is limited. GNAT should explicitly check for the presence of "synchronized" in a private extension declaration, and it should have the same effect as the presence of “limited”. gcc/ada/ChangeLog: * sem_ch3.adb (Build_Derived_Record_Type): Treat presence of keyword "synchronized" the same as "limited" when determining if a private extension is limited. gcc/testsuite/ChangeLog: * gnat.dg/sync_tag_discriminals.adb: New test. * gnat.dg/sync_tag_limited.adb: New test. Signed-off-by: Richard Wai <richard@annexi-strayline.com>
2023-09-05Revert "Adjust one Ada test"Marc Poulhiès1-1/+1
This reverts commit d8dc61bb5ab99c3239ea93a37097f9419bee0211.
2023-07-25Adjust one Ada testMarc Poulhiès1-1/+1
Recent change modified how the loops are created, with the first iteration being extracted out of the loops in the 2 test cases. Adjust the text to match from the unroll dump. gcc/testsuite/ChangeLog: * gnat.dg/unroll3.adb: Adjust.
2023-05-29Fix artificial overflow during GENERIC foldingEric Botcazou1-0/+18
The Ada compiler gives a bogus warning: storage_offset1.ads:16:52: warning: Constraint_Error will be raised at run time [enabled by default] Ironically enough, this occurs because of an intermediate conversion to an unsigned type which is supposed to hide overflows but is counter-productive for constants because TREE_OVERFLOW is always set for them, so it ends up setting a bogus TREE_OVERFLOW when converting back to the original type. The fix simply redirects INTEGER_CSTs to the other, direct path without the intermediate conversion to the unsigned type. gcc/ * match.pd ((T)P - (T)(P + A) -> -(T) A): Avoid artificial overflow on constants. gcc/testsuite/ * gnat.dg/specs/storage_offset1.ads: New test.
2023-05-23Fix handling of non-integral bit-fields in native_encode_initializerEric Botcazou2-0/+49
The encoder for CONSTRUCTORs assumes that all bit-fields (DECL_BIT_FIELD) have integral types, but that's not the case in Ada where they may have pretty much any type, resulting in a wrong encoding for them gcc/ * fold-const.cc (native_encode_initializer) <CONSTRUCTOR>: Apply the specific treatment for bit-fields only if they have an integral type and filter out non-integral bit-fields that do not start and end on a byte boundary. gcc/testsuite/ * gnat.dg/opt101.adb: New test. * gnat.dg/opt101_pkg.ads: New helper.
2023-05-19Fix internal error on small array with negative lower boundEric Botcazou1-0/+14
Ada supports arrays with negative indices, although the internal index type is sizetype like in other languages, which is unsigned. This means that negative values are represented by very large numbers, which works with a bit of care. This plugs a small loophole in output_constructor_bitfield. gcc/ * varasm.cc (output_constructor_bitfield): Call tree_to_uhwi instead of tree_to_shwi on array indices. Minor tweaks. gcc/testsuite/ * gnat.dg/specs/array6.ads: New test.
2023-04-02Fix gnat.dg/opt39.adb on hppa.John David Anglin1-1/+1
Add hppa*-*-* to dg-additional-options list. 2023-04-02 John David Anglin <danglin@gcc.gnu.org> gcc/testsuite/ChangeLog: PR target/109375 * gnat.dg/opt39.adb: Add hppa*-*-* to dg-additional-options list.
2023-04-02Skip gnat.dg/prot7.adb on hppa.John David Anglin1-0/+1
Test needs to be skipped if the target does not support atomic primitives. 2023-04-02 John David Anglin <danglin@gcc.gnu.org> gcc/testsuite/ChangeLog: PR target/109376 * gnat.dg/prot7.adb: Skip on hppa.
2023-03-23Skip gnat.dg/div_zero.adb on Aarch64Eric Botcazou1-1/+1
gcc/testsuite/ * gnat.dg/div_zero.adb: Skip for aarch64*-*-* targets.
2023-03-14Add testcase for ifcvt fixEric Botcazou1-0/+69
gcc/testsuite/ PR tree-optimization/109005 * gnat.dg/specs/opt6.ads: New test.
2023-02-14Fix small regression in AdaEric Botcazou1-0/+8
gcc/ * gimplify.cc (gimplify_save_expr): Add missing guard. gcc/ada/ * gcc-interface/trans.cc (gnat_gimplify_expr): Add missing guard. gcc/testsuite/ * gnat.dg/shift2.adb: New test.
2023-01-16Update copyright years.Jakub Jelinek4-4/+4
2022-11-29Fix PR ada/107810Eric Botcazou1-1/+1
This just makes the pattern matching more robust. gcc/testsuite/ PR ada/107810 * gnat.dg/unchecked_convert9.adb: Adjust pattern.
2022-11-25Fix thinko in operator_bitwise_xor::op1_rangeEric Botcazou3-0/+53
There is a thinko in the op1_range method of ranger's operator_bitwise_xor class in a boolean context: if the result is known to be true, it may infer that a specific operand is false without any basis. gcc/ * range-op.cc (operator_bitwise_xor::op1_range): Fix thinko. gcc/testsuite/ * gnat.dg/opt100.adb: New test. * gnat.dg/opt100_pkg.adb, gnat.dg/opt100_pkg.ads: New helper.
2022-11-22Fix wrong array type conversion with different storage ordeEric Botcazou1-0/+21
When two arrays of scalars have a different storage order in Ada, the front-end makes sure that the conversion is performed component-wise so that each component can be reversed. So it's a little bit counter productive that the ldist pass performs the opposite transformation and synthesizes a memcpy/memmove in this case. gcc/ * tree-loop-distribution.cc (loop_distribution::classify_builtin_ldst): Bail out if source and destination do not have the same storage order. gcc/testsuite/ * gnat.dg/sso18.adb: New test.
2022-11-21Make ARMv8-M attribute cmse_nonsecure_call work in AdaEric Botcazou2-0/+23
Unlike most other machine attributes, this one does not work in Ada because, while it applies to pointer-to-function types, it is explicitly marked as requiring declarations in the implementation. Now, in Ada, machine attributes are specified like this: type Non_Secure is access procedure; pragma Machine_Attribute (Non_Secure, "cmse_nonsecure_call"); i.e. not attached to the declaration of Non_Secure. The change extends the support to Ada by also accepting pointer-to-function types in the handler. gcc/ * config/arm/arm.cc (arm_attribute_table) <cmse_nonsecure_call>: Change decl_required field to false. (arm_handle_cmse_nonsecure_call): Deal with a TYPE node. gcc/testsuite/ * gnat.dg/machine_attr2.ads, gnat.dg/machine_attr2.adb: New test.
2022-11-04Fix recent thinko in operand_equal_pEric Botcazou4-0/+57
There is a thinko in a recent improvement made to operand_equal_p where the code just looks at operand 2 of COMPONENT_REF, if it is present, to compare addresses. That's wrong because operand 2 contains the number of DECL_OFFSET_ALIGN-bit-sized words so, when DECL_OFFSET_ALIGN > 8, not all the bytes are included and some of them are in DECL_FIELD_BIT_OFFSET, see get_inner_reference for the model computation. In other words, you would need to compare operand 2 and DECL_OFFSET_ALIGN and DECL_FIELD_BIT_OFFSET in this situation, but I'm not sure this is worth the hassle in practice so the fix just removes this alternate handling. gcc/ * fold-const.cc (operand_compare::operand_equal_p) <COMPONENT_REF>: Do not take into account operand 2. (operand_compare::hash_operand) <COMPONENT_REF>: Likewise. gcc/testsuite/ * gnat.dg/opt99.adb: New test. * gnat.dg/opt99_pkg1.ads, gnat.dg/opt99_pkg1.adb: New helper. * gnat.dg/opt99_pkg2.ads: Likewise.
2022-11-04ada: Flag unsupported dispatching constructor callsJavier Miranda2-9/+11
gcc/ada/ * exp_intr.adb (Expand_Dispatching_Constructor_Call): Report an error on unsupported dispatching constructor calls and report a warning on calls that may fail at run time. gcc/testsuite/ * gnat.dg/abstract1.ads: Cleanup whitespaces. * gnat.dg/abstract1.adb: Likewise and add -gnatws to silence new warning.
2022-10-25Relax assertion in profilerEric Botcazou3-0/+13
This assertion in branch_prob: if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb) { location_t loc = DECL_SOURCE_LOCATION (current_function_decl); gcc_checking_assert (!RESERVED_LOCATION_P (loc)); had been correct until the fix for PR debug/101598 was installed. gcc/ * profile.cc (branch_prob): Be prepared for ignored functions with DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION. gcc/testsuite: * gnat.dg/specs/coverage1.ads: New test. * gnat.dg/specs/variant_part.ads: Minor tweak. * gnat.dg/specs/weak1.ads: Add dg directive.
2022-10-05Fix bogus -Wstringop-overflow warning in AdaEric Botcazou5-0/+59
It comes from a discrepancy between get_offset_range, which uses a signed type, and handle_array_ref, which uses an unsigned one, to do computations. gcc/ PR tree-optimization/106698 * pointer-query.cc (handle_array_ref): Fix handling of low bound. gcc/testsuite/ * gnat.dg/lto26.adb: New test. * gnat.dg/lto26_pkg1.ads, gnat.dg/lto26_pkg1.adb: New helper. * gnat.dg/lto26_pkg2.ads, gnat.dg/lto26_pkg2.adb: Likewise.
2022-09-12[Ada] Replace SPARK containers implementation by Compile_Time_ErrorJoffrey Huguet10-228/+0
The SPARK containers are now maintained under the spark2014 repository. This change replaces the implementation of SPARK containers by a pragma Compile_Time_Error, pointing the users WITHing the libraries to their new location. gcc/ada/ * Makefile.rtl: Remove SPARK containers filenames. * impunit.adb: Remove SPARK containers packages names. * libgnat/a-cfdlli.adb, libgnat/a-cfdlli.ads: Remove content and add pragma Compile_Time_Error with suitable message. * libgnat/a-cfhama.adb, libgnat/a-cfhama.ads: Likewise. * libgnat/a-cfhase.adb, libgnat/a-cfhase.ads: Likewise. * libgnat/a-cfidll.adb, libgnat/a-cfidll.ads: Likewise. * libgnat/a-cfinse.adb, libgnat/a-cfinse.ads: Likewise. * libgnat/a-cfinve.adb, libgnat/a-cfinve.ads: Likewise. * libgnat/a-cforma.adb, libgnat/a-cforma.ads: Likewise. * libgnat/a-cforse.adb, libgnat/a-cforse.ads: Likewise. * libgnat/a-cofove.adb, libgnat/a-cofove.ads: Likewise. * libgnat/a-cofuma.adb, libgnat/a-cofuma.ads: Likewise. * libgnat/a-cofuse.adb, libgnat/a-cofuse.ads: Likewise. * libgnat/a-cofuve.adb, libgnat/a-cofuve.ads: Likewise. * libgnat/a-cofuba.adb, libgnat/a-cofuba.ads: Remove package. gcc/testsuite/ * gnat.dg/aspect2.adb: Removed. * gnat.dg/aspect2.ads: Removed. * gnat.dg/config_pragma1.adb: Removed. * gnat.dg/config_pragma1_pkg.ads: Removed. * gnat.dg/equal8.adb: Removed. * gnat.dg/equal8.ads: Removed. * gnat.dg/equal8_pkg.ads: Removed. * gnat.dg/formal_containers.adb: Removed. * gnat.dg/iter1.adb: Removed. * gnat.dg/iter1.ads: Removed.
2022-07-14Fix ICE on view conversion between struct and integerEric Botcazou2-0/+33
This happens from prepare_gimple_addressable for the variable to be marked with DECL_NOT_GIMPLE_REG_P when its initialization is gimplified, so it's apparently just a matter of setting the flag earlier. gcc/ * gimplify.cc (lookup_tmp_var): Add NOT_GIMPLE_REG boolean parameter and set DECL_NOT_GIMPLE_REG_P on the variable according to it. (internal_get_tmp_var): Add NOT_GIMPLE_REG boolean parameter and pass it in the call to lookup_tmp_var. (get_formal_tmp_var): Pass false in the call to lookup_tmp_var. (get_initialized_tmp_var): Likewise. (prepare_gimple_addressable): Call internal_get_tmp_var instead of get_initialized_tmp_var with NOT_GIMPLE_REG set to true. gcc/testsuite/ * gnat.dg/opt98.ads, gnat.dg/opt98.adb: New test.
2022-07-12[Ada] Warn on unset objects in packages with no bodiesPiotr Trojanek3-5/+6
Fix an inconsistency, where GNAT was warning about references to unset objects inside generic packages with no bodies but not inside ordinary packages with no bodies. gcc/ada/ * sem_ch7.adb (Analyze_Package_Declaration): Check references to unset objects. gcc/testsuite/ * gnat.dg/specs/discr5.ads: Expect new warnings. * gnat.dg/specs/empty_variants.ads: Likewise. * gnat.dg/specs/pack13.ads: Likewise.
2022-07-05[Ada] Warn about obsolete uses of renamed Ada 83 packagesPiotr Trojanek3-7/+7
Ada 83 packages like Unchecked_Conversion or Text_IO are obsolete since Ada 95. GNAT now warns about their uses when warnings on obsolescent featured (Annex J) is active. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Warning Message Control): Update description of switch -gnatwj. * gnat_ugn.texi: Regenerate. * sem_ch10.adb (Analyze_With_Clause): Warn on WITH clauses for obsolete renamed units; in Ada 83 mode do not consider predefined renamings to be obsolete. gcc/testsuite/ * gnat.dg/renaming1.adb: Update WITH clause. * gnat.dg/renaming1.ads: Likewise. * gnat.dg/warn29.adb: Likewise.
2022-05-13Introduce tests for hardbool Machine_Attribute for AdaAlexandre Oliva2-0/+68
Test for the validity checking performed on nonstandard booleans annotated with the "hardbool" Machine_Attribute pragma. for gcc/testsuite/ChangeLog * gnat.dg/hardbool.ads: New. * gnat.dg/hardbool.adb: New.
2022-05-13Fix wrong SRA with VIEW_CONVERT_EXPR and reverse SSOEric Botcazou1-0/+34
Most cases of VIEW_CONVERT_EXPRs involving reverse scalar storage order are disqualified for SRA because they are storage_order_barrier_p, but you can still have a VIEW_CONVERT_EXPR to a regular composite type being applied to a component of a record type with reverse scalar storage order. In this case the bypass for !useless_type_conversion_p in sra_modify_assign, albeit already heavily guarded, triggers and may generate wrong code, so the patch makes sure that it does only when the SSO is the same on both side. gcc/ * tree-sra.cc (sra_modify_assign): Check that scalar storage order is the same on the LHS and RHS before rewriting one with the model of the other. gcc/testsuite/ * gnat.dg/sso17.adb: New test.
2022-05-10[Ada] Accept Structural in aspect Subprogram_Variant and pragma Loop_VariantClaire Dross1-1/+1
Add a new form of variants to ensure termination of loops or recursive subprograms. Structural variants correspond to objects which designate a part of the data-structure they used to designate in the previous loop iteration or recursive call. They only imply termination if the data-structure is acyclic, which is the case in SPARK but not in Ada in general. The fact that these variants are correct is only verified formally by the proof tool and not by the compiler or dynamically at execution like other forms of variants. gcc/ada/ * snames.ads-tmpl: Add "Structural" as a name. * sem_prag.adb: (Analyze_Pragma): Accept modifier "Structural" in pragmas Loop_Variant and Subprogram_Variant. Check that items associated to Structural occur alone in the pragma associations. (Analyze_Subprogram_Variant_In_Decl_Part): Idem. * exp_prag.adb (Expand_Pragma_Loop_Variant): Discard structural variants. (Expand_Pragma_Subprogram_Variant): Idem. gcc/testsuite/ * gnat.dg/loopvar.adb: Update expected error message.
2022-05-10[Ada] Fix hiding of user-defined operator that is not a homographEric Botcazou1-1/+9
This adds a missing test for the presence of a homograph when applying the RM 8.4(10) clause about the visibility of operators, and removes resolution code made obsolete by the change. There is also a fixlet for a previously undetected ambiguity in the runtime. gcc/ada/ * sem_res.adb (Resolve_Eqyality_Op): Remove obsolete code. (Resolve_Op_Not): Likewise. * sem_type.adb (Disambiguate): Add missing test for RM 8.4(10). * libgnat/s-dwalin.adb (Enable_Cache): Fix ambiguity. (Symbolic_Address): Likewise. gcc/testsuite/ * gnat.dg/equal7.adb: Add expected error messages (code is now illegal).
2022-04-07ipa/104303 - miscompilation of gnatmakeRichard Biener5-0/+47
Modref attempts to track memory accesses relative to the base pointers which are parameters of functions. If it fails, it still makes difference between unknown memory access and global memory access. The second makes it possible to disambiguate with memory that is not accessible from outside world (i.e. everything that does not escape from the caller function). This is useful so we do not punt when unknown function is called. The added ref_may_access_global_memory_p ends up using ptr_deref_may_alias_global_p which does not consider escaped automatic variables as global. For modref those are still global since they can be accessed from functions called. The following adds a flag to the *_global_p APIs indicating whether escaped local memory should be considered as global or not and removes ref_may_access_global_memory_p in favor of using ref_may_alias_global_p with the flag set to true. 2022-04-07 Richard Biener <rguenther@suse.de> Jan Hubicka <hubicka@ucw.cz> PR ipa/104303 * tree-ssa-alias.h (ptr_deref_may_alias_global_p, ref_may_alias_global_p, ref_may_alias_global_p, stmt_may_clobber_global_p, pt_solution_includes_global): Add bool parameters indicating whether escaped locals should be considered global. * tree-ssa-structalias.cc (pt_solution_includes_global): When the new escaped_nonlocal_p flag is true also consider pt->vars_contains_escaped. * tree-ssa-alias.cc (ptr_deref_may_alias_global_p): Pass down new escaped_nonlocal_p flag. (ref_may_alias_global_p): Likewise. (stmt_may_clobber_global_p): Likewise. (ref_may_alias_global_p_1): Likewise. For decls also query the escaped solution if true. (ref_may_access_global_memory_p): Remove. (modref_may_conflict): Use ref_may_alias_global_p with escaped locals considered global. (ref_maybe_used_by_stmt_p): Adjust. * ipa-fnsummary.cc (points_to_local_or_readonly_memory_p): Likewise. * tree-ssa-dse.cc (dse_classify_store): Likewise. * trans-mem.cc (thread_private_new_memory): Likewise, but consider escaped locals global. * tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Likewise. * gnat.dg/concat5.adb: New. * gnat.dg/concat5_pkg1.adb: Likewise. * gnat.dg/concat5_pkg1.ads: Likewise. * gnat.dg/concat5_pkg2.adb: Likewise. * gnat.dg/concat5_pkg2.ads: Likewise.
2022-02-04Add optmization testcase for incorrect optimization in AdaEric Botcazou1-0/+25
gcc/testsuite/ PR tree-optimization/104356 * gnat.dg/opt97.adb: New test.