Pengxuan Zheng [Tue, 21 May 2024 17:55:06 +0000 (10:55 -0700)]
aarch64: Fold vget_high_* intrinsics to BIT_FIELD_REF [PR102171]
This patch is a follow-up of r15-697-ga2e4fe5a53cf75 to also fold vget_high_*
intrinsics to BIT_FILED_REF and remove the vget_high_* definitions from
arm_neon.h to use the new intrinsics framework.
Eric Botcazou [Wed, 22 May 2024 16:10:39 +0000 (18:10 +0200)]
Fix internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
The problem directly comes from the -ffold-mem-offsets pass messing up with
the prologue and the frame-related instructions, which is a no-no with SEH,
so the fix simply disconnects the pass in these circumstances.
gcc/
PR rtl-optimization/115038
* fold-mem-offsets.cc (fold_offsets): Return 0 if the defining
instruction of the register is frame related.
Roger Sayle [Wed, 22 May 2024 15:45:48 +0000 (16:45 +0100)]
i386: Correct insn_cost of movabsq.
This single line patch fixes a strange quirk/glitch in i386's rtx_costs,
which considers an instruction loading a 64-bit constant to be significantly
cheaper than loading a 32-bit (or smaller) constant.
Consider the two functions:
unsigned long long foo() { return 0x0123456789abcdefULL; }
unsigned int bar() { return 10; }
and the corresponding lines from combine's dump file:
insn_cost 1 for #: r98:DI=0x123456789abcdef
insn_cost 4 for #: ax:SI=0xa
The same issue can be seen in -dP assembler output.
movabsq $81985529216486895, %rax # 5 [c=1 l=10] *movdi_internal/4
The problem is that pattern_costs interpretation of rtx_costs contains
"return cost > 0 ? cost : COSTS_N_INSNS (1)" where a zero value (for
example a register or small immediate constant) is considered special,
and equivalent to a single instruction, but all other values are treated
as verbatim. Hence to x86_64's 10-byte long movabsq instruction slightly
more expensive than a simple constant, rtx_costs needs to return
COSTS_N_INSNS(1)+1 and not 1. With this change, the insn_cost of
movabsq is the intended value 5:
insn_cost 5 for #: r98:DI=0x123456789abcdef
and
movabsq $81985529216486895, %rax # 5 [c=5 l=10] *movdi_internal/4
2024-05-22 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/i386.cc (ix86_rtx_costs) <case CONST_INT>:
A CONST_INT that isn't x86_64_immediate_operand requires an extra
(expensive) movabsq insn to load, so return COSTS_N_INSNS (1) + 1.
Roger Sayle [Wed, 22 May 2024 12:48:52 +0000 (13:48 +0100)]
Avoid ICE in except.cc on targets that don't support exceptions.
A number of testcases currently fail on nvptx with the ICE:
during RTL pass: final
openmp-simd-2.c: In function 'foo':
openmp-simd-2.c:28:1: internal compiler error: in get_personality_function, at expr.cc:14037
28 | }
| ^
0x98a38f get_personality_function(tree_node*)
/home/roger/GCC/nvptx-none/gcc/gcc/expr.cc:14037
0x969d3b output_function_exception_table(int)
/home/roger/GCC/nvptx-none/gcc/gcc/except.cc:3226
0x9b760d rest_of_handle_final
/home/roger/GCC/nvptx-none/gcc/gcc/final.cc:4252
The simple oversight in output_function_exception_table is that it calls
get_personality_function (immediately) before checking the target's
except_unwind_info hook (which on nvptx always returns UI_NONE).
The (perhaps obvious) fix is to move the assignments of fname and
personality after the tests that they are needed, and before their
first use.
2024-05-22 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* except.cc (output_function_exception_table): Move call to
get_personality_function after targetm_common.except_unwind_info
check, to avoid ICE on targets that don't support exceptions.
Richard Biener [Tue, 21 May 2024 17:15:33 +0000 (19:15 +0200)]
Fix mixed input kind permute optimization
When change_vec_perm_layout runs into a permute combining two
nodes where one is invariant and one internal the partition of
one input can be -1 but the other might not be. The following
supports this case by simply ignoring inputs with input partiton -1.
I'm not sure this is correct but it avoids ICEing when accessing
that partitions layout for gcc.target/i386/pr98928.c with the
change to avoid splitting store dataref groups during SLP discovery.
* tree-vect-slp.cc (change_vec_perm_layout): Ignore an
input partition of -1.
Richard Biener [Fri, 17 May 2024 12:26:38 +0000 (14:26 +0200)]
Avoid requiring VEC_PERM represenatives
The following plugs one hole where we require a VEC_PERM node
representative unnecessarily. This is for vect_check_store_rhs
which looks at the RHS and checks whether a constant can be
native encoded. The fix is to guard that with vect_constant_def
additionally and making vect_is_simple_use forgiving for a missing
SLP_TREE_REPRESENTATIVE when the child is a VEC_PERM node,
initializing the scalar def to error_mark_node.
* tree-vect-stmts.cc (vect_check_store_rhs): Look at *rhs
only when it's a vec_constant_def.
(vect_is_simple_use): When we have no representative for
an internal node, fill in *op with error_mark_node.
Jonathan Wakely [Fri, 17 May 2024 09:55:32 +0000 (10:55 +0100)]
libstdc++: Implement std::formatter<std::thread::id> without <sstream> [PR115099]
The std::thread::id formatter uses std::basic_ostringstream without
including <sstream>, which went unnoticed because the test for it uses
a stringstream to check the output is correct.
The fix implemented here is to stop using basic_ostringstream for
formatting thread::id and just use std::format instead.
As a drive-by fix, the formatter specialization is constrained to
require that the thread::id::native_handle_type can be formatted, to
avoid making the formatter ill-formed if the pthread_t type is not a
pointer or integer. Since non-void pointers can't be formatted, ensure
that we convert pointers to const void* for formatting. Make a similar
change to the existing operator<< overload so that in the unlikely case
that pthread_t is a typedef for char* we don't treat it as a
null-terminated string when inserting into a stream.
libstdc++-v3/ChangeLog:
PR libstdc++/115099
* include/bits/std_thread.h: Declare formatter as friend of
thread::id.
* include/std/thread (operator<<): Convert non-void pointers to
void pointers for output.
(formatter): Add constraint that thread::native_handle_type is a
pointer or integer.
(formatter::format): Reimplement without basic_ostringstream.
* testsuite/30_threads/thread/id/output.cc: Check output
compiles before <sstream> has been included.
Apparently this happens because the Solaris as/ld combo doesn't support
SHF_MERGE.
While I initially meant to just skip the test on sparc*-*-solaris2* && !gas,
Tom suggested to allow for both forms instead, which is what his patch
does.
Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11 (as and gas
each) and x86_64-pc-linux-gnu.
2024-05-21 Tom de Vries <tdevries@suse.de>
gcc/testsuite:
PR debug/115066
* gcc.dg/pr115066.c (scan-assembler): Allow for alternative form
of Define macro.
Jakub Jelinek [Wed, 22 May 2024 07:13:50 +0000 (09:13 +0200)]
strlen: Fix up !si->full_string_p handling in count_nonzero_bytes_addr [PR115152]
The following testcase is miscompiled because
strlen_pass::count_nonzero_bytes_addr doesn't handle correctly
the !si->full_string_p case.
If si->full_string_p, it correctly computes minlen and maxlen as
minimum and maximum length of the '\0' terminated stgring and
clears *nulterm (ie. makes sure !full_string_p in the ultimate
caller) if minlen is equal or larger than nbytes and so
'\0' isn't guaranteed to be among those bytes.
But in the !si->full_string_p case, all we know is that there
are [minlen,maxlen] non-zero bytes followed by unknown bytes,
so effectively the maxlen is infinite (but caller cares about only
the first nbytes bytes) and furthermore, we never know if there is
any '\0' char among those, so *nulterm needs to be always cleared.
2024-05-22 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/115152
* tree-ssa-strlen.cc (strlen_pass::count_nonzero_bytes_addr): If
!si->full_string_p, clear *nulterm and set maxlen to nbytes.
Jakub Jelinek [Wed, 22 May 2024 07:12:28 +0000 (09:12 +0200)]
ubsan: Use right address space for MEM_REF created for bool/enum sanitization [PR115172]
The following testcase is miscompiled, because -fsanitize=bool,enum
creates a MEM_REF without propagating there address space qualifiers,
so what should be normally loaded using say %gs:/%fs: segment prefix
isn't. Together with asan it then causes that load to be sanitized.
2024-05-22 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/115172
* ubsan.cc (instrument_bool_enum_load): If rhs is not in generic
address space, use qualified version of utype with the right
address space. Formatting fix.
Haochen Jiang [Tue, 21 May 2024 06:10:43 +0000 (14:10 +0800)]
i386: Disable ix86_expand_vecop_qihi2 when !TARGET_AVX512BW
Since vpermq is really slow, we should avoid using it for permutation
when vpmovwb is not available (needs AVX512BW) for ix86_expand_vecop_qihi2
and fall back to ix86_expand_vecop_qihi.
gcc/ChangeLog:
PR target/115069
* config/i386/i386-expand.cc (ix86_expand_vecop_qihi2):
Do not enable the optimization when AVX512BW is not enabled.
xuli [Mon, 20 May 2024 01:56:47 +0000 (01:56 +0000)]
RISC-V: Enable vectorization for vect-early-break_124-pr114403.c
Because "targetm.slow_unaligned_access" is set to true by default
(aka -mtune=rocket) for RISC-V, it causes the __builtin_memcpy with
8 bytes failed to folded into int64 assignment during ccp1.
So adding "-mtune=generic-ooo" to the RISC-V target can vectorize
vect-early-break_124-pr114403.c.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-early-break_124-pr114403.c: Enable vectrization for RISC-V target.
Nathaniel Shead [Sat, 11 May 2024 12:25:44 +0000 (22:25 +1000)]
c++: Strengthen checks on 'main'
This patch adds some missing requirements for legal main declarations,
as according to [basic.start.main] p2.
gcc/cp/ChangeLog:
* decl.cc (grokfndecl): Check for main functions with language
linkage or module attachment.
(grokvardecl): Check for extern 'C' entities named main.
gcc/testsuite/ChangeLog:
* g++.dg/abi/main.C: Check pedwarn for main with linkage-spec.
* g++.dg/modules/contracts-1_b.C: Don't declare main in named
module.
* g++.dg/modules/contracts-3_b.C: Likewise.
* g++.dg/modules/contracts-4_d.C: Likewise.
* g++.dg/modules/horcrux-1_a.C: Export declarations, so that...
* g++.dg/modules/horcrux-1_b.C: Don't declare main in named
module.
* g++.dg/modules/main-1.C: New test.
* g++.dg/parse/linkage5.C: New test.
* g++.dg/parse/linkage6.C: New test.
Patrick Palka [Tue, 21 May 2024 19:54:10 +0000 (15:54 -0400)]
c++: folding non-dep enumerator from current inst [PR115139]
After the tsubst_copy removal r14-4796-g3e3d73ed5e85e7 GCC 14 ICEs during
fold_non_dependent_expr for 'e1 | e2' below ultimately because we no
longer exit early when substituting the CONST_DECLs for e1 and e2 with
args=NULL_TREE and instead proceed to substitute the class context A<Ts...>
(also with args=NULL_TREE) which ends up ICEing from tsubst_pack_expansion
(due to processing_template_decl being cleared).
Incidentally, the ICE went away on trunk ever since the tsubst_aggr_type
removal r15-123-gf04dc89a991ddc since it changed the CONST_DECL case of
tsubst_expr to use tsubst to substitute the context, which short circuits
for empty args and so avoids the ICE.
This patch fixes this ICE for GCC 14 by narrowly restoring the early exit
for empty args that would've happened in tsubst_copy when substituting an
enumerator CONST_DECL. We might as well apply this to trunk too, as a
small optimization.
PR c++/115139
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) <case CONST_DECL>: Exit early if args
is empty.
gcc/testsuite/ChangeLog:
* g++.dg/template/non-dependent33.C: New test.
Reviewed-by: Marek Polacek <mpolacek@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Vineet Gupta [Mon, 13 May 2024 18:46:03 +0000 (11:46 -0700)]
RISC-V: avoid LUI based const mat in prologue/epilogue expansion [PR/105733]
If the constant used for stack offset can be expressed as sum of two S12
values, the constant need not be materialized (in a reg) and instead the
two S12 bits can be added to instructions involved with frame pointer.
This avoids burning a register and more importantly can often get down
to be 2 insn vs. 3.
The prev patches to generally avoid LUI based const materialization didn't
fix this PR and need this directed fix in funcion prologue/epilogue
expansion.
This fix doesn't move the neddle for SPEC, at all, but it is still a
win considering gcc generates one insn fewer than llvm for the test ;-)
gcc/ChangeLog:
PR target/105733
* config/riscv/riscv.h: New macros for with aligned offsets.
* config/riscv/riscv.cc (riscv_split_sum_of_two_s12): New
function to split a sum of two s12 values into constituents.
(riscv_expand_prologue): Handle offset being sum of two S12.
(riscv_expand_epilogue): Ditto.
* config/riscv/riscv-protos.h (riscv_split_sum_of_two_s12): New.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr105733.c: New Test.
* gcc.target/riscv/rvv/autovec/vls/spill-1.c: Adjust to not
expect LUI 4096.
* gcc.target/riscv/rvv/autovec/vls/spill-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/spill-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/spill-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/spill-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/spill-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/spill-7.c: Ditto.
Gaius Mulley [Tue, 21 May 2024 14:46:46 +0000 (15:46 +0100)]
modula2: use groups in the type resolver of the bootstrap tool mc
This patch introduces groups to maintain the lists used when resolving
types in the bootstrap tool mc. The groups and type resolver are very
similar to that used in cc1gm2. Specifically the resolver uses the group
to detect any change to any element in any list within a group. This is
much cleaner and safer than the previous list length comparisons.
gcc/m2/ChangeLog:
* Make-lang.in (MC_EXTENDED_OPAQUE): New definition.
* mc-boot/GDynamicStrings.cc: Rebuild.
* mc-boot/GDynamicStrings.h: Rebuild.
* mc-boot/Galists.cc: Rebuild.
* mc-boot/Galists.h: Rebuild.
* mc-boot/Gdecl.cc: Rebuild.
* mc/alists.def (equalList): New procedure.
* mc/alists.mod (equalList): New procedure implementation.
* mc/decl.mod (group): New type.
(freeGroup): New variable.
(globalGroup): Ditto.
(todoQ): Remove declaration and prefix all occurances with globalGroup^.
(partialQ): Ditto.
(doneQ): Ditto.
(newGroup): New procedure.
(initGroup): Ditto.
(killGroup): Ditto.
(dupGroup): Ditto.
(equalGroup): Ditto.
(topologicallyOut): Rewrite.
Andrew Pinski [Mon, 20 May 2024 07:16:40 +0000 (00:16 -0700)]
match: Disable `(type)zero_one_valuep*CST` for 1bit signed types [PR115154]
The problem here is the pattern added in r13-1162-g9991d84d2a8435
assumes that it is well defined to multiply zero_one_valuep by the truncated
converted integer constant. It is well defined for all types except for signed 1bit types.
Where `a * -1` is produced which is undefined/
So disable this pattern for 1bit signed types.
Note the pattern added in r14-3432-gddd64a6ec3b38e is able to workaround the undefinedness except when
`-fsanitize=undefined` is turned on, this is why I added a testcase for that.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/115154
gcc/ChangeLog:
* match.pd (convert (mult zero_one_valued_p@1 INTEGER_CST@2)): Disable
for 1bit signed types.
gcc/testsuite/ChangeLog:
* c-c++-common/ubsan/signed1bitfield-1.c: New test.
* gcc.c-torture/execute/signed1bitfield-1.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
While reviewing Andrew's fix for PR114843, it seemed like it would
be convenient to have a HARD_REG_SET of EH_RETURN_DATA_REGNOs.
This patch adds one and uses it to simplify a couple of use sites.
gcc/
* hard-reg-set.h (target_hard_regs::x_eh_return_data_regs): New field.
(eh_return_data_regs): New macro.
* reginfo.cc (init_reg_sets_1): Initialize x_eh_return_data_regs.
* df-scan.cc (df_get_exit_block_use_set): Use it.
* ira-lives.cc (process_out_of_region_eh_regs): Likewise.
Richard Biener [Tue, 21 May 2024 07:48:04 +0000 (09:48 +0200)]
tree-optimization/115149 - VOP live and missing PHIs
The following fixes a bug in vop-live get_live_in which was using
NULL to indicate the first processed edge but at the same time
using it for the case the live-in virtual operand cannot be computed.
The following fixes this, avoiding sinking a load to a place where
we'd have to insert virtual PHIs to make the virtual operand SSA
web OK.
PR tree-optimization/115149
* tree-ssa-live.cc (virtual_operand_live::get_live_in):
Explicitly track the first processed edge.
* gcc-changelog/git_update_version.py: Add '-i'/'--ignore' argument
to add to-be-ignored commits via the command line.
(ignored_commits): Rename from IGNORED_COMMITS and change
type from tuple to set.
(prepend_to_changelog_files): Show git hash if errors occurred.
(update_current_branch): Mark argument as optional by defaulting
to None.
Eric Botcazou [Thu, 4 Apr 2024 14:39:55 +0000 (16:39 +0200)]
ada: Streamline implementation of simple nonbinary modular operations
They are implemented by the nonbinary_modular_operation routine, which is
complex and, in particular, creates signed types and types with a partial
precision each time a subtraction or a multiplication resp. is generated.
Both are unnecessary and a simple approach even generates better code for
the subtraction on architectures with conditional moves.
gcc/ada/
* gcc-interface/utils2.cc (nonbinary_modular_operation): Rewrite.
Do not create signed types for subtraction, do not create types with
partial precision, call fold_convert instead of convert throughout.
Eric Botcazou [Fri, 29 Mar 2024 08:08:08 +0000 (09:08 +0100)]
ada: Simplify test for propagation of attributes to subtypes
This changes the test to use the Is_Base_Type predicate and also removes the
superfluous call to Base_Type before First_Subtype. No functional changes.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity): Use the Is_Base_Type
predicate and remove superfluous calls to Base_Type.
Eric Botcazou [Wed, 27 Mar 2024 23:02:11 +0000 (00:02 +0100)]
ada: Fix internal error on discriminated record with Atomic aspect in Ada 2022
It occurs in build_load_modify_store where the pattern matching logic cannot
find the atomic load that is present in the tree because it has been wrapped
in a SAVE_EXPR by gnat_protect_expr, which is unnecessary.
gcc/ada/
* gcc-interface/utils2.cc (gnat_protect_expr): Deal specifically
with atomic loads. Document the relationship with gnat_save_expr.
Eric Botcazou [Sun, 10 Mar 2024 12:22:55 +0000 (13:22 +0100)]
ada: Fix strict aliasing violation in parameter passing (continued)
This fixes another long-standing (implicit) violation of the strict aliasing
rules that occurs when the result of a value conversion is directly passed
as an actual parameter in a call to a subprogram and the passing mechanism
is by reference. In this case, the reference passed to the subprogram may
be to a type that is too different from the type of the underlying object,
which is the definition of such a violation.
The change reworks and strengthens the previous fix as follows: first, the
detection of these violations is moved into a dedicated predicate; second,
an assertion is added to check that none of them has been missed, which is
triggered by either -fchecking or -fstrict-aliasing, as the closely related
assertion that is present in relate_alias_sets.
The assertion uncovered two internal sources of violations: implementation
types for packed array types with peculiar index types and interface types,
which are fixed by propagating alias sets in the first case and resorting to
universal aliasing in the second case.
Finally, an unconditional warning is implemented to inform the user that the
temporary is created and to suggest a possible solution to prevent that.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: For a
packed type implemented specially, temporarily save the XUA type as
equivalent to the entity before processing the implementation type.
For this implementation type, if its component type is the same as
that of the original type, copy the alias set from the latter.
<types>: Resort to universal aliasing for all interface types.
* gcc-interface/trans.cc (Call_to_gnu): Add GNU_ACTUAL_TYPE local
variable and rename existing one to GNU_UNPADDED_ACTUAL_TYPE.
If the formal is passed by reference and the actual is a conversion,
call aliasable_p to detect aliasing violations, issue a warning upon
finding one and create the temporary in the target type.
Add an assertion that no such violation has been missed above.
(addressable_p): Revert latest changes.
(aliasable_p): New predicate.
* gcc-interface/utils2.cc (build_binary_op) <ARRAY_RANGE_REF>: When
creating a new array type on the fly, preserve the alias set of the
operation type.
Eric Botcazou [Tue, 12 Mar 2024 16:56:00 +0000 (17:56 +0100)]
ada: Make detection of useless copy for return more robust
In the return-by-invisible-reference case, the return object of an extended
return statement is allocated directly on the return stack and, therefore,
the copy operation on return is useless. The code detecting this was not
robust enough and missed some complex cases.
gcc/ada/
* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
In the return-by-invisible-reference case, remove conversions before
looking for a dereference in the return values and building the test
protecting against a useless copy operation.
Eric Botcazou [Thu, 29 Feb 2024 08:14:27 +0000 (09:14 +0100)]
ada: Fix strict aliasing violation in parameter passing
This fixes a long-standing (implicit) violation of the strict aliasing rules
that occurs when the result of a call to an instance of Unchecked_Conversion
is directly passed as an actual parameter in a call to a subprogram and the
passing mechanism is by reference. In this case, the reference passed to
the subprogram may be to a type that has nothing to do with the type of the
underlying object, which is the definition of such a violation.
This implements the following two-pronged approach: first, the problematic
cases are detected and a reference to a temporary is passed instead of the
direct reference to the underlying object; second, the implementation of
pragma Universal_Aliasing is enhanced so that it is propagated from the
component type of an array type to the array type itself, or else can be
applied to the array type directly, and may therefore be used to prevent
the violation from occurring in the first place, when the array type is
involved in the Unchecked_Conversion.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Set
TYPE_TYPELESS_STORAGE on the array types if Universal_Aliasing is
set on the type or its component type.
<E_Array_Subtype>: Likewise.
For other aggregate types, set TYPE_TYPELESS_STORAGE in this case.
(set_typeless_storage_on_aggregate_type): New function.
(set_universal_aliasing_on_type): Likewise.
* gcc-interface/trans.cc (Call_to_gnu): Add const to local variable.
Adjust comment. Pass GNAT_NAME in the call to addressable_p and add
a bypass for atomic types in case it returns false.
(addressable_p): Add GNAT_EXPR third parameter with default value
and add a default value to the existing second parameter.
<VIEW_CONVERT_EXPR:>: Return false if the expression comes from a
function call and if the alias sets of source and target types are
both distinct from zero and each other.
ada: Fix crash with aliased array and if expression
The way if expressions were translated led the gimplifying phase
to attempt to create a temporary of a variable-sized type in some
cases. This patch fixes this by adding an address indirection layer
in those cases.
gcc/ada/
* gcc-interface/utils2.cc (build_cond_expr): Also apply an
indirection when the result type is variable-sized.
Eric Botcazou [Sun, 11 Feb 2024 18:18:46 +0000 (19:18 +0100)]
ada: Follow-up adjustment to earlier fix in Build_Allocate_Deallocate_Proc
The deallocation call of the return and secondary stacks no longer matches
the profile built in Exp_Util.Build_Allocate_Deallocate_Proc, so this just
removes the code as unreachable and adds an assertion to that effect.
gcc/ada/
* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Add an
assertion that this is not a deallocation of the return or secondary
stack and remove subsequent unreachable code.
Eric Botcazou [Tue, 6 Feb 2024 11:57:38 +0000 (12:57 +0100)]
ada: Avoid temporary for conditional expression of discriminated record type
This just aligns the definite case (discriminants with default) with the
indefinite case (discriminants without default), the latter case having
been properly handled for long. In the former case, the maximum size is
used so a temporary can be much larger than the actual data it contains.
gcc/ada/
* gcc-interface/utils2.cc (build_cond_expr): Use the indirect path
for all types containing a placeholder.
Piotr Trojanek [Fri, 26 Jan 2024 10:08:35 +0000 (11:08 +0100)]
ada: Remove unused dependencies from gnatbind object list
The gnatbind executable does not depend on aspects, SCIL, style checks,
etc. Also, these dependencies are not needed to actually build the
executable. Cleanup.
Eric Botcazou [Mon, 22 Jan 2024 22:56:37 +0000 (23:56 +0100)]
ada: Fix assembler error for gigantic library-level object on 64-bit Windows
Most small 64-bit code models have a limit of 2 GB on the span of binaries,
so we also use the limit for the size of the largest statically allocatable
object by the compiler. If the limit is topped, the compiler switches over
to a dynamic allocation (if not forbidden) after giving a warning.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Give a
warning for a statically allocated object whose size is constant,
valid but too large.
(allocatable_size_p): In the static case, return false for a size
that is constant, valid but too large.
Eric Botcazou [Fri, 12 Jan 2024 09:50:01 +0000 (10:50 +0100)]
ada: Fix crash on aliased constant with packed array type and -g switch
The problem is that we build a template whose array field is not an array
in the case of an aliased object with nominal unconstrained array subtype.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: For an
array allocated with its bounds, make sure to have an array type
to build the template.
Eric Botcazou [Thu, 14 Dec 2023 14:18:28 +0000 (15:18 +0100)]
ada: Fix small inaccuracy for Size attribute applied to objects
This reverts a change made some time ago in lvalue_required_for_attribute_p
whereby the Size attribute applied to objects would no longer be considered
as requiring an lvalue.
While not wrong in principle, this turns out to be problematic because the
implementation in Attribute_to_gnu needs to look at the translated prefix
to spot particular cases and not only at the actual type of its value.
This of course requires a small adjustment in gnat_to_gnu to compensate.
gcc/ada/
* gcc-interface/trans.cc (access_attribute_p): New predicate.
(lvalue_required_for_attribute_p): Return again 1 for Size and add
the missing terminating call to gcc_unreachable.
(gnat_to_gnu): Return the result unmodified for a reference to an
unconstrained array only if it is the prefix of an access attribute.
Steve Baird [Fri, 5 Apr 2024 19:35:08 +0000 (12:35 -0700)]
ada: Missing constraint check for initial value of object with address clause
In some cases where an object is declared with an initial value that is
an aggregate and also with a specified Address (either via an
aspect_specification or via an attribute_definition_clause), the
check that the initial value satisfies the constraints of the object's
subtype was incorrectly omitted.
gcc/ada/
* exp_util.adb (Remove_Side_Effects): Make_Reference assumes that
the referenced object satisfies the constraints of the designated
subtype of the access type. Ensure that this assumption holds by
introducing a qualified expression if needed (and then ensuring
that checking associated with evaluation of the qualified
expression is not suppressed).
This patch removes a duplicate statement that was useless and could
be misleading to the reader by suggesting that there are multiple
global variables named Style_Check, while there is just one.
Eric Botcazou [Thu, 4 Apr 2024 16:15:24 +0000 (18:15 +0200)]
ada: Remove useless trampolines caused by Unchecked_Conversion
The partial solution implemented in Validate_Unchecked_Conversion to support
unchecked conversions between addresses and pointers to subprograms, for the
platforms where pointers to subprograms do not all have the same size, turns
out to be counter-productive for others because it may cause the creation of
useless trampolines, which in turn makes the stack executable.
gcc/ada/
* sem_ch13.adb (Validate_Unchecked_Conversion): Restrict forcing the
Can_Use_Internal_Rep flag to platforms that require unnesting.
Add the ?$? insertion characters for elaboration
message so they would be marked with the [-gnatel]
tag. Note that these insertion characters were
not added for SPARK elaboration messages:
gcc/ada/
* sem_elab.adb: Add missing elaboration insertion
characters to info messages.
ada: Remove some explicit yields in tasking run-time
This patch removes three occurrences where tasking run-time
subprograms yielded control shortly before conditional calls to Sleep,
in order to avoid these calls more often. It was intended as an
optimization on systems where calls to Sleep are costly and in
particular VMS.
A problem was that two of the yields contained data races that were
reported by thread sanitizing tools on some platforms, and that's the
motivation for removing them.
gcc/ada/
* libgnarl/s-taenca.adb (Wait_For_Completion): Remove call to
Yield.
* libgnarl/s-tasren.adb (Timed_Selective_Wait, Wait_For_Call):
Remove calls to Yield.
Piotr Trojanek [Mon, 18 Mar 2024 17:00:55 +0000 (18:00 +0100)]
ada: Sort list of implemented Ada 2012 features
The list of implemented Ada 2012 features is now ordered by the AI
numbers. It has been sorted mechanically using the csplit command with
a bit of shell scripting.
gcc/ada/
* doc/gnat_rm/implementation_of_ada_2012_features.rst:
Order list by AI number.
* gnat_rm.texi: Regenerate.
Update the documentation of warning messages that only
emit info messages to clearly reflect that they only emit
info messages and not warning messages.
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Update the documentation of -gnatw.n and -gnatw.l
* gnat_ugn.texi: Regenerate.
Piotr Trojanek [Fri, 22 Mar 2024 22:11:10 +0000 (23:11 +0100)]
ada: Do not leak tagged type names when Discard_Names is enabled
When both pragmas Discard_Names and No_Tagged_Streams apply to a tagged
type, the intended behavior is to prevent type names from leaking into
object code, as documented in GNAT RM.
However, while Discard_Names can be used as a configuration pragma,
No_Tagged_Streams must be applied to each type separately. This patch
enables the use of restriction No_Streams, which can be activated
globally, instead of No_Tagged_Streams on individual types.
When no tagged stream object can be created and allocated, then routines
that make use of the External_Tag won't be used.
gcc/ada/
* doc/gnat_rm/implementation_defined_pragmas.rst
(No_Tagged_Streams): Document how to avoid exposing entity names
for the entire partition.
* exp_disp.adb (Make_DT): Make use of restriction No_Streams.
* exp_put_image.adb (Build_Record_Put_Image_Procedure): Respect
Discard_Names in the generated Put_Image procedure.
* gnat_rm.texi: Regenerate.
Justin Squirek [Mon, 11 Mar 2024 15:15:34 +0000 (15:15 +0000)]
ada: Add new Mingw task priority mapping
This patch adds a new mapping (Non_FIFO_Underlying_Priorities) for dynamically
setting task priorities in Windows when pragma Task_Dispatching_Policy
(FIFO_Within_Priorities) is not present. Additionally, it documents the
requirement to specify the pragma in order to use Set_Priority in the general
case.
gcc/ada/
* doc/gnat_ugn/platform_specific_information.rst: Add note about
different priority level granularities under different policies in
Windows and move POSIX related info into new section.
* libgnarl/s-taprop.ads: Add note about Task_Dispatching_Policy.
* libgnarl/s-taprop__mingw.adb:
(Set_Priority): Add use of Non_FIFO_Underlying_Priorities.
* libgnat/system-mingw.ads: Add documentation for modifying
priority mappings and add alternative mapping
Non_FIFO_Underlying_Priorities.
* gnat_ugn.texi: Regenerate.
liuhongt [Fri, 22 Mar 2024 06:40:00 +0000 (14:40 +0800)]
Use pblendw instead of pand to clear upper 16 bits.
For vec_pack_truncv8si/v4si w/o AVX512,
(const_vector:v4si (const_int 0xffff) x4) is used as mask to clear
upper 16 bits, but vpblendw with zero_vector can also be used, and
zero vector is cheaper than (const_vector:v4si (const_int 0xffff) x4).
gcc/ChangeLog:
PR target/114427
* config/i386/i386-expand.cc (expand_vec_perm_even_odd_pack):
Use pblendw instead of pand to clear upper bits.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr114427.c: New test.
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)]
testsuite, rs6000: Make powerpc_altivec consider current_compiler_flags [PR114842]
As noted in PR114842, most of the test cases which require
effective target check powerpc_altivec_ok actually care
about if ALTIVEC feature is enabled, and they should adopt
effective target powerpc_altivec instead. By considering
we already have a number of test cases having explicit
-maltivec in dg-options etc., to keep them still be tested
as before even without altivec enabled by default, this
patch makes powerpc_altivec consider current_compiler_flags
like what we do for powerpc_vsx.
PR testsuite/114842
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_effective_target_powerpc_altivec):
Take current_compiler_flags into account.
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)]
testsuite, rs6000: Make powerpc_vsx consider current_compiler_flags [PR114842]
As noted in PR114842, most of the test cases which require
effective target check powerpc_vsx_ok actually care about
if VSX feature is enabled, and they should adopt effective
target powerpc_vsx instead. By considering we already have
a number of test cases having explicit -mvsx in dg-options
etc., to keep them still be tested as before even without
vsx enabled by default, this patch is to make powerpc_vsx
consider current_compiler_flags.
PR testsuite/114842
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_effective_target_powerpc_vsx): Take
current_compiler_flags into account.
With the introduction of -mdejagnu-cpu=, when the test case
is specifying -mdejagnu-cpu=405, it would override the other
possibly given -mcpu=, so it would compile for PowerPC 405
for sure. This patch is to remove the effective target
powerpc_405_nocache and update all its uses.
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)]
testsuite, rs6000: Remove powerpc_popcntb_ok
There are three uses of effective target powerpc_popcntb_ok,
they are all for compiling, but powerpc_popcntb_ok checks
for executable generation, which is too heavy. This patch
is to remove powerpc_popcntb_ok and adjust its three uses
accordingly.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_effective_target_powerpc_popcntb_ok):
Remove.
* gcc.target/powerpc/cmpb-2.c: Adjust with dg-skip-if as
powerpc_popcntb_ok gets removed.
* gcc.target/powerpc/cmpb-3.c: Likewise.
* gcc.target/powerpc/cmpb32-2.c: Likewise.
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)]
testsuite, rs6000: Remove all linux*paired* checks and cases
Since r9-115-g559289370f76bf the support of paired single
had been dropped, but we still have some test checks and
cases for that, this patch is to get rid of them.
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)]
testsuite, rs6000: Remove some checks with aix[456]
Since r12-75-g0745b6fa66c69c aix6 support had been dropped,
so we don't need to check for aix[456].* when testing, this
patch is to remove such checks.
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)]
testsuite: Fix typo in torture/vector-{1,2}.c
When making some clean up patches, I happened to find test
cases vector-{1,2}.c are having typo "powerpc64--*-*" in
target selector, which should be powerpc64-*-*. The reason
why we didn't catch before is that all our testing machines
support VMX insns, so it passes always. But it would break
if a test machine doesn't support that, so this patch is to
fix it to ensure robustness.
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)]
rs6000: Remove useless operands[3]
As shown, three uses of operands[3] are totally useless, so
this patch is to remove them to avoid any confusion.
gcc/ChangeLog:
* config/rs6000/rs6000.md (@ieee_128bit_vsx_neg<IEEE128>2): Remove
the use of operands[3].
(@ieee_128bit_vsx_neg<IEEE128>2): Likewise.
(*ieee_128bit_vsx_nabs<mode>2): Likewise.
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)]
rs6000: Remove useless entries in rreg
When I was working on a trial patch to get rid of TFmode,
I noticed that mode attribute rreg only gets used for mode
iterator SFDF, it means that only SF and DF key-value pairs
are useful, the other are useless, so this patch is to clean
up them.
gcc/ChangeLog:
* config/rs6000/rs6000.md (mode attribute rreg): Remove useless
entries with modes TF, TD, V4SF and V2DF.
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)]
rs6000: Drop useless vector_{load,store}_<mode> defines
When I was working on a patch to get rid of TFmode, I
noticed that define_expands vector_load_<mode> and
vector_store_<mode> are useless. This patch is to clean up
both.
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)]
rs6000: Clean up TF and TD check with FLOAT128_2REG_P
Commit r6-2116-g2c83faf86827bf did some clean up on TFmode
and TFmode check with FLOAT128_2REG_P, but it missed to
update an assertion, this patch is to make it align.
btw, it's noticed when I'm making a patch to get rid of
TFmode.
gcc/ChangeLog:
* config/rs6000/rs6000-call.cc (rs6000_darwin64_record_arg_recurse):
Clean up TFmode and TDmode check with FLOAT128_2REG_P.
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)]
rs6000: Add assert !TARGET_VSX if !TARGET_ALTIVEC and strip a useless check
In function rs6000_option_override_internal, we have the
checks and adjustments like:
if (TARGET_P8_VECTOR && !TARGET_ALTIVEC)
rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
if (TARGET_P8_VECTOR && !TARGET_VSX)
rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
But in fact some previous code has guaranteed !TARGET_VSX if
!TARGET_ALTIVEC, so we can remove the former check and
adjustment. This patch is to remove it accordingly and also
place an explicit assertion.
gcc/ChangeLog:
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Remove
useless check on TARGET_P8_VECTOR && !TARGET_ALTIVEC and add an
assertion on !TARGET_VSX if !TARGET_ALTIVEC.
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)]
rs6000: Fix ICE on IEEE128 long double without vsx [PR114402]
As PR114402 shows, we supports IEEE128 format long double
even if there is no vsx support, but there is an ICE about
cbranch as the test case shows. For now, we only supports
compare:CCFP pattern for IEEE128 fp if TARGET_FLOAT128_HW,
so in function rs6000_generate_compare we have a check with
!TARGET_FLOAT128_HW && FLOAT128_VECTOR_P (mode) to make
!TARGET_FLOAT128_HW IEEE128 fp handling go with libcall.
But unfortunately the IEEE128 without vsx support doesn't
meet FLOAT128_VECTOR_P (mode) so it goes further with an
unmatched compare:CCFP pattern which triggers ICE.
So this patch is to make rs6000_generate_compare consider
IEEE128 without vsx as well then it can end up with libcall.
PR target/114402
gcc/ChangeLog:
* config/rs6000/rs6000.cc (rs6000_generate_compare): Make IEEE128
handling without vsx go with libcall.
Gaius Mulley [Tue, 21 May 2024 00:11:48 +0000 (01:11 +0100)]
PR modula2/115164 initial test code highlighting the problem
This patch includes some trivial testcode which highlights
PR 115164. Expect future test code to perform runtime checks
for a series of trailing zeros.
gcc/testsuite/ChangeLog:
PR modula2/115164
* gm2/isolib/run/pass/testlowread.mod: New test.
* gm2/isolib/run/pass/testwritereal.mod: New test.
Andrew Pinski [Sat, 18 May 2024 18:55:58 +0000 (11:55 -0700)]
PHIOPT: Don't transform minmax if middle bb contains a phi [PR115143]
The problem here is even if last_and_only_stmt returns a statement,
the bb might still contain a phi node which defines a ssa name
which is used in that statement so we need to add a check to make sure
that the phi nodes are empty for the middle bbs in both the
`CMP?MINMAX:MINMAX` case and the `CMP?MINMAX:B` cases.
Bootstrapped and tested on x86_64_linux-gnu with no regressions.
PR tree-optimization/115143
gcc/ChangeLog:
* tree-ssa-phiopt.cc (minmax_replacement): Check for empty
phi nodes for middle bbs for the case where middle bb is not empty.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/pr115143-1.c: New test.
* gcc.c-torture/compile/pr115143-2.c: New test.
* gcc.c-torture/compile/pr115143-3.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Mikael Morin [Sun, 12 May 2024 13:16:23 +0000 (15:16 +0200)]
fortran: Assume there is no cyclic reference with submodule symbols [PR99798]
This prevents a premature release of memory with procedure symbols from
submodules, causing random compiler crashes.
The problem is a fragile detection of cyclic references, which can match
with procedures host-associated from a module in submodules, in cases where it
shouldn't. The formal namespace is released, and with it the dummy arguments
symbols of the procedure. But there is no cyclic reference, so the procedure
symbol itself is not released and remains, with pointers to its dummy arguments
now dangling.
The fix adds a condition to avoid the case, and refactors to a new predicate
by the way. Part of the original condition is also removed, for lack of a
reason to keep it.
PR fortran/99798
gcc/fortran/ChangeLog:
* symbol.cc (gfc_release_symbol): Move the condition guarding
the handling cyclic references...
(cyclic_reference_break_needed): ... here as a new predicate.
Remove superfluous parts. Add a condition preventing any premature
release with submodule symbols.
* gcc.target/aarch64/pr113573.c: Replace __builtin_aarch64_get_lowv8hi
with vget_low_s16.
* gcc.target/aarch64/vget_low_2.c: New test.
* gcc.target/aarch64/vget_low_2_be.c: New test.
Bob Duff [Mon, 1 Apr 2024 18:05:14 +0000 (14:05 -0400)]
ada: Allow 'others' in formal packages with overloaded formals
If a generic package has two or more generic formal parameters with the
same defining name (which can happen only for formal subprograms), then
RM-12.7(4.1/3) disallows named associations in a corresponding formal
package. This is not intended to cover "others => <>".
This patch allows "others => <>" even when it applies to such
formals. Previously, the compiler incorrectly gave an error.
Minor related cleanups involving type Text_Ptr.
gcc/ada/
* sem_ch12.adb: Misc cleanups and comment fixes.
(Check_Overloaded_Formal_Subprogram): Remove the Others_Choice
error message.
(Others_Choice): Remove this variable; no longer needed.
* types.ads (Text_Ptr): Add a range constraint limiting the
subtype to values that are actually used. This has the advantage
that when the compiler is compiled with validity checks,
uninitialized values of subtypes Text_Ptr and Source_Ptr will be
caught.
* sinput.ads (Sloc_Adjust): Use the base subtype; this is used as
an offset, so we need to allow arbitrary negative values.
Eric Botcazou [Sat, 30 Mar 2024 22:12:51 +0000 (23:12 +0100)]
ada: Add direct workaround for limitations of RTSfind mechanism
This adds a direct workaround for the spurious compilation errors caused by
the presence of preconditions/postconditions in the Interfaces.C unit, which
trip on limitations of the RTSfind mechanism when it comes to visibility, as
well as removes an indirect workaround that was added very recently.
These errors were first triggered in the context of finalization and worked
around by preloading the System.Finalization_Primitives unit. Now they also
appear in the context of tasking, and it turns out that the preloading trick
does not work for separate compilation units.
gcc/ada/
* exp_ch7.ads (Preload_Finalization_Collection): Delete.
* exp_ch7.adb (Allows_Finalization_Collection): Revert change.
(Preload_Finalization_Collection): Delete.
* opt.ads (Interface_Seen): Likewise.
* scng.adb (Scan): Revert latest change.
* sem_ch10.adb: Remove clause for Exp_Ch7.
(Analyze_Compilation_Unit): Revert latest change.
* libgnat/i-c.ads: Use a fully qualified name for the standard "+"
operator in the preconditons/postconditions of subprograms.
Eric Botcazou [Fri, 29 Mar 2024 16:46:43 +0000 (17:46 +0100)]
ada: Fix internal error on nested aggregate in conditional expression
This plugs a loophole in the change improving code generation for nested
aggregates present in conditional expressions: once the delayed expansion
is chosen for the nested aggregate, the expansion of the parent aggregate
cannot be left to the back-end and the test must be adjusted to implement
this in the presence of conditional expressions too.
gcc/ada/
* exp_aggr.adb (Expand_Record_Aggregate.Component_OK_For_Backend):
Also return False for a delayed conditional expression.
Eric Botcazou [Fri, 29 Mar 2024 12:29:54 +0000 (13:29 +0100)]
ada: Get rid of secondary stack for indefinite record types with size clause
This change eliminates the use of the secondary stack for indefinite record
types for which a valid (object) size clause is specified. In accordance
with the RM, the compiler accepts (object) size clauses on such types only
if all the components, including those of the variants of the variant part
if any, have a size known at compile time, and only if the clauses specify
a value that is at least as large as the largest possible size of objects
of the types when all the variants are considered. However, it would still
have used the secondary stack, despite valid (object) size clauses, before
the change, as soon as a variant part was present in the types.
gcc/ada/
* freeze.ads (Check_Compile_Time_Size): Remove obsolete description
of usage for the Size_Known_At_Compile_Time flag.
* freeze.adb (Check_Compile_Time_Size.Size_Known): In the case where
a variant part is present, do not return False if Esize is known.
* sem_util.adb (Needs_Secondary_Stack.Caller_Known_Size_Record): Add
missing "Start of processing" comment. Return true if either a size
clause or an object size clause has been given for the first subtype
of the type.
Bob Duff [Fri, 29 Mar 2024 16:17:56 +0000 (12:17 -0400)]
ada: Formal package comment corrections in sinfo.ads
Misc comment corrections and clarifications in sinfo.ads
related to generic formal packages.
gcc/ada/
* sinfo.ads: Misc comment corrections and clarifications.
The syntax for GENERIC_ASSOCIATION and FORMAL_PACKAGE_ACTUAL_PART
was wrong.
Emphasize that "others => <>" is not represented as an
N_Generic_Association (with or without Box_Present set),
and give examples illustrating the various possibilities.
Gary Dismukes [Tue, 26 Mar 2024 22:36:02 +0000 (22:36 +0000)]
ada: Error on instantiation of generic containing legal container aggregate
When a container aggregate for a predefined container type (such as
a Vector type) that has an iterated component association occurs within
a generic unit and that generic is instantiated, the compiler reports
a spurious error message "iterated component association can only appear
in an array aggregate" and the compilation aborts (because Unrecoverable_Error
is raised unconditionally after that error). The problem is that as part of
the instantiation process, for aggregates whose type has a partial view,
in Copy_Generic_Node the compiler switches the visibility so that the full
view of the type is available, and for a type whose full view is a record
type this leads to incorrectly trying to process the aggregate as a record
aggregate in Resolve_Aggregate (making a call to Resolve_Record_Aggregate).
Rather than trying to address this by changing what Copy_Generic_Node does,
this can be fixed by reordering and adjusting the code in Resolve_Aggregate,
so that we first test whether we need to resolve as a record aggregate
(if the aggregate is not homogeneous), followed by testing whether the
type has an Aggregate aspect and calling Resolve_Container_Aggregate.
As a bonus, we also remove the subsequent complex condition and redundant
code for handling null container aggregates.
gcc/ada/
* sem_aggr.adb (Resolve_Aggregate): Move condition and call for
Resolve_Record_Aggregate in front of code related to calling
Resolve_Container_Aggregate (and add test that the aggregate is
not homogeneous), and remove special-case testing and call to
Resolve_Container_Aggregate for empty aggregates. Also, add error
check for an attempt to use "[]" for an aggregate of a record type
that does not specify an Aggregate aspect.
(Resolve_Record_Aggregate): Remove error check for record
aggregates with "[]" (now done by Resolve_Aggregate).
Gary Dismukes [Tue, 26 Mar 2024 01:01:57 +0000 (01:01 +0000)]
ada: Error on instantiation of generic containing legal container aggregate
When a container aggregate for a predefined container type (such as
a Vector type) that has an iterated component association occurs within
a generic unit and that generic is instantiated, the compiler reports
a spurious error message "iterated component association can only appear
in an array aggregate" and the compilation aborts (because Unrecoverable_Error
is raised unconditionally after that error). The problem is that as part of
the instantiation process, for aggregates whose type has a partial view,
in Copy_Generic_Node the compiler switches the visibility so that the full
view of the type is available, and for a type whose full view is a record
type this leads to incorrectly trying to process the aggregate as a record
aggregate in Resolve_Aggregate (making a call to Resolve_Record_Aggregate).
Rather than trying to address this by changing what Copy_Generic_Node does,
this can be fixed by reordering and adjusting the code in Resolve_Aggregate,
so that we first test whether we need to resolve as a record aggregate
(if the aggregate is not homogeneous), followed by testing whether the
type has an Aggregate aspect and calling Resolve_Container_Aggregate.
As a bonus, we also remove the subsequent complex condition and redundant
code for handling null container aggregates.
gcc/ada/
* sem_aggr.adb (Resolve_Aggregate): Move condition and call for
Resolve_Record_Aggregate in front of code related to calling
Resolve_Container_Aggregate (and add test that the aggregate
is not homogeneous), and remove special-case testing and call
to Resolve_Container_Aggregate for empty aggregates.
Justin Squirek [Wed, 27 Mar 2024 01:02:41 +0000 (01:02 +0000)]
ada: Handle accessibility calculations for 'First and 'Last
This patch fixes a crash in the compiler whereby calculating the accessibility
level of of a local variable whose original expression is an 'First on an
array type led to an error during compilation.
gcc/ada/
* accessibility.adb (Accessibility_Level): Add cases for 'First
and 'Last.