Jakub Jelinek [Tue, 31 May 2022 09:41:52 +0000 (11:41 +0200)]
openmp: Add support for firstprivate and allocate clauses on scope construct
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.
Marek Polacek [Sat, 14 May 2022 00:09:53 +0000 (20:09 -0400)]
c++: Add !TYPE_P assert to type_dependent_expression_p [PR99080]
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.
Roger Sayle [Mon, 30 May 2022 20:32:58 +0000 (21:32 +0100)]
Allow SCmode and DImode to be tieable with TARGET_64BIT on x86_64.
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.
Harald Anlauf [Sat, 28 May 2022 20:02:20 +0000 (22:02 +0200)]
Fortran: improve runtime error message with ALLOCATE and ERRMSG= [PR91300]
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.
Roger Sayle [Mon, 30 May 2022 20:26:37 +0000 (21:26 +0100)]
PR rtl-optimization/101617: Use neg/sbb in ix86_expand_int_movcc.
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.
Roger Sayle [Mon, 30 May 2022 20:23:15 +0000 (21:23 +0100)]
Make the default rtx_costs of MULT/DIV variants consistent.
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.
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:
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.
Uros Bizjak [Mon, 30 May 2022 19:38:16 +0000 (21:38 +0200)]
i386: Remove constraints when used with constant integer predicates, take 2
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.
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).
[Ada] Add "option" field to GNAT's -fdiagnostics-format=json output
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.
Piotr Trojanek [Wed, 27 Apr 2022 15:30:59 +0000 (17:30 +0200)]
[Ada] Fix expansion of structural subprogram variants
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.
Piotr Trojanek [Fri, 8 Apr 2022 21:27:24 +0000 (23:27 +0200)]
[Ada] Remove repeated description of support for Address clauses
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.
Piotr Trojanek [Tue, 26 Apr 2022 13:21:00 +0000 (15:21 +0200)]
[Ada] Deconstruct deferred references
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.
Bob Duff [Tue, 26 Apr 2022 11:16:20 +0000 (07:16 -0400)]
[Ada] Avoid creating a finalization wrapper block for functions
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.
[Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects
This patch corrects an error in the compiler whereby spurious
unreferenced warnings are generated on formal parameters of null generic
subprograms.
These changes also fix the parsing of aspects on formal parameters such
that the aspects now get properly set for all formal parameters in a
parameter list.
gcc/ada/
* par-ch6.adb (P_Formal_Part): Set Aspect_Specifications on all
formals instead of just the last in a formal id list.
* sem_ch6.adb (Analyze_Null_Procedure): Mark expanded null
generic procedures as trivial in order to avoid spurious
unreferenced warnings.
Both the `System.Mmap` and `System.Object_Reader` packages are defining
entities named `Offset` and they are both `use`d at the top of
s-dwalin.adb.
Therefore, the references to `Offset` throughout this file are
ambiguous, and GNAT is supposed to complain. Since it does not for the
moment, we fix the ambiguity by declaring a subtype `Offset` at the top
of the file simply renames `System.Object_Reader.Offset`.
gcc/ada/
* libgnat/s-dwalin.adb: Add a subtype declaration to fix the
ambiguity.
Steve Baird [Wed, 20 Apr 2022 21:48:11 +0000 (14:48 -0700)]
[Ada] Incorrect determination of whether an expression is predicate-static
The expression given in a Static_Predicate aspect specification is
required to be predicate-static. The implementation of this compile-time
check was incorrect in some cases. There were problems in both
directions: expressions that are not predicate-static were incorrectly
treated as though they were and vice versa. This led to both accepting
invalid code and to rejecting valid code.
gcc/ada/
* sem_ch13.adb (Is_Predicate_Static): Do not generate warnings
about subexpressions of enclosing expressions. Generate warnings
for predicates that are known to be always true or always false,
except in the case where the predicate is expressed as a Boolean
literal. Deal with non-predicate-static expressions that have
been transformed into predicate-static expressions. Add missing
Is_Type_Ref call to N_Membership_Test case.
Eric Botcazou [Sat, 23 Apr 2022 10:28:28 +0000 (12:28 +0200)]
[Ada] Fix expansion of aggregate for discriminated limited extension
The presence of the discriminants prevents the values associated with the
components of the parent type from being put into the sub-aggregate built
for the _Parent component.
gcc/ada/
* exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End_Aggregate):
Skip the discriminants at the start of the component list before
looking for the components inherited from the parent in the case
of a tagged extension.
Eric Botcazou [Fri, 22 Apr 2022 20:27:22 +0000 (22:27 +0200)]
[Ada] Do not analyze expression functions for dispatch tables
There is no need to analyze expression functions that are primitives of a
tagged type for its dispatch table because they will be analyzed at the end
of the current scope.
gcc/ada/
* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Don't analyze
the body of an expression function in the case of a dispatch table.
[Ada] Update proofs of double arithmetic unit after prover changes
Changes in GNATprove (translation to Why3 and provers) result in proofs
being much less automatic, and requiring ghost code to detail
intermediate steps. In some cases, it is better to use the new By
mechanism to prove assertions in steps, as this avoids polluting the
proof context for other proofs. For that reason, add units s-spark.ads
and s-spcuop.ads/b to the runtime sources.
gcc/ada/
* Makefile.rtl: Add new units.
* libgnat/s-aridou.adb (Scaled_Divide): Add ghost code for provers.
* libgnat/s-spcuop.adb: New unit for ghost cut operations.
* libgnat/s-spcuop.ads: New unit for ghost cut operations.
* libgnat/s-spark.ads: New unit.
Mention when security hardening features are available in other
languages.
Expand the strub documentation a little, for clarity and completeness.
Add missing 'aliased' and attribute to variables in strub example.
gcc/ada/
* doc/gnat_rm/security_hardening_features.rst: Mention
availability in other languages when applicable.
(Stack Scrubbing): Associate the attribute with types, expand
some comments, fix the example involving access to variables.
* gnat_rm.texi: Regenerate.
Eric Botcazou [Wed, 20 Apr 2022 22:03:59 +0000 (00:03 +0200)]
[Ada] Restore hiding of predefined "=" operator through class-wide type
The previous change introduced a backward incompatibility in the handling
of a user-defined "=" operator for a class-wide type of a tagged type: it
would previously hide the predefined "=" operator of the tagged type in
the private case, but it no longer does in this case, while it still does
in the nonprivate case.
This hiding is a non-portability, but is fundamentally what the compiler
implements, instead of the RM rule which requires homographs. The reason
lies in the implementation of the "=" operator in GNAT: internally, there
is not a "=" predefined operator for every nonlimited type, but instead
there is a single, universal "=" predefined operator for all the nonlimited
types. The consequence is that the hiding rule implemented in GNAT for "="
is effectively that a user-declared symmetrical "=" operator returning
boolean hides the predefined "=" operator of any type that is covered by
the user-declared operator.
Whether it is desirable to implement the exact RM rule in GNAT is to be
discussed, but existing code relies on the non-portability and would thus
need to be changed.
gcc/ada/
* sem_ch6.adb (New_Overloaded_Entity): Deal specifically with the
overriding of the "=" operator for tagged types.
Eric Botcazou [Wed, 20 Apr 2022 07:54:49 +0000 (09:54 +0200)]
[Ada] Do not freeze profiles for dispatch tables
When static dispatch tables are built for library-level tagged types, the
primitives (the subprogram themselves) are frozen; that's necessary because
their address is taken. However, their profile, i.e. all the types present
therein, is also frozen, which is not necessary after AI05-019 and is also
inconsistent with the handling of attribute references.
The change also removes a couple of pragma Inline on subprograms that are
too large for inlining to bring any benefit.
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Adjust call to Make_DT.
* exp_disp.ads (Building_Static_DT): Remove pragma Inline.
(Building_Static_Secondary_DT): Likewise.
(Convert_Tag_To_Interface): Likewise.
(Make_DT): Remove second parameter.
* exp_disp.adb (Make_DT): Likewise.
(Check_Premature_Freezing): Delete.
Pass Do_Freeze_Profile as False in call to Freeze_Entity.
* freeze.ads (Freezing_Library_Level_Tagged_Type): Delete.
* freeze.adb (Freeze_Profile): Remove obsolete code.
(Freeze_Entity): Tweak comment.
[Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit
The internal unit System.Generic_Array_Operations defines only generic
subprograms. Thus, pragma Assertion_Policy inside the spec has no
effect, as each instantiation is only subject to the assertion policy at
the program point of the instantiation. Remove this confusing pragma,
and add the pragma inside each generic body making use of additional
assertions or ghost code, so that running time of instantiations is not
impacted by assertions meant for formal verification.
gcc/ada/
PR ada/105303
* libgnat/s-gearop.adb: Add pragma Assertion_Policy in generic
bodies making use of additional assertions or ghost code.
* libgnat/s-gearop.ads: Remove confusing Assertion_Policy.
Removal of the previous kernel registration scheme unearthed mistakes in
the new one, which were:
- The new kernel registration code relied on the binder expansion phase,
which didn't happen because the registration code was already
generated by the binder.
- The kernel handle passed to CUDA_Register_Function was the first eight
bytes of the code of the host-side procedure representing the kernel
rather than its address.
gcc/ada/
* bindgen.adb (Gen_CUDA_Init): Remove code generating CUDA
definitions.
(Gen_CUDA_Defs): New function, generating definitions
initialized by Gen_CUDA_Init.
(Gen_Output_File_Ada): Call Gen_CUDA_Defs instead of
Gen_CUDA_Init.
(Gen_Adainit): Call Gen_CUDA_Init.
Vineet Gupta [Fri, 27 May 2022 02:36:36 +0000 (19:36 -0700)]
RISC-V/testsuite: constraint some of tests to hard_float
Commit 9ddd44b58649d1d ("RISC-V: Provide `fmin'/`fmax' RTL pattern") added
tests which check for hard float instructions which obviously fails on
soft-float ABI builds.
And my recent commit b646d7d279ae ("RISC-V: Inhibit FP <--> int register
moves via tune param") is guilty of same crime.
So constraint with "dg-require-effective-target hard_float"
This reduces bunch of new RV failures.
| ========= Summary of gcc testsuite =========
| | # of unexpected case / # of unique unexpected case
| | gcc | g++ | gfortran |
| rv64imac/ lp64/ medlow | 134 / 22 | 0 / 0 | - | BEFORE
| rv64imac/ lp64/ medlow | 22 / 9 | 0 / 0 | - | AFTER
|
Jakub Jelinek [Sun, 29 May 2022 19:57:51 +0000 (21:57 +0200)]
libcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]
The first part of the following testcase (m1-m3 macros and its use)
regressed with my PR89971 fix, but as the m1,m4-m5 and its use part shows,
the problem isn't new, we can emit a CPP_PADDING token to avoid it from
being adjacent to whatever comes after the __VA_OPT__ (in this case there
is nothing afterwards, true).
In most cases these CPP_PADDING tokens don't matter, all other
callers of cpp_get_token_with_location either ignore CPP_PADDING tokens
completely (e.g. c_lex_with_flags) or they just remember them and
take them into account when printing stuff whether there should be
added whitespace or not (scan_translation_unit + token_streamer::stream).
So, I think we should just ignore CPP_PADDING tokens the same way in
_cpp_parse_expr.
2022-05-27 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/105732
* expr.cc (_cpp_parse_expr): Handle CPP_PADDING by just another
token.
Iain Sandoe [Sun, 29 May 2022 15:14:32 +0000 (16:14 +0100)]
Darwin: Fix empty g++ command lines [PR105599].
An empty g++ command line should produce a diagnostic that there are no
inputs. The PR is that currently Darwin produces a dignostic about missing
link items instead - this is because (errnoeously), for this driver, we are
creating a link job for empty command lines.
The problem occurs in four stages:
The g++ driver appends -shared-libgcc to the command line.
The Darwin driver_init code in the backend does not see this (it sees an
empty command line).
When the back end driver code driver sees an empty command line, it does not
add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
avoid anything being claimed as an input_file and therefore triggering a link
line.
Since we do not have a value for asm-macosx-version-min when processing the
driver specs, we unconditionally inject 'multiply_defined suppress' which is
used with shared libgcc (but only intended on very old Darwin). This then
causes the generation of a link job.
The solution, for the present, is to move version-specific link params to the
LINK_SPEC so that they are only processed when a link job has already been
decided.
Eric Gallager [Sun, 29 May 2022 04:57:05 +0000 (00:57 -0400)]
sourcebuild.texi: Document toplevel directories
Fixes PR82383
gcc/ChangeLog:
PR other/82383
* doc/sourcebuild.texi: Add entries for the c++tools,
gotools, libbacktrace, libcc1, libcody, liboffloadmic,
and libsanitizer directories. Remove entry for boehm-gc.
Fix alphabetization for libquadmath.
* libgomp.texi (OpenMP 5.2): Mark 'enter' clause as supported.
* testsuite/libgomp.fortran/declare-target-1.f90: Extend to test
explicit 'to' and 'enter' clause.
* testsuite/libgomp.fortran/declare-target-2.f90: Update accordingly.
Alexandre Oliva [Sat, 28 May 2022 06:50:17 +0000 (03:50 -0300)]
Rename OSCONS_CC to GCC_FOR_ADA_RTS
Several gnatlib* targets perform, with a subshell and sed, the same
GCC_FOR_TARGET pathname transformation that OSCONS_CC performs with
make subst macros. Rename OSCONS_CC to a more general name, and use
it for gnatlib as well.
for gcc/ada/ChangeLog
* gcc-interface/Makefile.in (OSCONS_CC): Rename to...
(GCC_FOR_ADA_RTS): ... this. Adjust users.
(gnatlib): Pass it down as CC.
(gnatlib-shared-default): Likewise.
(gnatlib-shared-win32, gnatlib-shared-darwin): Likewise.
Jakub Jelinek [Sat, 28 May 2022 06:30:47 +0000 (08:30 +0200)]
libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]
since apparently _aligned_malloc requires freeing with _aligned_free and:
/* Defined if gomp_aligned_alloc doesn't use fallback version
and free can be used instead of gomp_aligned_free. */
#define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
so the second condition isn't satisfied. For uses inside of the OpenMP
allocators we can still use _aligned_malloc but we need to call _aligned_free
in gomp_aligned_free.
2022-05-28 Jakub Jelinek <jakub@redhat.com>
PR libgomp/105745
* libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Don't define for
defined(HAVE__ALIGNED_MALLOC) case.
* alloc.c (gomp_aligned_alloc): Move defined(HAVE__ALIGNED_MALLOC)
handling as last option before fallback instead of first.
(gomp_aligned_free): For defined(HAVE__ALIGNED_MALLOC) call
_aligned_free.
Jakub Jelinek [Sat, 28 May 2022 06:26:57 +0000 (08:26 +0200)]
openmp: Adjust diagnostics about same variable in link and to/enter clauses
On Fri, May 27, 2022 at 04:52:17PM +0200, Tobias Burnus wrote:
> The 'TO'/'ENTER' usage is first stored in a linked list – and
> then as attribute to the symbol. I am not sure how to handle it best.
This reminds me I've left the C/C++ FE diagnostics about mixing link and
to/enter on the same variable in separate directives as is, so it always
talked about mixing link and to clauses.
This patch adjusts it, so that if link is first, it talks about the
clause actually used and if link is later, uses to or enter together
in the wording.
2022-05-28 Jakub Jelinek <jakub@redhat.com>
gcc/c/
* c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was
seen first, use "%<to%>" or "%<enter%>" depending on
OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
"%<to%> or %<enter%>" wording.
gcc/cp/
* parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was
seen first, use "%<to%>" or "%<enter%>" depending on
OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
"%<to%> or %<enter%>" wording.
gcc/testsuite/
* c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of
link and to/enter clauses on separate directives.
Jason Merrill [Fri, 27 May 2022 02:43:05 +0000 (22:43 -0400)]
c++: lambda in concept [PR105652]
We currently check satisfaction in the context of the constrained
declaration (which may be wrong, see PR104111). When checking C<int>
for S<int>, we currently substitute into the lambda in the context of
S<T> (rather than S<int>, which seems wrong if the above isn't wrong), so
the new closure type thinks its context is S<T>, which confuses debug
output. For the moment, let's work around all of this by overriding the
context of the closure.
PR c++/105652
gcc/cp/ChangeLog:
* pt.cc (tsubst_lambda_expr): Don't let a namespace-scope lambda
instantiate into a class-scope lambda.
- `scope' semantics are now enforced in `@safe' code on pointers to
stack memory, but only as deprecation warnings.
- Overriding virtual functions are now marked with the `override'
and `final' in the generated headers of `-fdump-c++-spec='.
- `-fpreview=fiximmmutableconv` has been added that disallows
implicitly converting a return value with indirections to
immutable if it determines the result must be unique.
D runtime changes:
- Posix (excluding Darwin): Switch default GC signals from SIGUSR1/2
to SIGRTMIN/SIGRTMIN+1
Specifically, the "class T::foo" bit. There, class_decl_loc_t::add gets
a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking
TYPE_BEING_DEFINED will crash. I think it's OK to allow a TYPENAME_TYPE to
slip into that function; we just shouldn't consider the 'class' tag redundant
(which works as a 'typename'). In fact, every other compiler *requires* it.
Marek Polacek [Thu, 26 May 2022 22:59:44 +0000 (18:59 -0400)]
c-family: fix attribute constructor ICE [PR90658]
Here the C compiler crashes because a FUNCTION_DECL got into
get_priority -> default_conversion, and the C FE's version of d_c
specifically asserts that it doesn't get a FUNCTION_DECL. All uses
of default_conversion in c-attribs.cc are guarded by != IDENTIFIER_NODE
&& != FUNCTION_DECL, but get_priority was only checking IDENTIFIER_NODE.
Jonathan Wakely [Fri, 27 May 2022 11:43:18 +0000 (12:43 +0100)]
libstdc++: Mark non-exported function always_inline [PR105671]
This new function was added for gcc 11.1 but is not exported from the
shared library. Depending on inlining decisions, its callers might get
inlined but an external definition be needed for this function. That
then fails to link.
Since we can't add the export to the gcc-11 release branch now, mark it
always_inline. We can consider exporting it for gcc-13 if/when we bump
the shared library version (and maybe also for gcc-12 which is currently
at the same version as trunk). For now, the attribute will solve the
problem on all affected branches. The function is small enough that
force-inlining it shouldn't cause problems.
Martin Jambor [Fri, 27 May 2022 11:05:40 +0000 (13:05 +0200)]
ipa: Check cst type when propagating controled uses info
PR 105639 shows that code with type-mismatches can trigger an assert
after runnning into a branch that was inteded only for references to
variables - as opposed to references to functions. Fixed by moving
the condition from the assert to the guarding if statement.
gcc/ChangeLog:
2022-05-25 Martin Jambor <mjambor@suse.cz>
PR ipa/105639
* ipa-prop.cc (propagate_controlled_uses): Check type of the
constant before adding a LOAD reference.
Jakub Jelinek [Fri, 27 May 2022 10:48:48 +0000 (12:48 +0200)]
openmp: Add support for enter clause on declare target
OpenMP 5.1 and earlier had 2 different uses of to clause, one for target
update construct with one semantics, and one for declare target directive
with a different semantics.
Under the hood we were using OMP_CLAUSE_TO_DECLARE to represent the latter.
OpenMP 5.2 renamed the declare target clause to to enter, the old one is
kept as a deprecated alias.
As we are far from having full OpenMP 5.2 support, this patch adds support
for the enter clause (and renames OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER
with a flag to tell the spelling of the clause for better diagnostics),
but doesn't deprecate the to clause on declare target just yet (that
should be done as one of the last steps in 5.2 support).
2022-05-27 Jakub Jelinek <jakub@redhat.com>
gcc/
* tree-core.h (enum omp_clause_code): Rename OMP_CLAUSE_TO_DECLARE
to OMP_CLAUSE_ENTER.
* tree.h (OMP_CLAUSE_ENTER_TO): Define.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Rename
OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER.
* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_ENTER
instead of OMP_CLAUSE_TO_DECLARE, if OMP_CLAUSE_ENTER_TO, print
"to" instead of "enter".
* tree-nested.cc (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
gcc/c-family/
* c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_ENTER.
gcc/c/
* c-parser.cc (c_parser_omp_clause_name): Parse enter clause.
(c_parser_omp_all_clauses): For to clause on declare target, use
OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER.
(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
(c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
* c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
name in diagnostics instead of
omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/cp/
* parser.cc (cp_parser_omp_clause_name): Parse enter clause.
(cp_parser_omp_all_clauses): For to clause on declare target, use
OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER.
(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
(cp_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
* semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
name in diagnostics instead of
omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/testsuite/
* c-c++-common/gomp/clauses-3.c: Add tests with enter clause instead
of to or modify some existing to clauses to enter.
* c-c++-common/gomp/declare-target-1.c: Likewise.
* c-c++-common/gomp/declare-target-2.c: Likewise.
* c-c++-common/gomp/declare-target-3.c: Likewise.
* g++.dg/gomp/attrs-9.C: Likewise.
* g++.dg/gomp/declare-target-1.C: Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/target-40.c: Modify some existing to
clauses to enter.
* testsuite/libgomp.c/target-41.c: Likewise.
There's heuristic to detect ptr[1].a[...] out of bound accesses
reasoning that if ptr points to an array of aggregates a trailing
incomplete array has to have size zero. The following more
thoroughly constrains the cases this applies to avoid false
positive diagnostics.
2022-05-25 Richard Biener <rguenther@suse.de>
PR tree-optimization/105726
* gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset):
Constrain array-of-flexarray case more.
Jakub Jelinek [Fri, 27 May 2022 09:40:42 +0000 (11:40 +0200)]
fold-const: Fix up -fsanitize=null in C++ [PR105729]
The following testcase triggers a false positive UBSan binding a reference
to null diagnostics.
In the FE we instrument conversions from pointer to reference type
to diagnose at runtime if the operand of such a conversion is 0.
The problem is that a GENERIC folding folds
((const struct Bar *) ((const struct Foo *) this)->data) + (sizetype) range_check (x)
conversion to const struct Bar & by converting to that the first
operand of the POINTER_PLUS_EXPR. But that changes when the -fsanitize=null
binding to reference runtime check occurs. Without the optimization,
it is invoked on the result of the POINTER_PLUS_EXPR, and as range_check
call throws, that means it never triggers in the testcase.
With the optimization, it checks whether this->data is NULL and it is.
The following patch avoids that optimization during GENERIC folding when
-fsanitize=null is enabled and it is a cast from non-REFERENCE_TYPE to
REFERENCE_TYPE.
2022-05-27 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/105729
* fold-const.cc (fold_unary_loc): Don't optimize (X &) ((Y *) z + w)
to (X &) z + w if -fsanitize=null during GENERIC folding.
Roger Sayle [Fri, 27 May 2022 07:57:46 +0000 (08:57 +0100)]
Canonicalize X&-Y as X*Y in match.pd when Y is [0,1].
"For every pessimization, there's an equal and opposite optimization".
In the review of my original patch for PR middle-end/98865, Richard
Biener pointed out that match.pd shouldn't be transforming X*Y into
X&-Y as the former is considered cheaper by tree-ssa's cost model
(operator count). A corollary of this is that we should instead be
transforming X&-Y into the cheaper X*Y as a preferred canonical form
(especially as RTL expansion now intelligently selects the appropriate
implementation based on the target's costs).
With this patch we now generate identical code for:
int foo(int x, int y) { return -(x&1) & y; }
int bar(int x, int y) { return (x&1) * y; }
specifically on x86_64-pc-linux-gnu both use and/neg/and with -O2,
but both use and/mul with -Os.
One minor wrinkle/improvement is that this patch includes three
additional optimizations (that account for the change in canonical
form) to continue to optimize PR92834 and PR94786.
2022-05-27 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* match.pd (match_zero_one_valued_p): New predicate.
(mult @0 @1): Use zero_one_valued_p for optimization to the
expression "bit_and @0 @1".
(bit_and (negate zero_one_valued_p@0) @1): Optimize to MULT_EXPR.
(plus @0 (mult (minus @1 @0) zero_one_valued_p@2)): New transform.
(minus @0 (mult (minus @0 @1) zero_one_valued_p@2)): Likewise.
(bit_xor @0 (mult (bit_xor @0 @1) zero_one_valued_p@2)): Likewise.
Remove three redundant transforms obsoleted by the three above.
gcc/testsuite/ChangeLog
* gcc.dg/pr98865.c: New test case.
Roger Sayle [Fri, 27 May 2022 07:52:03 +0000 (08:52 +0100)]
Pre-reload splitter to transform and;cmp into not;test on x86.
A common idiom for testing if a specific set of bits is set in a value
is to use "(X & Y) == Y", which on x86 results in an AND followed by a
CMP. A slightly improved implementation is to instead use (~X & Y)==0,
that uses a NOT and a TEST (or ANDN where available); still two "fast"
instructions, but typically shorter especially if Y is an immediate
constant. Because the above transformation would require more gimple
statements in SSA, and may only be a win on targets with flags registers,
it isn't performed by the middle-end, instead leaving this choice to
the backend.
As an example, here's the change in code generation for pr91400-1.c
[which now requires a tweak to its dg-final clauses].
This patch makes bswap[sd]i2 better register allocation, and reconstructs
bswapsi2 in order to take advantage of GIMPLE manual byte-swapping
recognition.
gcc/ChangeLog:
* config/xtensa/xtensa.md (bswapsi2): New expansion pattern.
(bswapsi2_internal): Revise the template and condition, and add
detection code for preceding the same insn in order to omit a
"SSAI 8" instruction of the latter.
(bswapdi2): Suppress built-in insn expansion with the corresponding
library call when optimizing for size.
Jonathan Wakely [Thu, 26 May 2022 20:32:55 +0000 (21:32 +0100)]
libstdc++: Fix narrowing conversions for 16-bit size_t [PR105681]
On a 16-bit target such as msp430 we get errors about narrowing long
values to size_t, which is only 16-bit. When --enable-libstdcxx-pch is
used the <bits/extc++.h> header breaks the build because of these
narrowing errors.
libstdc++-v3/ChangeLog:
PR libstdc++/105681
* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:
Limit ga_sizes array to values that fit in size_t.
* include/ext/random [__SIZE_WIDTH < 32] (sfmt86243)
(sfmt86243_64, sfmt132049, sfmt132049_64, sfmt216091)
(sfmt216091_64): Do not declare.
Jonathan Wakely [Thu, 26 May 2022 14:44:08 +0000 (15:44 +0100)]
libstdc++: Fix atomic and error_code printers for versioned namespace
This fixes the printers to work with std::__8::atomic and
std::__v8::ios_errc and std::__v8::future_errc.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Make
lookup for ios_errc and future_errc check versioned namespace.
(StdAtomicPrinter): Strip versioned namespace from typename.
Jonathan Wakely [Thu, 26 May 2022 14:42:50 +0000 (15:42 +0100)]
libstdc++: Move std::iostream_category() definition to new file
This fixes a missing symbol when the dual ABI is disabled, e.g. for the
versioned namespace build.
libstdc++-v3/ChangeLog:
* src/c++11/Makefile.am: Add new source file.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/cxx11-ios_failure.cc (iostream_category):
Move to ...
* src/c++11/ios_errcat.cc: New file.
* testsuite/27_io/ios_base/failure/error_code.cc: Check that
std::iostream_category() is defined and used for std::io_errc.
Marek Polacek [Wed, 11 May 2022 18:38:49 +0000 (14:38 -0400)]
c++: improve -Waddress warnings with *_cast [PR105569]
This patch improves the diagnostic for -Waddress when it warns for
if (dynamic_cast<A*>(&ref))
// ...
where 'ref' is a reference, which cannot be null. In particular, it
changes
warning: comparing the result of pointer addition '(((A*)ref) + ((sizetype)(*(long int*)((& ref)->B::_vptr.B + -24))))' and NULL
to
warning: the compiler can assume that the address of 'ref' will never be NULL
PR c++/105569
gcc/cp/ChangeLog:
* typeck.cc (warn_for_null_address): Improve the warning when
the POINTER_PLUS_EXPR's base is of reference type.
Jonathan Wakely [Thu, 26 May 2022 11:41:03 +0000 (12:41 +0100)]
libstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (counted_iterator::operator++(int)):
Add 'constexpr' as per LWG 3643.
* testsuite/24_iterators/counted_iterator/lwg3643.cc: New test.
Here during cp_parser_single_declaration for #2, we were calling
associate_classtype_constraints for TPL<T> (the primary template type)
before maybe_process_partial_specialization could get a chance to
notice that we're in fact declaring a distinct constrained partial
spec and not redeclaring the primary template. This caused us to
emit a bogus error about differing constraints b/t the primary template
and #2's constraints. This patch fixes this by moving the call to
associate_classtype_constraints after the call to shadow_tag (which
calls maybe_process_partial_specialization) and adjusting shadow_tag to
use the return value of m_p_p_s.
Moreover, if we later try to define a constrained partial specialization
that's been declared earlier (as in the third testcase), then
maybe_new_partial_specialization correctly notices it's a redeclaration
and returns NULL_TREE. But in this case we also need to update TYPE to
point to the redeclared partial spec (it'll otherwise continue pointing
to the primary template type, eventually leading to a bogus error).
PR c++/96363
gcc/cp/ChangeLog:
* decl.cc (shadow_tag): Use the return value of
maybe_process_partial_specialization.
* parser.cc (cp_parser_single_declaration): Call shadow_tag
before associate_classtype_constraints.
* pt.cc (maybe_new_partial_specialization): Change return type
to bool. Take 'type' argument by mutable reference. Set 'type'
to point to the correct constrained specialization when
appropriate.
(maybe_process_partial_specialization): Adjust accordingly.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-partial-spec12.C: New test.
* g++.dg/cpp2a/concepts-partial-spec12a.C: New test.
* g++.dg/cpp2a/concepts-partial-spec13.C: New test.
Jonathan Wakely [Tue, 24 May 2022 11:17:01 +0000 (12:17 +0100)]
libstdc++: Refactor includes for unordered containers
This moves some #include directives to the relevant place. For example,
<bits/hashtable_policy.h> needs <bits/stl_pair.h> so should include it
directly instead of relying on <unordered_map> and <unordered_set> to do
so first.
libstdc++-v3/ChangeLog:
* include/bits/functional_hash.h (__is_fast_hash): Add doxygen
comment.
* include/bits/hashtable.h: Do not include <bits/stl_function.h>
here.
* include/bits/hashtable_policy.h: Include <bits/stl_pair.h> and
<bits/functional_hash.h>.
* include/bits/unordered_map.h: Include required headers.
* include/bits/unordered_set.h: Likewise.
* include/std/unordered_map: Do not include headers for indirect
dependencies.
* include/std/unordered_set: Likewise.
Jonathan Wakely [Tue, 24 May 2022 11:15:00 +0000 (12:15 +0100)]
libstdc++: Remove some unnecessary includes
These headers do not use anything in <bits/stl_iterator_base_types.h>
directly, and it's included by <bits/stl_iterator_base_funcs.h> and
<bits/stl_iterator.h> anyway, because they do need it.
libstdc++-v3/ChangeLog:
* include/bits/ranges_algobase.h: Do not include
<bits/stl_iterator_base_types.h>.
* include/std/string: Likewise.
* include/std/variant: Likewise.
Jonathan Wakely [Fri, 20 May 2022 09:41:53 +0000 (10:41 +0100)]
libstdc++: Rename tests like .../wchar_t/1.cc to .../wchar_t.cc
There's no need to have directories containing a single test file, we
can rename the files to the directory names and remove the directories.
The dejagnu proc that filters out wchar_t tests just checks for
"wchar_t" anywhere in the path, so will work just as well on wchar_t.cc
or constexpr-wchar_t.cc paths.
libstdc++-v3/ChangeLog:
* testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/pop_back/char.cc:
...here.
* testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/swap/constexpr-wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/swap/constexpr.cc:
...here.
* testsuite/21_strings/basic_string/operations/contains/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/contains/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/contains/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/contains/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/data/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/data/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/data/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/ends_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/ends_with/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/ends_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/starts_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/starts_with/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/starts_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/substr/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/substr/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/substr/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/range_access/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/range_access/char.cc:
...here.
* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/range_access/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/swap/char.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/contains/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/contains/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/contains/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/contains/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/data/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/data/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/data/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/ends_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/ends_with/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/starts_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/starts_with/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/substr/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/substr/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/substr/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/range_access/char.cc:
...here.
* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/range_access/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/int.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/int.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/short/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/short.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t.cc:
...here.
Marek Polacek [Thu, 28 Apr 2022 17:21:41 +0000 (13:21 -0400)]
c++: fix ICE on invalid attributes [PR96637]
When chaining attributes, attr_chainon should be used rather than plain
chainon, so that we don't end up with a TREE_LIST where one of the elements
is error_mark_node, which causes problems. parser.cc has already been
fixed to use attr_chainon, but decl.cc has not. Until now.
PR c++/96637
gcc/cp/ChangeLog:
* cp-tree.h (attr_chainon): Declare.
* decl.cc (start_decl): Use attr_chainon.
(grokdeclarator): Likewise.
* parser.cc (cp_parser_statement): No longer static.
Jason Merrill [Wed, 25 May 2022 16:38:58 +0000 (12:38 -0400)]
c++: CTAD with alias and nested template [PR105655]
Here, alias_ctad_tweaks expect tsubst_decl of a FUNCTION_DECL to return a
FUNCTION_DECL. A reasonable expectation, but in this case we were replacing
the template args of the class-scope deduction guide with equivalent args,
so looking in the hash table we found the partial instantiation stored when
instantiating A<int>, which is a TEMPLATE_DECL. It's fine for that to be
what is stored, but tsubst_function_decl should never return it.
PR c++/105655
gcc/cp/ChangeLog:
* pt.cc (build_template_decl): Add assert.
(tsubst_function_decl): Don't return a template.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/class-deduction-alias13.C: New test.
Jason Merrill [Tue, 24 May 2022 21:37:58 +0000 (17:37 -0400)]
c++: deduction from auto fn [PR105623]
Since my patch for PR90451, we defer mark_used of single functions as late
as possible. And since my r12-1273, we keep BASELINK from lookup around
rather than reconstruct it later. These both made us try to instantiate g
with a function type that still had 'auto' as its return type.
PR c++/105623
gcc/cp/ChangeLog:
* decl2.cc (mark_used): Copy type from fn to BASELINK.
* pt.cc (unify_one_argument): Call mark_single_function.
Jason Merrill [Sun, 22 May 2022 19:04:33 +0000 (15:04 -0400)]
c++: strict constexpr and local vars
A change I was working on made constexpr_searcher.cc start to fail, and when
I looked at it I wondered why it had been accepted before. This turned out
to be because we try to be more flexible about constant-evaluation of static
initializers, as allowed, but we were wrongly doing the same for non-static
initializers as well.
gcc/cp/ChangeLog:
* constexpr.cc (maybe_constant_init_1): Only pass false for
strict when initializing a variable of static duration.
that is, two PLACEHOLDER_EXPRs for different types on the same level in
a {}. This crashes because our CONSTRUCTOR_PLACEHOLDER_BOUNDARY mechanism to
avoid replacing unrelated PLACEHOLDER_EXPRs cannot deal with it.
Here's why we wound up with those PLACEHOLDER_EXPRs: When we're performing
cp_parser_late_parsing_nsdmi for "int y = A{x}.y;" we use finish_compound_literal
on type=A, compound_literal={((struct B *) this)->x}. When digesting this
initializer, we call get_nsdmi which creates a PLACEHOLDER_EXPR for A -- we don't
have any object to refer to yet. After digesting, we have
{.x=((struct B *) this)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x}
and since we've created a PLACEHOLDER_EXPR inside it, we marked the whole ctor
CONSTRUCTOR_PLACEHOLDER_BOUNDARY. f_c_l creates a TARGET_EXPR and returns
TARGET_EXPR <D.2384, {.x=((struct B *) this)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x}>
Then we get to
B b = {};
and call store_init_value, which digests the {}, which produces
lookup_placeholder in constexpr won't find an object to replace the
PLACEHOLDER_EXPR for B, because ctx->object will be D.2395 of type A, and we
cannot search outward from D.2395 to find 'b'.
The call to replace_placeholders in store_init_value will not do anything:
we've marked the inner { } CONSTRUCTOR_PLACEHOLDER_BOUNDARY, and it's only
a sub-expression, so replace_placeholders does nothing, so the <P_E struct B>
stays even though now is the perfect time to replace it because we have an
object for it: 'b'.
where D.2395 is of type A, but we crash because we hit <P_E struct B>, which
has a different type.
My idea was to replace <P_E struct A> with D.2384 after creating the
TARGET_EXPR because that means we have an object we can refer to.
Then clear CONSTRUCTOR_PLACEHOLDER_BOUNDARY because we no longer have
a PLACEHOLDER_EXPR in the {}. Then store_init_value will be able to
replace <P_E struct B> with 'b', and we should be good to go. We must
be careful not to break guaranteed copy elision, so this replacement
happens in digest_nsdmi_init where we can see the whole initializer,
and avoid replacing any placeholders in TARGET_EXPRs used in the context
of initialization/copy elision. This is achieved via the new function
called potential_prvalue_result_of.
While fixing this problem, I found PR105550, thus the FIXMEs in the
tests.
PR c++/100252
gcc/cp/ChangeLog:
* typeck2.cc (potential_prvalue_result_of): New.
(replace_placeholders_for_class_temp_r): New.
(digest_nsdmi_init): Call it.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/nsdmi-aggr14.C: New test.
* g++.dg/cpp1y/nsdmi-aggr15.C: New test.
* g++.dg/cpp1y/nsdmi-aggr16.C: New test.
* g++.dg/cpp1y/nsdmi-aggr17.C: New test.
* g++.dg/cpp1y/nsdmi-aggr18.C: New test.
* g++.dg/cpp1y/nsdmi-aggr19.C: New test.
Increase the priority of the init_have_lse_atomics constructor so it runs
before other constructors. This improves chances that rr works when LSE
atomics are supported.