This is needed after the creation of Returns_On_Secondary_Stack from the
original Requires_Transient_Scope.
gcc/ada/
* sem_util.adb (Indirect_Temp_Needed): Adjust reference in comment.
Having components that need to be returned on the secondary stack would
not always force a record type to be returned on the secondary stack
itself.
gcc/ada/
* sem_util.adb
(Returns_On_Secondary_Stack.Caller_Known_Size_Record): Directly
check the dependence on discriminants for the variant part, if
any, instead of calling the Is_Definite_Subtype predicate.
This makes tagging more accurate.
gcc/ada/
* sem_warn.adb (Check_References): Adjust conditions under which
warning messages should be emitted and their tags as well.
No functional changes.
gcc/ada/
* exp_disp.ads (Expand_Interface_Thunk): Change type of Prim.
* exp_disp.adb (Expand_Interface_Thunk): Declare Is_Predef_Op
earlier, do not initialize Iface_Formal, use No idiom and tweaks
comments.
(Register_Primitive): Declare L earlier and tweak comments.
* sem_disp.adb (Check_Dispatching_Operation): Move tests out of
loop.
In some cases, the compiler would incorrectly fail to generate
discriminant checks when accessing fields declared in a variant part.
Correct some such cases; detect the remaining cases and flag them as
unsupported. The formerly-problematic cases that are now handled
correctly involve component references occurring in a predicate
expression (e.g., the expression of a Dynamic_Predicate aspect
specification) for a type declaration (not for a subtype declaration).
The cases which are now flagged as unsupported involve expression
functions declared before the discriminated type in question has been
frozen.
gcc/ada/
* exp_ch3.ads: Replace visible Build_Discr_Checking_Funcs (which
did not need to be visible - it was not referenced outside this
package) with Build_Or_Copy_Discr_Checking_Funcs.
* exp_ch3.adb: Refactor existing code into 3 procedures -
Build_Discr_Checking_Funcs, Copy_Discr_Checking_Funcs, and
Build_Or_Copy_Discr_Checking_Funcs. This refactoring is intended
to be semantics-preserving.
* exp_ch4.adb (Expand_N_Selected_Component): Detect case where a
call should be generated to the Discriminant_Checking_Func for
the component in question, but that subprogram does not yet
exist.
* sem_ch13.adb (Freeze_Entity_Checks): Immediately before
calling Build_Predicate_Function, add a call to
Exp_Ch3.Build_Or_Copy_Discr_Checking_Funcs in order to ensure
that Discriminant_Checking_Func attributes are already set when
Build_Predicate_Function is called.
* sem_ch6.adb (Analyze_Expression_Function): If the expression
of a static expression function has been transformed into an
N_Raise_xxx_Error node, then we need to copy the original
expression in order to check the requirement that the expression
must be a potentially static expression. We also want to set
aside a copy the untransformed expression for later use in
checking calls to the expression function via
Inline_Static_Function_Call. So introduce a new function,
Make_Expr_Copy, for use in these situations.
* sem_res.adb (Preanalyze_And_Resolve): When analyzing certain
expressions (e.g., a default parameter expression in a
subprogram declaration) we want to suppress checks. However, we
do not want to suppress checks for the expression of an
expression function.
This patch makes the search for Get_Element_Access, Step (Next/Prev),
Reference_Control_Type, and Pseudo_Reference (for optimized "for ... of"
loops) more robust. In particular, we have a new Next procedure in Ada
2022, and we need to pick the right one.
We have not yet added the new Next and other subprograms.
gcc/ada/
* exp_ch5.adb (Expand_Iterator_Loop_Over_Container): For each
subprogram found, assert that the variable is Empty, so we can
detect bugs where we find two or more things with the same name.
Without this patch, that bug would happen when we add the new
Next procedure. For Step, make sure we pick the right one, by
checking name and number of parameters. For Get_Element_Access,
check that we're picking a function. That's not really
necessary, because there is no procedure with that name, but it
seems cleaner this way.
* rtsfind.ads: Minor comment improvement. It seems kind of odd
to say "under no circumstances", and then immediately contradict
that with "The one exception is...".
This patch adds reference counting to dynamically allocated pointers
on arrays and elements used by the functional container. This is done
by making both the arrays and the elements controlled.
gcc/ada/
* libgnat/a-cofuba.ads, libgnat/a-cofuba.adb: Add reference
counting.
Augment the warnings issued with switch -gnatwh, so that a warning is
also issued when an entity from the package of a use_clause ends up
hidden due to an existing visible homonym.
gcc/ada/
* sem_ch8.adb (Use_One_Package): Possibly warn.
* sem_util.adb (Enter_Name): Factor out warning on hidden entity.
(Warn_On_Hiding_Entity): Extract warning logic from Enter_Name and
generalize it to be applied also on use_clause.
* sem_util.ads (Warn_On_Hiding_Entity): Add new procedure.
Various cases of out-of-order keywords in the definition of a record
were already detected. This adds a similar detection after NULL and
RECORD keywords.
gcc/ada/
* par-ch3.adb (P_Known_Discriminant_Part_Opt): Reword error
message to benefit from existing codefix.
(P_Record_Definition): Detect out-of-order keywords in record
definition and issue appropriate messages. Other cases are
already caught at appropriate places.
This case was missed in the previous change.
gcc/ada/
* exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Put
the actions into the Actions field of the freeze node instead of
inserting them after it.
Both flags were added when square brackets for array/container
aggregates have been enabled with -gnat2022 without their corresponding
inline documentation. This change adds the missing documention.
gcc/ada/
* sinfo.ads: Add inline documention for Is_Parenthesis_Aggregate
and Is_Enum_Array_Aggregate.
This patch fixes a bug where the compiler generates incorrect code for a
call via an object with convention C, whose type is an anonymous
access-to-function type.
gcc/ada/
* einfo-utils.adb (Set_Convention): Call Set_Convention
recursively, so that Set_Can_Use_Internal_Rep is called (if
appropriate) on the anonymous access type of the object, and its
designated subprogram type.
* sem_ch3.adb (Access_Definition): Remove redundant call to
Set_Can_Use_Internal_Rep.
For a membership test "X in A .. B", the compiler used to warn if it
could prove that X is within one of the bounds. For example, if we know
at compile time that X >= A, then the above could be replaced by "X <=
B".
This patch suppresses that warning, because there is really
nothing wrong with the membership test, and programmers sometimes
find it annoying.
gcc/ada/
* exp_ch4.adb (Expand_N_In): Do not warn in the above-mentioned
cases.
* fe.h (Assume_No_Invalid_Values): Remove from fe.h, because
this is not used in gigi.
* opt.ads (Assume_No_Invalid_Values): Improve the comment. We
don't need to "clearly prove"; we can just "prove". Remove the
comment about fe.h, which is no longer true.
In unswitching we use ranger to simplify switch statements so we
have to avoid doing anything for abnormals.
2022-05-30 Richard Biener <rguenther@suse.de>
PR tree-optimization/105763
* tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb):
Check gimple_range_ssa_p.
* gcc.dg/pr105763.c: New testcase.
Here the out-of-line definition of Z<T>::z causes duplicate_decls to
change z's type from using the primary template type Z<T> (which is also
the type of the injected class name) to the implicit instantiation Z<T>,
and this latter type lacks a TYPE_BINFO (although its TYPE_CANONICAL was
set by a special case in lookup_template_class to point to the former).
Later, when processing the non-dependent call z->foo(0), build_over_call
relies on the object argument's TYPE_BINFO to build the templated form
for this call, which fails because the object argument type has empty
TYPE_BINFO due to the above.
It seems weird that the implicit instantiation Z<T> doesn't have the
same TYPE_BINFO as the primary template type Z<T>, despite them being
proclaimed equivalent via TYPE_CANONICAL. So I tried also setting
TYPE_BINFO in the special case in lookup_template_class, but that led to
some problems with constrained partial specializations of the form Z<T>.
I'm not sure what, if anything, we ought to do about the subtle
differences between these two versions of the same type.
Fortunately it seems we don't need to rely on TYPE_BINFO at all in
build_over_call here -- the z_candidate struct already contains the
exact binfos we need to rebuild the BASELINK for the templated form.
PR c++/105758
gcc/cp/ChangeLog:
* call.cc (build_over_call): Use z_candidate::conversion_path
and ::access_path instead of TYPE_BINFO when building the
BASELINK for the templated form.
gcc/testsuite/ChangeLog:
* g++.dg/template/non-dependent24.C: New test.
r12-5487-g9bf69a8558638c replaced uses of timevar_cond_push/pop with
auto_cond_timevar and removed now unnecessary wrapper functions. This
patch does the same with timevar_push/pop and auto_timevar.
gcc/cp/ChangeLog:
* parser.cc: Use auto_timevar instead of timevar_push/pop.
Remove wrapper functions.
* pt.cc: Likewise.
This combines the two differently named versions of the same function
into a single function utilizing a default argument.
gcc/cp/ChangeLog:
* cp-tree.h (cp_build_qualified_type_real): Rename to ...
(cp_build_qualified_type): ... this. Give its last parameter
a default argument. Remove macro of the same name.
* decl.cc (grokdeclarator): Adjust accordingly.
* pt.cc (tsubst_aggr_type): Likewise.
(rebuild_function_or_method_type): Likewise.
(tsubst): Likewise.
(maybe_dependent_member_ref): Likewise.
(unify): Likewise.
* tree.cc (cp_build_qualified_type_real): Rename to ...
(cp_build_qualified_type): ... this. Adjust accordingly.
A few globs missed in the .c -> .cc transition. Some targets were looking
at both *.c and *.cc, but there are no longer any .c files to scan.
gcc/ChangeLog:
* Makefile.in (TAGS): Look at libcpp/*.cc.
gcc/c/ChangeLog:
* Make-lang.in (c.tags): Look at *.cc.
gcc/cp/ChangeLog:
* Make-lang.in (c++.tags): Just look at *.cc.
gcc/d/ChangeLog:
* Make-lang.in (d.tags): Just look at *.cc.
gcc/fortran/ChangeLog:
* Make-lang.in (fortran.tags): Look at *.cc.
gcc/go/ChangeLog:
* Make-lang.in (go.tags): Look at *.cc.
gcc/objc/ChangeLog:
* Make-lang.in (objc.tags): Look at *.cc.
gcc/objcp/ChangeLog:
* Make-lang.in (obj-c++.tags): Look at *.cc.
As of gdc-12, the lexer expects there 4 bytes of zero padding at the end
of the source buffer to mark the end of input. Sometimes when reading
from stdin, the data at the end of input is garbage rather than zeroes.
Fix that by explicitly calling memset past the end of the buffer.
PR d/105544
gcc/d/ChangeLog:
* d-lang.cc (d_parse_file): Zero padding past the end of the stdin
buffer so the D lexer has a sentinel to stop parsing at.
My r13-680-g0dc8e1e7026d9b commit to add support for Decimal Floating
Point introduced:
case SDmode:
case DDmode:
case TDmode:
which are rejected by gcc-4.8 as build compiler.
This patch replaces them with E_SDmode, E_DDmode and E_TD_mode.
Committed as obvious.
* config/aarch64/aarch64.cc (aarch64_gimplify_va_arg_expr):
Prefix mode names with E_.
In passing, use bool for its return type.
gcc/cp/ChangeLog:
* cp-tree.h (comp_template_args): Change return type to bool.
* pt.cc (comp_template_args): Document default arguments.
Change return type to bool and adjust returns accordingly.
OpenMP 5.2 adds support for firstprivate and allocate clauses on the scope
construct and this patch adds that support to GCC.
5.2 unfortunately (IMNSHO mistakenly) marked scope construct as worksharing,
which implies that it isn't possible to nest inside of it other scope,
worksharing loop, sections, explicit barriers, single etc. which would
make scope far less useful. I'm not implementing that part, keeping the
5.1 behavior here, and will file an issue to revert that for OpenMP 6.0.
But, for firstprivate it keeps the restriction that is now implied from
worksharing construct that listed var can't be private in outer context,
where for reduction 5.1 had similar restriction explicit even for scope
and 5.2 has it implicitly through worksharing construct.
2022-05-31 Jakub Jelinek <jakub@redhat.com>
gcc/
* omp-low.cc (build_outer_var_ref): For code == OMP_CLAUSE_ALLOCATE
allow var to be private in the outer context.
(lower_private_allocate): Pass OMP_CLAUSE_ALLOCATE as last argument
to build_outer_var_ref.
gcc/c/
* c-parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
clauses.
gcc/cp/
* parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
clauses.
gcc/testsuite/
* c-c++-common/gomp/scope-5.c: New test.
* c-c++-common/gomp/scope-6.c: New test.
* g++.dg/gomp/attrs-1.C (bar): Add firstprivate and allocate clauses
to scope construct.
* g++.dg/gomp/attrs-2.C (bar): Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-1.c (foo): Add testcase for
scope construct with allocate clause.
* testsuite/libgomp.c-c++-common/allocate-3.c (foo): Likewise.
* testsuite/libgomp.c-c++-common/scope-2.c: New test.
As discussed here:
<https://gcc.gnu.org/pipermail/gcc-patches/2021-February/564629.html>,
type_dependent_expression_p should not be called with a type argument.
I promised I'd add an assert so here it is. One place needed adjusting.
PR c++/99080
gcc/cp/ChangeLog:
* pt.cc (type_dependent_expression_p): Assert !TYPE_P.
* semantics.cc (finish_id_expression_1): Handle UNBOUND_CLASS_TEMPLATE
specifically.
This patch is a form of insurance policy in case my patch for PR 7061 runs
into problems on non-x86 targets; the middle-end can add an extra check
that the backend is happy placing SCmode and DImode values in the same
register, before creating a SUBREG. Unfortunately, ix86_modes_tieable_p
currently claims this is not allowed(?), even though the default target
hook for modes_tieable_p is to always return true [i.e. false can be
used to specifically prohibit bad combinations], and the x86_64 ABI
passes SCmode values in DImode registers!. This makes the backend's
modes_tiable_p hook a little more forgiving, and additionally enables
interconversion between SCmode and V2SFmode, and between DCmode and
VD2Fmode, which opens interesting opporutunities in the future.
2022-05-30 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/i386.cc (ix86_modes_tieable_p): Allow SCmode to be
tieable with DImode on TARGET_64BIT, and SCmode tieable with
V2SFmode, and DCmode with V2DFmode.
ALLOCATE: generate different STAT,ERRMSG results for failures from
allocation of already allocated objects or insufficient virtual memory.
gcc/fortran/ChangeLog:
PR fortran/91300
* libgfortran.h: Define new error code LIBERROR_NO_MEMORY.
* trans-stmt.cc (gfc_trans_allocate): Generate code for setting
ERRMSG depending on result of STAT result of ALLOCATE.
* trans.cc (gfc_allocate_using_malloc): Use STAT value of
LIBERROR_NO_MEMORY in case of failed malloc.
gcc/testsuite/ChangeLog:
PR fortran/91300
* gfortran.dg/allocate_alloc_opt_15.f90: New test.
This patch resolves PR rtl-optimization/101617 where we should generate
the exact same code for (X ? -1 : 1) as we do for ((X ? -1 : 0) | 1).
The cause of the current difference on x86_64 is actually in
ix86_expand_int_movcc that doesn't know that negl;sbbl can be used
to create a -1/0 result depending on whether the input is zero/nonzero.
So for Andrew Pinski's test case:
int f1(int i)
{
return i ? -1 : 1;
}
GCC currently generates:
f1: cmpl $1, %edi
sbbl %eax, %eax // x ? 0 : -1
andl $2, %eax // x ? 0 : 2
subl $1, %eax // x ? -1 : 1
ret
but with the attached patch, now generates:
f1: negl %edi
sbbl %eax, %eax // x ? -1 : 0
orl $1, %eax // x ? -1 : 1
ret
To implement this I needed to add two expanders to i386.md to generate
the required instructions (in both SImode and DImode) matching the
pre-existing define_insns of the same name.
2022-05-30 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR rtl-optimization/101617
* config/i386/i386-expand.cc (ix86_expand_int_movcc): Add a
special case (indicated by negate_cc_compare_p) to generate a
-1/0 mask using neg;sbb.
* config/i386/i386.md (x86_neg<mode>_ccc): New define_expand
to generate an *x86_neg<mode>_ccc instruction.
(x86_mov<mode>cc_0_m1_neg): Likewise, a new define_expand to
generate a *x86_mov<mode>cc_0_m1_neg instruction.
gcc/testsuite/ChangeLog
PR rtl-optimization/101617
* gcc.target/i386/pr101617.c: New test case.
GCC's middle-end provides a default cost model for RTL expressions, for
backends that don't specify their own instruction timings, that can be
summarized as multiplications are COSTS_N_INSNS(4), divisions are
COSTS_N_INSNS(7) and all other operations are COSTS_N_INSNS(1).
This patch tweaks the above definition so that fused-multiply-add
(FMA) and high-part multiplications cost the same as regular multiplications,
or more importantly aren't (by default) considered less expensive. Likewise
the saturating forms of multiplication and division cost the same as the
regular variants. These values can always be changed by the target, but
the goal is to avoid RTL expansion substituting a suitable operation with
its saturating equivalent because it (accidentally) looks much cheaper.
For example, PR 89845 is about implementing division/modulus via highpart
multiply, which may accidentally look extremely cheap.
2022-05-30 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* rtlanal.cc (rtx_cost) <MULT>: Treat FMA, SS_MULT, US_MULT,
SMUL_HIGHPART and UMUL_HIGHPART as having the same cost as MULT.
<DIV>: Likewise, SS_DIV and US_DIV have the same default as DIV.
This patch resolves the last piece of PR target/70321 a code quality
(P2 regression) affecting mainline. Currently, for HJ's testcase:
void foo (long long ixi)
{
if (ixi != 14348907)
__builtin_abort ();
}
GCC with -m32 -O2 generates four instructions for the comparison:
movl 16(%esp), %eax
movl 20(%esp), %edx
xorl $14348907, %eax
orl %eax, %edx
but with this patch it now requires only three, making better use of
x86's addressing modes:
movl 16(%esp), %eax
xorl $14348907, %eax
orl 20(%esp), %eax
The solution is to expand "doubleword" equality/inequality expressions
using flag setting COMPARE instructions for the early RTL passes, and
then split them during split1, after STV and before reload.
Hence on x86_64, we now see/allow things like:
(insn 11 8 12 2 (set (reg:CCZ 17 flags)
(compare:CCZ (reg/v:TI 84 [ x ])
(reg:TI 96))) "cmpti.c":2:43 30 {*cmpti_doubleword}
This allows the STV pass to decide whether it's preferrable to perform
this comparison using vector operations, i.e. a pxor/ptest sequence,
or as scalar integer operations, i.e. a xor/xor/or sequence. Alas
this required tweaking of the STV pass to recognize the "new" form of
these comparisons and split out the pxor operation itself. To confirm
this still works as expected I've added a new STV test case:
long long a[1024];
long long b[1024];
int foo()
{
for (int i=0; i<1024; i++)
{
long long t = (a[i]<<8) | (b[i]<<24);
if (t == 0)
return 1;
}
return 0;
}
where with -m32 -O2 -msse4.1 the above comparison with zero should look
like:
punpcklqdq %xmm0, %xmm0
ptest %xmm0, %xmm0
Although this patch includes one or two minor tweaks to provide all the
necessary infrastructure to support conversion of TImode comparisons to
V1TImode (and SImode comparisons to V4SImode), STV doesn't yet implement
these transformations, but this is something that can be considered after
stage 4. Indeed the new convert_compare functionality is split out
into a method to simplify its potential reuse by the timode_scalar_chain
class.
2022-05-30 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/70321
* config/i386/i386-expand.cc (ix86_expand_branch): Don't decompose
DI mode equality/inequality using XOR here. Instead generate a
COMPARE for doubleword modes (DImode on !TARGET_64BIT or TImode).
* config/i386/i386-features.cc (gen_gpr_to_xmm_move_src): Use
gen_rtx_SUBREG when NUNITS is 1, i.e. for TImode to V1TImode.
(general_scalar_chain::convert_compare): New function to convert
scalar equality/inequality comparison into vector operations.
(general_scalar_chain::convert_insn) [COMPARE]: Refactor. Call
new convert_compare helper method.
(convertible_comparion_p): Update to match doubleword COMPARE
of two register, memory or integer constant operands.
* config/i386/i386-features.h (general_scalar_chain::convert_compare):
Prototype/declare member function here.
* config/i386/i386.md (cstore<mode>4): Change mode to SDWIM, but
only allow new doubleword modes for EQ and NE operators.
(*cmp<dwi>_doubleword): New define_insn_and_split, to split a
doubleword comparison into a pair of XORs followed by an IOR to
set the (zero) flags register, optimizing the XORs if possible.
* config/i386/sse.md (V_AVX): Include V1TI and V2TI in mode
iterator; V_AVX is (currently) only used by ptest.
(sse4_1 mode attribute): Update to support V1TI and V2TI.
gcc/testsuite/ChangeLog
PR target/70321
* gcc.target/i386/pr70321.c: New test case.
* gcc.target/i386/sse4_1-stv-1.c: New test case.
const_int_operand and other const*_operand predicates do not need
constraints when the constraint is inherited from the range of
constant integer predicate. Remove the constraint in case all
alternatives use the same inherited constraint.
However, when there are operands, commitative with a non-constant
operand, the operand effectively matches e.g.
nonimmediate_operand|const_int_operand rather than just
const_int_operand. We should keep the constraint for
const_int_operand that are in a % pair. See PR 105624.
2022-05-30 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
* config/i386/i386.md: Remove constraints when used with
const_int_operand, const0_operand, const_1_operand, constm1_operand,
const8_operand, const128_operand, const248_operand, const123_operand,
const2367_operand, const1248_operand, const359_operand,
const_4_or_8_to_11_operand, const48_operand, const_0_to_1_operand,
const_0_to_3_operand, const_0_to_4_operand, const_0_to_5_operand,
const_0_to_7_operand, const_0_to_15_operand, const_0_to_31_operand,
const_0_to_63_operand, const_0_to_127_operand, const_0_to_255_operand,
const_0_to_255_mul_8_operand, const_1_to_31_operand,
const_1_to_63_operand, const_2_to_3_operand, const_4_to_5_operand,
const_4_to_7_operand, const_6_to_7_operand, const_8_to_9_operand,
const_8_to_11_operand, const_8_to_15_operand, const_10_to_11_operand,
const_12_to_13_operand, const_12_to_15_operand, const_14_to_15_operand,
const_16_to_19_operand, const_16_to_31_operand, const_20_to_23_operand,
const_24_to_27_operand and const_28_to_31_operand.
* config/i386/mmx.md: Ditto.
* config/i386/sse.md: Ditto.
* config/i386/subst.md: Ditto.
* config/i386/sync.md: Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr105624.c: New test.
It's pretty clear that the operand numbers in the MEM_P() checks are
off by one, perhaps due to a copy-and-paste oversight (unlike in most
other places here we're dealing with two outputs).
gcc/
* config/i386/i386.md (bmi2_umul<mode><dwi>3_1): Correct MEM_P()
arguments.
Without this patch, gnat would use `-gnatw?` as the default option for
some of the default warnings.
gcc/ada/
* erroutc.adb (Get_Warning_Option): Don't consider `?` as a
valid option switch.
This enables better integration with tools that handle GNAT's output.
gcc/ada/
* erroutc.ads (Get_Warning_Option): New function returning the
option responsible for a warning if it exists.
* erroutc.adb (Get_Warning_Option): Likewise.
(Get_Warning_Tag): Rely on Get_Warning_Option when possible.
* errout.adb (Output_JSON_Message): Emit option field.
When implementing structural subprogram variants we ignored them in
expansion of the pragma itself, but not in expansion of a recursive
subprogram call. Now fixed.
gcc/ada/
* exp_ch6.adb (Check_Subprogram_Variant): Ignore structural
variants.
Code cleanup; semantics is unaffected.
gcc/ada/
* osint.adb (Locate_File): Change variable to constant and
initialize it by concatenation of directory, file name and NUL.
The GNAT behaviour regarding the Ada RM requirement to support Address
clauses for imported subprograms was documented twice: in section about
packed types (which was a mistake) and in section about address clauses
(where it belongs).
Cleanup related to the use of packed arrays for bitset operations to
detect uses of uninitialized scalars in GNAT.
gcc/ada/
* doc/gnat_rm/implementation_advice.rst (Packed Types): Remove
duplicated and wrongly placed paragraph.
* gnat_rm.texi: Regenerate.
This enables tools that ingest GNAT's output to properly classify these
messages.
gcc/ada/
* inline.adb (Check_Package_Body_For_Inlining): Add insertion
character.
This caused these warnings not to be tagged with the switch causing
them, which is an issue for tools ingesting GNAT's output.
gcc/ada/
* sem_elab.adb (Process_Conditional_ABE_Access_Taken): Add '.f'
insertion characters.
While cleaning up and modifying code for unreferenced warnings we
removed all calls to Defer_Reference, which was the only routine that
populated the Deferred_References table. Consequently, all the code
related to this table became dead.
gcc/ada/
* lib-xref.ads (Deferred_Reference_Entry, Defer_Reference,
Process_Deferred_References, Has_Deferred_Reference): Remove
client API.
* lib-xref.adb (Deferred_References, Defer_Reference,
Has_Deferred_Reference, Process_Deferred_References): Remove
implementation.
* frontend.adb, sem_ch11.adb, sem_ch5.adb, sem_res.adb,
sem_util.adb, sem_warn.adb: Remove uses of Deferred_References.
This patch fixes a bug whereby if a function body has local objects that
are finalizable, and has a return statement that requires generation of
transient finalizable temps, and there are dynamic-sized objects
requiring pushing/popping the (primary) stack at run time, and the
function body has exception handlers, then incorrect code is
generated. In particular, the transient objects are finalized after they
have been deallocated. This can cause seg faults, corrupted heap, and
the like.
Note that if there are no dynamic-sized objects, then the bug does
not occur, because the back end allocates objects of compile-time-known
size based on where they are referenced, rather than which local
block they are declared in.
This patch relies on the fact that an At_End handler and regular
exception handlers CAN coexist in the same handled statement sequence,
which was not true some years ago.
gcc/ada/
* exp_ch7.adb (Wrap_HSS_In_Block): Do not create a new block in
the case of function bodies. We include all subprogram bodies,
because it's harmless for procedures. We cannot easily avoid
creating this block in ALL cases, because some transformations
of (e.g.) task bodies end up moving some code such that the
wrong exception handlers apply to that code.
(Build_Finalizer_Call): Remove code for creating a new block.
This was unreachable code, given that Wrap_HSS_In_Block has
already done that, but with the above change to
Wrap_HSS_In_Block, this code becomes reachable, and triggers
essentially the same bug.
* exp_ch7.ads: Adjust comment.