Etienne Servais [Tue, 14 Dec 2021 08:46:19 +0000 (09:46 +0100)]
[Ada] Update -gnatwr doc for import of parent package
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Update -gnatwr documentation.
* gnat_ugn.texi: Regenerate.
Piotr Trojanek [Tue, 14 Dec 2021 22:10:44 +0000 (23:10 +0100)]
[Ada] Fix comment about subprogram unnesting and unconstrained arrays
gcc/ada/
* exp_unst.adb (Unnest_Subprogram): Sync comment with the
current code.
Piotr Trojanek [Wed, 8 Dec 2021 22:24:13 +0000 (23:24 +0100)]
[Ada] Fix inconsistent quoting in messages about compile-time errors
gcc/ada/
* exp_ch4.adb (Raise_Accessibility_Error): Move exception name
to the message string; move << control characters to the end,
for consistency.
* sem_ch6.adb (Analyze_Function_Return): Likewise.
* sem_util.adb (Compile_Time_Constraint_Error): Likewise.
* gcc-interface/decl.c (gnat_to_gnu_entity): Remove quotes
around Storage_Error.
* gcc-interface/trans.c (gnat_to_gnu): Remove quotes around
Constraint_Error.
gcc/testsuite/
* gnat.dg/aggr26.adb: Update expected error message.
Piotr Trojanek [Mon, 13 Dec 2021 13:07:42 +0000 (14:07 +0100)]
[Ada] Consistent suppression for warnings inside null loops
gcc/ada/
* errout.adb (Error_Msg): Move warning suppression code from
Error_Msg_NLE
(Error_Msg_NLE): Warning suppression is now done by the internal
call to Error_Msg.
Piotr Trojanek [Mon, 13 Dec 2021 19:25:15 +0000 (20:25 +0100)]
[Ada] Remove unnecessary guard for inserting non-empty list
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Remove unnecessary
guards.
* exp_ch4.adb (Expand_N_If_Expression): Likewise; clarify comment.
* exp_ch5.adb (Expand_N_If_Statement,
Expand_Iterator_Loop_Over_Container): Likewise.
* exp_ch9.adb (Expand_N_Task_Type_Declaration): Remove redundant
guard.
* freeze.adb (Freeze_All_Ent): Reduce scope of a local variable.
Piotr Trojanek [Mon, 13 Dec 2021 15:53:23 +0000 (16:53 +0100)]
[Ada] Remove unnecessary guards for appending non-empty lists
gcc/ada/
* exp_ch3.adb (Build_Init_Procedure): Remove unnecessary guard.
* exp_disp.adb (Make_DT): Likewise.
* sem_ch12.adb (Analyze_Associations): Likewise.
Etienne Servais [Tue, 30 Nov 2021 16:47:52 +0000 (17:47 +0100)]
[Ada] Check scalar range in arrays constructed by concatenation
gcc/ada/
* sem_res.adb (Resolve_Op_Concat_Arg): Check range when
concatenating scalars.
Bob Duff [Sat, 11 Dec 2021 12:45:54 +0000 (07:45 -0500)]
[Ada] treepr: print value only for discrete types
gcc/ada/
* treepr.adb (Print_Node_Ref): Change "not Is_Array_Type" to
"Is_Discrete_Type".
Richard Kenner [Wed, 8 Dec 2021 22:11:26 +0000 (17:11 -0500)]
[Ada] Use non-internal representation for access subprograms if UC to Address
gcc/ada/
* libgnat/g-spipat.ads (Boolean_Func, Natural_Func,
VString_Func): Mark as Favor_Top_Level.
* sem_ch13.adb (Validate_Unchecked_Conversion): Avoid using
internal representation if Unchecked_Conversion between
an access to subprogram and System.Address within the same unit.
Bob Duff [Fri, 10 Dec 2021 20:53:04 +0000 (15:53 -0500)]
[Ada] treepr: Print value of static expression
gcc/ada/
* treepr.adb (Print_Node_Ref): Print the value if available.
Richard Kenner [Wed, 8 Dec 2021 22:11:00 +0000 (17:11 -0500)]
[Ada] Add an option to Get_Fullest_View to not recurse
gcc/ada/
* sem_util.ads, sem_util.adb (Get_Fullest_View): Add option to
not recurse and return the next-most-fullest view.
Bob Duff [Fri, 10 Dec 2021 19:04:59 +0000 (14:04 -0500)]
[Ada] Warn on import of parent package
gcc/ada/
* sem_ch10.adb (Check_Redundant_Withs): Add a warning if a
library unit with's its own ancestor. Note that this warning is
not triggered for something like "with P.R;" in P.Q, because
there the "with P;" is considered implicit.
* fname-sf.adb, libgnarl/s-stusta.adb, libgnarl/s-tasdeb.ads,
libgnat/a-calfor.adb, libgnat/a-tiboio.adb,
libgnat/a-wwboio.adb, libgnat/a-zzboio.adb, libgnat/i-cobol.adb,
libgnat/s-bitops.adb, libgnat/s-bitops.ads,
libgnat/s-direio.adb, libgnat/s-dwalin.adb,
libgnat/s-geveop.adb, libgnat/s-mmosin__unix.adb,
libgnat/s-os_lib.adb, libgnat/s-os_lib.ads,
libgnat/s-pooglo.ads, libgnat/s-secsta.adb,
libgnat/s-shasto.adb, libgnat/s-stausa.ads,
libgnat/s-stratt.ads, libgnat/s-ststop.adb: Remove with of
parent.
* sinfo.ads: Minor comment fix.
Bob Duff [Fri, 10 Dec 2021 18:21:38 +0000 (13:21 -0500)]
[Ada] Small cleanup of osint-m.adb
gcc/ada/
* osint-m.adb: Remove with_clause and pragma.
liuhongt [Mon, 20 Dec 2021 03:13:38 +0000 (11:13 +0800)]
Allow propagations from inner loop to outer loop.
NULL is considered as an outer loop of any other loop.
gcc/ChangeLog:
PR rtl-optimization/103750
* fwprop.c (forward_propagate_into): Allow propagations from
inner loop to outer loop.
gcc/testsuite/ChangeLog:
* g++.target/i386/pr103750-fwprop-1.C: New test.
Roger Sayle [Fri, 7 Jan 2022 09:57:21 +0000 (09:57 +0000)]
nvptx: Add support for PTX's cnot instruction.
This is a simple patch, now that the nvptx backend has transitioned
to STORE_FLAG_VALUE=1, that adds support for NVidia's cnot instruction,
that implements C/C++ style logical negation.
Previously, the simple function:
int foo(int x) { return !x; }
on nvptx-none with -O2 would generate:
mov.u32 %r24, %ar0;
setp.eq.u32 %r28, %r24, 0;
selp.u32 %value, 1, 0, %r28;
with this patch, GCC now generates:
mov.u32 %r24, %ar0;
cnot.b32 %value, %r24;
2022-01-07 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/nvptx/nvptx.md (*cnot<mode>2): New define_insn.
gcc/testsuite/ChangeLog
* gcc.target/nvptx/cnot-1.c: New test case.
Haochen Gui [Fri, 7 Jan 2022 06:20:44 +0000 (14:20 +0800)]
rs6000: Define a pattern for mffscrni. If the RN is a constant, it can call gen_rs6000_mffscrni directly.
gcc/
* config/rs6000/rs6000.md (rs6000_mffscrni): Define.
(rs6000_set_fpscr_rn): Change the type of operand[0] from DI to SI.
Call gen_rs6000_mffscrni when operand[0] is a const_0_to_3_operand.
gcc/testsuite/
* gcc.target/powerpc/mffscrni_p9.c: New testcase for mffscrni.
* gcc.target/powerpc/test_fpscr_rn_builtin.c: Test mffscrn and mffscrni
separately.
Jason Merrill [Fri, 7 Jan 2022 02:58:01 +0000 (21:58 -0500)]
c++: temporarily restore VEC_INIT_EXPR gimplify [PR103936]
PR103936 demonstrates that some VEC_INIT_EXPR can still survive into
GENERIC; until that's fixed let's put back the handling in cp_gimplify_expr.
PR c++/103936
PR c++/65591
gcc/cp/ChangeLog:
* cp-gimplify.c (cp_gimplify_expr): Restore VEC_INIT_EXPR handling.
gcc/testsuite/ChangeLog:
* g++.dg/init/aggr15.C: New test.
liuhongt [Thu, 6 Jan 2022 07:33:20 +0000 (15:33 +0800)]
Support commutative alternative for AVX512 vpcmpeq{b,w,d,q}
gcc/ChangeLog:
* config/i386/sse.md
(*<avx512>_eq<mode>3<mask_scalar_merge_name>_1): Extend to
UNSPEC_PCMP_UNSIGNED.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr103774.c: New test.
* gcc.target/i386/avx512bw-vpcmpequb-1.c: Adjust scan assembler
from vpcmpub to (?:vpcmpub|vpcmpeqb).
* gcc.target/i386/avx512bw-vpcmpequw-1.c: Ditto.
* gcc.target/i386/avx512bw-vpcmpub-1.c: Ditto.
* gcc.target/i386/avx512bw-vpcmpuw-1.c: Ditto.
* gcc.target/i386/avx512f-vpcmpequd-1.c: Ditto.
* gcc.target/i386/avx512f-vpcmpequq-1.c: Ditto.
* gcc.target/i386/avx512f-vpcmpud-1.c: Ditto.
* gcc.target/i386/avx512vl-vpcmpequd-1.c: Ditto.
* gcc.target/i386/avx512vl-vpcmpequq-1.c: Ditto.
* gcc.target/i386/avx512vl-vpcmpuq-1.c: Ditto.
liuhongt [Wed, 5 Jan 2022 07:26:18 +0000 (15:26 +0800)]
Optimize V16HF vector insert to element 0 for AVX2.
gcc/ChangeLog:
PR target/103753
* config/i386/i386-expand.c (ix86_expand_vector_set): Not use
gen_avx2_pblendph_1 when elt == 0.
* config/i386/sse.md (avx2_pblendph): Rename to ..
(avx2_pblend<ssemodesuffix>_1).. this, and extend to V16HI.
(*avx2_pblendw): Rename to ..
(*avx2_pblend<ssemodesuffix>): .. this, and extend to V16HF.
(avx2_pblendw): Rename to ..
(*avx2_pblend<ssemodesuffix>): .. this, and extend to V16HF.
(blendsuf): Removed.
(sse4_1_pblend<blendsuf>): Renamed to ..
(sse4_1_pblend<ssemodesuffix>): .. this.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr103753.c: New test.
Sandra Loosemore [Thu, 6 Jan 2022 19:23:18 +0000 (11:23 -0800)]
Fortran: Fix handling of optional argument to SIZE intrinsic [PR103898]
This patch fixes a think-o in the code that triggered an ICE
in the test case.
2021-01-06 Sandra Loosemore <sandra@codesourcery.com>
PR fortran/103898
gcc/fortran/
* trans-intrinsic.c (gfc_conv_intrinsic_size): Make size_var
actually be a variable and fix surrounding code.
gcc/testsuite/
* gfortran.dg/pr103898.f90: New test.
Jason Merrill [Thu, 6 Jan 2022 00:39:48 +0000 (19:39 -0500)]
c++: when delegating constructor throws [PR103711]
We were always calling the complete destructor if the target constructor
throws, even if we were calling the base constructor.
PR c++/103711
gcc/cp/ChangeLog:
* init.c (perform_target_ctor): Select destructor by in_chrg.
gcc/testsuite/ChangeLog:
* g++.dg/eh/delegating1.C: New test.
Jason Merrill [Thu, 6 Jan 2022 14:45:26 +0000 (09:45 -0500)]
c++: nested catch in ctor fn-try-block [PR61611]
Being in_function_try_handler isn't enough to satisfy the condition of
reaching the end of such a handler; in this case, we're reaching the end of
a handler within that handler, so we don't want the special semantics.
PR c++/61611
gcc/cp/ChangeLog:
* except.c (in_nested_catch): New.
(expand_end_catch_block): Check it.
gcc/testsuite/ChangeLog:
* g++.dg/eh/ctor-fntry1.C: New test.
Jason Merrill [Wed, 5 Jan 2022 22:01:12 +0000 (17:01 -0500)]
c++: destroy retval on throwing cleanup in try [PR33799]
My earlier attempt to fix this bug didn't handle the case where both the
return and the throwing cleanup are within a try-block that catches and
discards the exception. Fixed by adding the retval cleanup to any
try-blocks as well as the function body. PR102191 pointed out that we also
weren't handling templates properly, so I moved the call out of the parser.
PR c++/33799
PR c++/102191
gcc/cp/ChangeLog:
* except.c (maybe_splice_retval_cleanup): Check
current_binding_level.
* semantics.c (do_poplevel): Call it here.
* parser.c (cp_parser_compound_statement): Not here.
gcc/testsuite/ChangeLog:
* g++.dg/eh/return1.C: Add temporary in try block case.
* g++.dg/cpp2a/constexpr-dtor11.C: New test.
Jason Merrill [Wed, 5 Jan 2022 16:18:25 +0000 (11:18 -0500)]
c++: clean up ref-extended temp on throwing dtor [PR53868]
We have wrap_temporary_cleanups to handle the EH region nesting problems
between cleanups for complete variables and cleanups for temporaries used in
their construction, but we weren't calling it for temporaries extended from
binding to a reference.
We still don't want this for array cleanups (since my PR94041 fix), so I
move that exception from initialize_local_var to wrap_temporary_cleanups.
PR c++/53868
gcc/cp/ChangeLog:
* decl.c (cp_finish_decl): Use wrap_temporary_cleanups for
cleanups from set_up_extended_ref_temp.
(wrap_temporary_cleanups): Ignore array cleanups.
(initialize_local_var): Don't check for array here.
* cp-tree.h (BIND_EXPR_VEC_DTOR): New.
* init.c (build_vec_delete_1): Set it.
gcc/testsuite/ChangeLog:
* g++.dg/eh/ref-temp1.C: New test.
* g++.dg/eh/ref-temp2.C: New test.
Jason Merrill [Wed, 5 Jan 2022 14:49:37 +0000 (09:49 -0500)]
c++: keep destroying array after one dtor throws [PR66451]
When we're cleaning up an array, if one destructor throws, we should still
try to clean up the rest of the array. We can use TRY_CATCH_EXPR for this,
instead of a TARGET_EXPR like my other recent patches, because a destructor
call can't involve any temporaries that need to live longer.
I thought about only doing this when we call build_vec_delete_1 from
build_vec_init, but it seems appropriate for delete-expressions as well;
we've said that the array's lifetime is over, it makes sense to keep trying
to destroy it. The standard isn't clear, but clang seems to agree with me.
PR c++/66451
gcc/cp/ChangeLog:
* init.c (build_vec_delete_1): Handle throwing dtor.
(build_vec_init): Tell it we're in a cleanup already.
gcc/testsuite/ChangeLog:
* g++.dg/eh/array3.C: New test.
* g++.dg/eh/array1.C: Mark destructor as throw().
* g++.dg/ipa/devirt-40.C: Likewise.
* g++.dg/warn/pr83054.C: Likewise.
* g++.dg/eh/delete1.C: Shorten array to one element.
Jason Merrill [Tue, 4 Jan 2022 20:25:07 +0000 (15:25 -0500)]
c++: don't cleanup the last aggregate elt
Now that we're building cleanups for aggregate elements more often, it seems
worth optimizing by avoiding building one for the last element; once it is
initialized, the complete object is fully initialized, the element cleanups
end in favor of the complete object cleanup, and so a cleanup for the last
element would guard nothing at all.
gcc/cp/ChangeLog:
* typeck2.c (split_nonconstant_init_1): Don't cleanup the last elt.
(split_nonconstant_init): Adjust.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/aggregate1.C: New test.
Jason Merrill [Thu, 5 Mar 2020 20:50:45 +0000 (15:50 -0500)]
c++: EH and partially constructed aggr temp [PR66139]
Now that PR94041 is fixed, I can return to addressing PR66139, missing
cleanups for partially constructed aggregate temporaries. My previous
approach of calling split_nonconstant_init in cp_gimplify_init_expr broke
because gimplification is too late to be introducing destructor calls. So
instead I now call it under cp_fold_function, just before cp_genericize;
doing it from cp_genericize itself ran into trouble with the rewriting of
invisible references.
So now the prediction in cp_gimplify_expr that cp_gimplify_init_expr
might need to replace references to TARGET_EXPR_SLOT within
TARGET_EXPR_INITIAL has come to pass. constexpr.c already had the simple
search-and-replace tree walk I needed, but it needed to be fixed to actually
replace all occurrences instead of just the first one.
Handling of VEC_INIT_EXPR at gimplify time had similar issues that we worked
around with build_vec_init_elt, so I'm moving that to cp_fold_function as
well. But it seems that build_vec_init_elt is still useful for setting the
VEC_INIT_EXPR_IS_CONSTEXPR flag, so I'm leaving it alone.
This also fixes 52320, because build_aggr_init of each X from build_vec_init
builds an INIT_EXPR rather than call split_nonconstant_init at that point,
and now that INIT_EXPR gets split later.
PR c++/66139
PR c++/52320
gcc/cp/ChangeLog:
* constexpr.c (replace_decl): Rename from replace_result_decl.
* cp-tree.h (replace_decl): Declare it.
* cp-gimplify.c (cp_gimplify_init_expr): Call it.
(cp_gimplify_expr): Don't handle VEC_INIT_EXPR.
(cp_genericize_init, cp_genericize_init_expr)
(cp_genericize_target_expr): New.
(cp_fold_r): Call them.
* tree.c (build_array_copy): Add a TARGET_EXPR.
* typeck2.c (digest_init_r): Look through a TARGET_EXPR.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist116.C: New test.
* g++.dg/cpp0x/initlist117.C: New test.
* g++.dg/cpp0x/lambda/lambda-eh.C: New test.
* g++.dg/eh/aggregate1.C: New test.
Jason Merrill [Sat, 1 Jan 2022 21:00:22 +0000 (16:00 -0500)]
c++: temporary lifetime with array aggr init [PR94041]
The previous patch fixed temporary lifetime for aggregate initialization of
classes; this one extends that fix to arrays. This specifically reverses my
r74790, the patch for PR12253, which was made wrong when these semantics
were specified in DR201.
Since the array cleanup region encloses the regions for any temporaries, we
don't need to add an additional region for the array object itself in either
initialize_local_var or split_nonconstant_init; we do, however, need to tell
split_nonconstant_init how to disable the cleanup once an enclosing object
is fully constructed, at which point we want to run that destructor instead.
PR c++/94041
gcc/cp/ChangeLog:
* decl.c (initialize_local_var): Fix comment.
* init.c (build_new_1): Do stabilize array init.
(build_vec_init): Use TARGET_EXPR for cleanup. Initialization
of an element from an explicit initializer is not a
full-expression.
* tree.c (expand_vec_init_expr): Pass flags through.
* typeck2.c (split_nonconstant_init_1): Handle VEC_INIT_EXPR.
(split_nonconstant_init): Handle array cleanups.
* cp-tree.h: Adjust.
gcc/testsuite/ChangeLog:
* g++.dg/init/array12.C:
* g++.dg/init/aggr7-eh2.C: New test.
* g++.dg/init/aggr7-eh3.C: New test.
Jason Merrill [Thu, 5 Mar 2020 20:50:45 +0000 (15:50 -0500)]
c++: temporary lifetime with aggregate init [PR94041]
In C++98 the lifetime of temporaries in aggregate initialization was
unclear, but C++11 DR201 clarified that only temporaries created for
default-initialization of an array element with no corresponding
initializer-clause are destroyed immediately; all others persist until the
end of the full-expression.
But we never implemented that, and continued treating individual element
initializations as full-expressions, such as in my patch for PR50866 in
r180442. This blocked my attempted fix for PR66139, which extended the use
of split_nonconstant_init, and thus the bug, to aggregate initialization of
temporaries within an expression.
The longer temporary lifetime creates further EH region overlap problems
like the ones that wrap_temporary_cleanups addresses: in aggr7.C, we start
out with a normal nesting of
A1
c.b1
A2
c.b2
...
~A2
~A1
where on the way in, throwing from one of the inits will clean up from the
previous inits. But once c.b2 is initialized, throwing from ~A2 must not
clean up c.b1; instead it needs to clean up c. So as in build_new_1, we
deal with this by guarding the B cleanups with flags that are cleared once c
is fully constructed; throwing from one of the ~A still hits that region,
but does not call ~B. And then wrap_temporary_cleanups deals with calling
~C, but we need to tell it not to wrap the subobject cleanups.
The change from expressing the subobject cleanups with CLEANUP_STMT to
TARGET_EXPR was also necessary because we need them to collate with the ~A
in gimplify_cleanup_point_expr; the CLEANUP_STMT representation only worked
with treating subobject initializations as full-expressions.
PR c++/94041
gcc/cp/ChangeLog:
* decl.c (check_initializer): Remove obsolete comment.
(wrap_cleanups_r): Don't wrap CLEANUP_EH_ONLY.
(initialize_local_var): Change assert to test.
* typeck2.c (maybe_push_temp_cleanup): New.
(split_nonconstant_init_1): Use it.
(split_nonconstant_init): Clear cleanup flags.
gcc/testsuite/ChangeLog:
* g++.dg/init/aggr7-eh.C: New test.
* g++.dg/cpp0x/initlist122.C: Also test aggregate variable.
Jason Merrill [Sat, 1 Jan 2022 21:00:09 +0000 (16:00 -0500)]
c++: loop over array elts w/o explicit init [PR92385]
The PR complains that initializing a large array with {} takes a long time
to compile; this was because digest_init would turn {} into a long
CONSTRUCTOR with an initializer for each element, instead of more sensibly
generating a loop. The standard doesn't specify this implementation, but it
does allow for it by specifying that a temporary created "when a default
constructor is called to initialize an element of an array with no
corresponding initializer" is destroyed "before the construction of the next
array element, if any." rather than living until the end of the complete
object initialization as usual.
This change is also needed before the PR94041 fix extends the lifetime of
temporaries from elements with explicit initializers.
To implement this, I change digest_init so that in cases where
initialization of trailing array elements isn't constant, we return a
VEC_INIT_EXPR instead of a bare CONSTRUCTOR; when it is encountered later,
we call build_vec_init to generate the actual initialization code.
PR c++/92385
gcc/cp/ChangeLog:
* typeck2.c (PICFLAG_VEC_INIT): New.
(process_init_constructor_array): Set it.
(process_init_constructor): Handle it.
(split_nonconstant_init_1): Handle VEC_INIT_EXPR.
* init.c (build_vec_init): Likewise.
* cp-gimplify.c (cp_gimplify_expr): Factor out...
* tree.c (expand_vec_init_expr): ...this function.
(build_vec_init_elt): Handle BRACE_ENCLOSED_INITIALIZER_P.
(build_vec_init_expr): Likewise.
* constexpr.c (cxx_eval_vec_init): Likewise.
(reduced_constant_expression_p): Check arrays before C++20.
* cp-tree.h (expand_vec_init_expr): Declare.
gcc/testsuite/ChangeLog:
* g++.dg/init/array61.C: New test.
Jason Merrill [Tue, 4 Jan 2022 19:39:52 +0000 (14:39 -0500)]
c++: don't preevaluate new-initializer
The preevaluation code was causing trouble with my fix for PR94041, and now
I see that it's actually wrong since P0145 was adopted for C++17, mandating
order of evaluation for many expressions that were previously unspecified.
I don't see a need to preserve the preevaluation code for older standard
modes.
gcc/cp/ChangeLog:
* init.c (build_new_1): Remove preevaluation code.
gcc/testsuite/ChangeLog:
* g++.old-deja/g++.martin/new1.C: Don't expect preeval.
* g++.dg/tree-ssa/stabilize1.C: Removed.
GCC Administrator [Fri, 7 Jan 2022 00:16:24 +0000 (00:16 +0000)]
Daily bump.
David Malcolm [Thu, 6 Jan 2022 16:39:54 +0000 (11:39 -0500)]
analyzer: make use of may_be_aliased in alias detection [PR103546]
Whilst debugging PR analyzer/103546 (false +ve in flex-generated lexers)
I noticed that the analyzer was considering that writes through symbolic
pointers could be treated as clobbering static globals such as:
static YY_BUFFER_STATE * yy_buffer_stack = NULL;
even for such variables that never have their address taken.
This patch fixes this issue at least, so that the analyzer can preserve
knowledge of such globals on code paths with writes through symbolic
pointers.
It does not fix the false +ve in the lexer code.
gcc/analyzer/ChangeLog:
PR analyzer/103546
* store.cc (store::eval_alias_1): Refactor handling of decl
regions, adding a test for may_be_aliased, rejecting those for
which it returns false.
gcc/testsuite/ChangeLog:
PR analyzer/103546
* gcc.dg/analyzer/aliasing-3.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Sandra Loosemore [Wed, 5 Jan 2022 21:18:10 +0000 (13:18 -0800)]
Fortran: Fix ICE in argument_rank_mismatch [PR103287]
This patch removes an incorrect assertion. A user-friendly error for this
case is already given elsewhere.
2022-01-05 Steve Kargl <kargl@gcc.gnu.org>
Sandra Loosemore <sandra@codesourcery.com>
PR fortran/103287
gcc/fortran/
* interface.c (argument_rank_mismatch): Replace incorrect assertion
with return.
gcc/testsuite/
* gfortran.dg/c-interop/pr103287-1.f90: new.
* gfortran.dg/c-interop/pr103287-2.f90: new.
H.J. Lu [Thu, 6 Jan 2022 02:04:21 +0000 (18:04 -0800)]
x86: Generate INT3 for __builtin_eh_return
Generate INT3 after indirect jmp in exception return for -fcf-protection
with -mharden-sls=indirect-jmp.
gcc/
PR target/103925
* config/i386/i386.c (ix86_output_indirect_function_return):
Generate INT3 after indirect jmp for -mharden-sls=indirect-jmp.
gcc/testsuite/
PR target/103925
* gcc.target/i386/harden-sls-6.c: New test.
H.J. Lu [Thu, 6 Jan 2022 00:33:16 +0000 (16:33 -0800)]
x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
Indirect branch also includes indirect call instructions. Rename
-harden-sls=indirect-branch to -harden-sls=indirect-jmp to match its
intended behavior.
PR target/102952
* config/i386/i386-opts.h (harden_sls): Replace
harden_sls_indirect_branch with harden_sls_indirect_jmp.
* config/i386/i386.c (ix86_output_jmp_thunk_or_indirect):
Likewise.
(ix86_output_indirect_jmp): Likewise.
(ix86_output_call_insn): Likewise.
* config/i386/i386.opt: Replace indirect-branch with
indirect-jmp. Replace harden_sls_indirect_branch with
harden_sls_indirect_jmp.
* doc/invoke.texi (-harden-sls=): Replace indirect-branch with
indirect-jmp.
Ian Lance Taylor [Thu, 6 Jan 2022 04:57:14 +0000 (20:57 -0800)]
compiler: permit converting unnamed types when ignoring struct tags
Test case is https://golang.org/cl/375796.
Fixes golang/go#50439
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/375797
Uros Bizjak [Thu, 6 Jan 2022 18:59:49 +0000 (19:59 +0100)]
i386: Improve HImode interunit moves
Currently, the compiler moves HImode values between GPR and XMM registers with:
%vpinsrw\t{$0, %k1, %d0|%d0, %k1, 0}
%vpextrw\t{$0, %1, %k0|%k0, %1, 0}
but it could use slightly faster and shorter:
%vmovd\t{%k1, %0|%0, %k1}
%vmovd\t{%1, %k0|%k0, %1}
2022-01-06 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
* config/i386/i386.c (ix86_output_ssemov) <MODE_DI>:
Add %q modifier for operands in general registers.
<MODE_SI>: Add %q modifier for operands in general registers.
* config/i386/i386.md (*movhi_internal): Change type attribute of
xmm-gpr interunit alternatives 9,10 to ssemov and mode attribute
to SImode for non-avx512fp16 targets.
(*movhf_internal): Ditto for xmm-gpr interunit alternatives 6,8.
* config/i386/mmx.md (*movv2qi_internal):
Ditto for xmm-gpr interunit alternatives 8,9.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102811-2.c (dg-final):
Update scan-assembler-times directives.
* gcc.target/i386/sse2-float16-2.c (dg-final):
Update scan-assembler directives.
Bob Duff [Fri, 10 Dec 2021 11:01:22 +0000 (06:01 -0500)]
[Ada] Warn on subtype declaration of null range
gcc/ada/
* sem_res.adb (Resolve_Range): Warn on null range, unless we are
inside a generic unit or an instance thereof.
* sem_ch3.adb (Analyze_Subtype_Indication): Minor: avoid double
negative.
Piotr Trojanek [Fri, 10 Dec 2021 15:54:03 +0000 (16:54 +0100)]
[Ada] Remove unnecessary declare block
gcc/ada/
* errout.adb (Adjust_Name_Case): Remove unnecessary declare
block.
Yannick Moy [Wed, 8 Dec 2021 14:09:25 +0000 (09:09 -0500)]
[Ada] Proof of System.Generic_Array_Operations at silver level
gcc/ada/
* libgnat/a-ngcoar.adb: Add pragma to ignore assertions in
instance.
* libgnat/a-ngrear.adb: Likewise.
* libgnat/s-gearop.adb: Prove implementation is free of runtime
errors.
* libgnat/s-gearop.ads: Add contracts to protect against runtime
errors in the generic part.
Piotr Trojanek [Wed, 8 Dec 2021 15:00:05 +0000 (16:00 +0100)]
[Ada] Simplify traversal for removing warnings from dead code
gcc/ada/
* errout.adb (Remove_Warning_Messages): Use traversal procedure
instead of traversal function, since we discard status of each
step anyway.
Piotr Trojanek [Thu, 9 Dec 2021 11:57:35 +0000 (12:57 +0100)]
[Ada] Remove a locally handled exception
gcc/ada/
* exp_ch4.adb (Expand_Concatenate): There is no reason for using
declaring, raising and catching an exception; a simple return
statement is enough.
Piotr Trojanek [Tue, 7 Dec 2021 15:58:59 +0000 (16:58 +0100)]
[Ada] Move messages on division by zero to the right operand
gcc/ada/
* sem_eval.adb (Eval_Arithmetic_Op): Add Loc parameter to all
calls to Apply_Compile_Time_Constraint_Error related to division
by zero.
Piotr Trojanek [Wed, 8 Dec 2021 14:19:49 +0000 (15:19 +0100)]
[Ada] Remove unnecessary guards for non-empty lists
gcc/ada/
* errout.adb (Remove_Warning_Messages): Remove unnecessary guard.
* exp_util.adb (Kill_Dead_Code): Likewise.
* par_sco.adb (Traverse_Declarations_Or_Statements): Likewise.
* sem_ch3.adb (Build_Derived_Record_Type): Likewise.
* sem_ch4.adb (Traverse_Interfaces): Likewise.
* sem_eval.adb (Traverse_Interfaces): Likewise.
* sem_util.adb (Collect_Interfaces): Likewise.
(Has_Non_Null_Statements, Side_Effect_Free_Statements):
Likewise; turn into WHILE loops, for consistency.
Etienne Servais [Thu, 9 Dec 2021 16:54:21 +0000 (17:54 +0100)]
[Ada] Fix typo on compatibility
gcc/ada/
* sem_type.adb (Full_View_Covers): Fix typo.
Eric Botcazou [Thu, 9 Dec 2021 12:34:09 +0000 (13:34 +0100)]
[Ada] Fix regression in freezing code for instantiations
gcc/ada/
* sem_ch12.adb (Insert_Freeze_Node_For_Instance): When going to
the outer level, do not jump over following instantiations in
the list.
Piotr Trojanek [Tue, 7 Dec 2021 19:16:02 +0000 (20:16 +0100)]
[Ada] Remove unreferenced Warn_On_Instance
gcc/ada/
* err_vars.ads (Warn_On_Instance): Remove; it was a relic from
the previous handling of warning in instances that was removed
decades ago.
Piotr Trojanek [Tue, 7 Dec 2021 16:00:01 +0000 (17:00 +0100)]
[Ada] Fix style in comments about warning messages
gcc/ada/
* errout.adb (Error_Msg_Internal): Reorder words.
* erroutc.ads (Is_Warning_Msg): Add closing paren.
* sem_util.adb (Compile_Time_Constraint_Error): Fix casing.
Piotr Trojanek [Tue, 7 Dec 2021 19:13:15 +0000 (20:13 +0100)]
[Ada] Simplify type conversions in source pointer arithmetic
gcc/ada/
* sem_res.adb (Resolve_String_Literal): Simplify pointer
arithmetic.
Piotr Trojanek [Tue, 7 Dec 2021 19:12:49 +0000 (20:12 +0100)]
[Ada] Refactor repeated implicit conversion from Char_Code to Uint
gcc/ada/
* sem_res.adb (Resolve_String_Literal): Avoid unnecessary
conversions inside "<" and ">" bodies.
Piotr Trojanek [Tue, 7 Dec 2021 09:32:53 +0000 (10:32 +0100)]
[Ada] Fix style in calls to Compile_Time_Constraint_Error
gcc/ada/
* checks.adb (Null_Exclusion_Static_Checks,
Selected_Range_Checks): Fix style.
Eric Botcazou [Tue, 7 Dec 2021 21:10:53 +0000 (22:10 +0100)]
[Ada] Fix spurious error on instantiation with Text_IO name
gcc/ada/
* sem_ch8.adb (Analyze_Package_Renaming): Do not check for Text_IO
special units when the name of the renaming is a generic instance,
which is the case for package instantiations in the GNAT model.
Steve Baird [Mon, 6 Dec 2021 21:42:51 +0000 (13:42 -0800)]
[Ada] Avoid building malformed component constraints
gcc/ada/
* sem_util.adb (Build_Discriminant_Reference): In the unexpected
case where we previously would fail an assertion, we instead
revert to the old behavior.
Steve Baird [Fri, 3 Dec 2021 01:04:15 +0000 (17:04 -0800)]
[Ada] Avoid building malformed component constraints
gcc/ada/
* sem_util.adb (Build_Actual_Subtype_Of_Component): Define a new
local function, Build_Discriminant_Reference, and call it in
each of the three cases where Make_Selected_Component was
previously being called to construct a discriminant reference (2
in Build_Actual_Array_Constraint and 1 in
Build_Actual_Record_Constraint). Instead of unconditionally
using the passed-in object name as the prefix for the new
selected component node, this new function checks to see if
perhaps a prefix of that name should be used instead.
Etienne Servais [Fri, 3 Dec 2021 14:13:07 +0000 (15:13 +0100)]
[Ada] Fix typo in comments found running aspell
gcc/ada/
* atree.adb: Fix typo.
* einfo.ads: Likewise.
* exp_aggr.adb: Likewise.
* exp_ch6.adb: Likewise.
* exp_ch7.adb: Likewise.
* exp_ch9.adb: Likewise.
* exp_prag.adb: Likewise.
* exp_unst.adb: Likewise.
* exp_unst.ads: Likewise.
* exp_util.adb: Likewise.
* par-endh.adb: Likewise.
* par.adb: Likewise.
* restrict.adb: Likewise.
* sem.ads: Likewise.
* sem_ch4.adb: Likewise.
* sem_ch5.adb: Likewise.
* sem_ch6.adb: Likewise.
* sem_ch8.adb: Likewise.
* sem_ch12.adb: Likewise.
* sem_ch13.adb: Likewise.
* sem_dim.adb: Likewise.
* sem_elab.adb: Likewise.
* sem_prag.adb: Likewise.
* sem_res.adb: Likewise.
* sem_util.adb: Likewise.
* sem_util.ads: Likewise.
* sinfo.ads: Likewise.
* sprint.adb: Likewise.
* urealp.adb: Likewise.
Justin Squirek [Tue, 30 Nov 2021 23:40:40 +0000 (23:40 +0000)]
[Ada] Spurious error when using current instance of type
gcc/ada/
* exp_ch3.adb (Build_Assignment): Replace current instance of
type with Init_Proc formal.
* sem_attr.adb (OK_Self_Reference): Handle recognition of
Current_Instance to detect certain expansion.
* sem_ch4.adb (Analyze_One_Call): Set actual's type when the
actual in question is a current instance and its corresponding
formal is an incomplete type.
* sem_util.adb (Is_Current_Instance): Add check for incomplete
views and add comment.
Bob Duff [Fri, 3 Dec 2021 17:01:14 +0000 (12:01 -0500)]
[Ada] New restriction No_Tagged_Type_Registration
gcc/ada/
* libgnat/s-rident.ads (No_Tagged_Type_Registration): New
restriction identifier.
* restrict.ads (Implementation_Restriction): Add restriction.
* exp_ch7.adb (Process_Declarations): Suppress
tagged-type-related finalization actions if the restriction is
active. Call RTE_Available last.
* exp_disp.adb (Make_DT): Likewise.
* exp_util.adb (Requires_Cleanup_Actions): Return False for a
tagged type declaration if No_Tagged_Type_Registration is
active.
* sem_attr.adb (Check_Stream_Attribute): Check restriction
No_Tagged_Type_Registration.
* libgnat/a-except.ads (Null_Occurrence): Minor: Initialize, to
avoid stopping at a warning in gdb.
* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst:
Document new restriction.
* gnat_rm.texi: Regenerate.
Piotr Trojanek [Thu, 2 Dec 2021 14:30:36 +0000 (15:30 +0100)]
[Ada] Remove duplicates of empty strings
gcc/ada/
* par-ch4.adb (P_Simple_Expression): Reuse Null_String_Id.
* prep.adb (Parse_Def_File): Likewise; remove Empty_String.
Eric Botcazou [Fri, 3 Dec 2021 18:43:23 +0000 (19:43 +0100)]
[Ada] Rename Any_Access into Universal_Access
gcc/ada/
* stand.ads (Any_Access): Delete.
(Universal_Access): New entity.
* einfo.ads: Remove obsolete reference to Any_Access.
* gen_il-gen-gen_entities.adb: Likewise.
* cstand.adb (Create_Standard): Do not create Any_Access and create
Universal_Access as a full type instead.
* errout.adb (Set_Msg_Insertion_Type_Reference): Do not deal with
Any_Access and deal with Universal_Access instead.
* sem_ch3.adb (Analyze_Object_Declaration): Replace Any_Access with
Universal_Access.
* sem_ch4.adb (Analyze_Null): Likewise.
(Find_Non_Universal_Interpretations): Likewise.
(Find_Equality_Types.Try_One_Interp): Likewise and avoid shadowing
by renaming a local variable of the same name.
* sem_res.adb (Make_Call_Into_Operato): Likewise.
(Resolve_Equality_Op): Likewise.
* sem_type.adb (Covers): Likewise.
(Specific_Type): Likewise.
Piotr Trojanek [Fri, 3 Dec 2021 14:52:34 +0000 (15:52 +0100)]
[Ada] Suppress spurious CodePeer check on generic actual subprogram
gcc/ada/
* treepr.adb (Destroy): Prevent spurious check from CodePeer.
Yannick Moy [Fri, 3 Dec 2021 15:23:01 +0000 (16:23 +0100)]
[Ada] Justify false positive message from CodePeer analysis of GNAT
gcc/ada/
* libgnat/s-exponu.adb (Exponu): Add annotation.
Justin Squirek [Mon, 22 Nov 2021 12:53:56 +0000 (12:53 +0000)]
[Ada] Removal of technical debt
gcc/ada/
* exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Add comments
regarding special handling of components which depend on
discriminants.
* exp_dist.adb (Build_From_Any_Function): Add Real_Rep actual
for calls to Has_Stream_Attribute_Definition.
(Build_To_Any_Function): Likewise.
(Build_TypeCode_Function): Likewise.
* freeze.adb (Freeze_Entity): Add missing comment for Test_E.
* libgnat/s-utf_32.adb: Remove disabled warning comments and
temporarily inserted pragma warnings. Remove very old (2006 and
2012) comments about bootstrapping older versions.
* par.adb (P_Identifier): Add new parameter Force_Msg.
* par-ch2.adb (P_Identifier): Restructure and clean up function.
* par-ch3.adb (P_Defining_Identifier): Remove code duplication
for parsing identifiers.
* sem_attr.adb (Stream_Attribute_Available): Add missing
comments and add Real_Rep actual for calls to
Has_Stream_Attribute_Definition.
* sem_cat.adb (Has_Read_Write_Attribute): Add Real_Rep actual
for calls to Has_Stream_Attribute_Definition.
(Has_Stream_Attribute_Definition): Remove local Real_Rep and fix
recursive calls. Add default value for Real_Rep.
* sem_cat.ads (Has_Stream_Attribute_Definition): Add new out
parameter "Real_Rep".
* sem_type.adb (Add_Entry): Add condition to avoid passing
non-function calls to Function_Interp_Has_Abstract_Op.
(Function_Interp_Has_Abstract_Op): Add missing comments and
remove check for Is_Overloadable.
* sem_util.adb (Derivation_Too_Early_To_Inherit): Remove
duplicated code.
Javier Miranda [Mon, 29 Nov 2021 18:12:47 +0000 (18:12 +0000)]
[Ada] Crash in class-wide pre/postconditions
gcc/ada/
* contracts.adb (Restore_Original_Selected_Component): New
subprogram that traverses a preanalyzed expression searching for
dispatching calls to functions whose original node was a
selected component, and replacing them with their original node.
This functionality is required because the preanalyis of
dispatching calls using the Object.Operation notation transforms
such calls, and we need the original condition to properly
inherit and extend the condition expression on tagged type
derivations. This functionality was previously provided by the
routine Install_Original_Selected_Component (as part of
inheriting conditions); now it is performed as part of the
preanalysis of the condition, thus avoiding repeatedly
installing and restoring such nodes.
(Install_Original_Selected_Component): Removed.
(Restore_Dispatching_Calls): Removed.
Piotr Trojanek [Fri, 3 Dec 2021 12:23:36 +0000 (13:23 +0100)]
[Ada] Simplify repeated calls in printing of GNAT AST
gcc/ada/
* treepr.adb (Visit_Node): Simplify repeated call to
Next_Entity.
Piotr Trojanek [Thu, 2 Dec 2021 20:49:35 +0000 (21:49 +0100)]
[Ada] Simplify GNAT AST printing with simple GNAT hash table
gcc/ada/
* treepr.ads (Treepr, Print_Tree_List, Print_Tree_Elist): Fix
style in comments.
* treepr.adb (Serial_Numbers): Hash table instance.
(Hash): Hashing routine.
(Print_Field): Fix style.
(Print_Init): Adapt to simple hash table.
(Print_Term): Likewise.
(Serial_Numbers): Likewise.
(Set_Serial_Number): Likewise.
Yannick Moy [Thu, 2 Dec 2021 14:42:32 +0000 (15:42 +0100)]
[Ada] Proof of runtime unit for non-binary modular exponentiation
gcc/ada/
* libgnat/s-expmod.adb: Mark in SPARK. Add ghost code for proof.
* libgnat/s-expmod.ads: Mark in SPARK. Add ghost specifications.
Yannick Moy [Thu, 2 Dec 2021 09:55:04 +0000 (10:55 +0100)]
[Ada] Proof of runtime units for binary modular exponentiation
gcc/ada/
* libgnat/s-explllu.ads: Mark in SPARK.
* libgnat/s-expllu.ads: Mark in SPARK.
* libgnat/s-exponu.adb: Add loop invariants and needed
assertions.
* libgnat/s-exponu.ads: Add functional contract.
* libgnat/s-expuns.ads: Mark in SPARK.
Kito Cheng [Fri, 3 Dec 2021 15:50:54 +0000 (23:50 +0800)]
RISC-V: Minimal support of vector extensions
gcc/ChangeLog:
* common/config/riscv/riscv-common.c (riscv_implied_info): Add
vector extensions.
(riscv_ext_version_table): Add version info for vector extensions.
(riscv_ext_flag_table): Add option mask for vector extensions.
* config/riscv/riscv-opts.h (MASK_VECTOR_EEW_32): New.
(MASK_VECTOR_EEW_64): New.
(MASK_VECTOR_EEW_FP_32): New.
(MASK_VECTOR_EEW_FP_64): New.
(MASK_ZVL32B): New.
(MASK_ZVL64B): New.
(MASK_ZVL128B): New.
(MASK_ZVL256B): New.
(MASK_ZVL512B): New.
(MASK_ZVL1024B): New.
(MASK_ZVL2048B): New.
(MASK_ZVL4096B): New.
(MASK_ZVL8192B): New.
(MASK_ZVL16384B): New.
(MASK_ZVL32768B): New.
(MASK_ZVL65536B): New.
(TARGET_ZVL32B): New.
(TARGET_ZVL64B): New.
(TARGET_ZVL128B): New.
(TARGET_ZVL256B): New.
(TARGET_ZVL512B): New.
(TARGET_ZVL1024B): New.
(TARGET_ZVL2048B): New.
(TARGET_ZVL4096B): New.
(TARGET_ZVL8192B): New.
(TARGET_ZVL16384B): New.
(TARGET_ZVL32768B): New.
(TARGET_ZVL65536B): New.
* config/riscv/riscv.opt (Mask(VECTOR)): New.
(riscv_vector_eew_flags): New.
(riscv_zvl_flags): New.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/predef-14.c: New.
* gcc.target/riscv/predef-15.c: Ditto.
* gcc.target/riscv/predef-16.c: Ditto.
Kito Cheng [Fri, 3 Dec 2021 15:50:53 +0000 (23:50 +0800)]
RISC-V: Allow extension name contain digit
RISC-V spec only allow alphabetical name for extension before, however
vector extension add several extension named with digits, so we try to
extend the naming rule.
Ref:
https://github.com/riscv/riscv-isa-manual/pull/718
gcc/ChangeLog:
* common/config/riscv/riscv-common.c
(riscv_subset_list::parse_multiletter_ext): Allow ext. name has
digit.
Patrick Palka [Thu, 6 Jan 2022 15:42:50 +0000 (10:42 -0500)]
c++: Add testcase for recently fixed PR [PR69681]
Fixed ever since r12-6188.
PR c++/69681
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-compare2.C: New test.
Pavel I. Kryukov [Thu, 6 Jan 2022 12:32:36 +0000 (12:32 +0000)]
libstdc++: Add self-merge check to std::forward_list::merge [PR103853]
This implements the proposed resolution of LWG 3088, so that x.merge(x)
is a no-op, consistent with std::list::merge.
Signed-off-by: Pavel I. Kryukov <pavel.kryukov@phystech.edu>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/103853
* include/bits/forward_list.tcc (forward_list::merge): Check for
self-merge.
* testsuite/23_containers/forward_list/operations/merge.cc: New test.
Jonathan Wakely [Thu, 6 Jan 2022 11:11:52 +0000 (11:11 +0000)]
libstdc++: Adjust friend declarations to work with Clang
I think this code is valid but it fails with Clang, possibly due to
https://llvm.org/PR38882
Qualifying the names makes it work for all compilers.
libstdc++-v3/ChangeLog:
* include/bits/regex.h (basic_regex, match_results): Qualify
name in friend declaration, to work around Clang bug.
Jonathan Wakely [Thu, 6 Jan 2022 11:10:31 +0000 (11:10 +0000)]
libstdc++: Increase timeout for pthread7-rope.cc test
This test spawns thousands of threads and so times out if the tests are
run with a low timeout value and the machine is busy.
libstdc++-v3/ChangeLog:
* testsuite/ext/rope/pthread7-rope.cc: Add dg-timeout-factor.
Jonathan Wakely [Wed, 5 Jan 2022 16:25:47 +0000 (16:25 +0000)]
libstdc++: Do not use std::isdigit in <charconv> [PR103911]
This avoids a potential race condition if std::setlocale is used
concurrently with std::from_chars.
libstdc++-v3/ChangeLog:
PR libstdc++/103911
* include/std/charconv (__from_chars_alpha_to_num): Return
char instead of unsigned char. Change invalid return value to
127 instead of using numeric trait.
(__from_chars_alnum): Fix comment. Do not use std::isdigit.
Change type of variable to char.
Jakub Jelinek [Thu, 6 Jan 2022 14:32:57 +0000 (15:32 +0100)]
expr: Workaround profiledbootstrap uninit false positive [PR103899]
The threader changes resulted in a false positive warning during
profiledbootstrap:
In file included from ../../gcc/expr.c:26:
../../gcc/tree.h: In function ‘rtx_def* expand_expr_real_1(tree, rtx, machine_mode, expand_modifier, rtx_def**, bool)’:
../../gcc/tree.h:244:56: error: ‘context’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
244 | #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code)
| ^~~~
../../gcc/expr.c:10343:8: note: ‘context’ was declared here
10343 | tree context;
| ^~~~~~~
While it will be nice to improve the uninit pass to handle it if possible
(I do not want to close the PR until that is done), doing profiledbootstrap
is a common thing to do, so a workaround is handy, especially as in this
case when the workaround seems to be the right thing to do, as it moves
a variable declaration to the only place where it is set and used and avoids
the weird and for uninit asking
tree context;
...
if (exp)
context = ...;
gcc_assert (!exp
|| use (context)
|| use_some_more (context));
2022-01-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103899
* expr.c (expand_expr_real_1): Add a workaround for bogus uninit
warning by moving context variable to the only spot where it is used
and moving gcc_assert into if body.
Olivier Hainque [Thu, 16 Dec 2021 13:50:25 +0000 (13:50 +0000)]
Add VxWworks fixincludes hack, don't expect yvals.h from gcc
yvals.h on VxWorks expects the toolchain to provide its own
version of the header, which we don't do. Arrange to fallback
on the common system definitions instead.
2021-12-16 Olivier Hainque <hainque@adacore.com>
fixincludes/
* inclhack.def (vxworks_next_yvals): New hack.
* tests/base/yvals.h: New expected test result.
* fixincl.x: Regenerate.
Jakub Jelinek [Thu, 6 Jan 2022 08:29:34 +0000 (09:29 +0100)]
ifcvt: Check for asm goto at the end of then_bb/else_bb in ifcvt [PR103908]
On the following testcase, RTL ifcvt sees then_bb
(note 7 6 8 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
(insn 8 7 9 3 (set (mem/c:SI (symbol_ref:DI ("b") [flags 0x2] <var_decl 0x7fdccf5b0cf0 b>) [1 b+0 S4 A32])
(const_int 1 [0x1])) "pr103908.c":6:7 81 {*movsi_internal}
(nil))
(jump_insn 9 8 13 3 (parallel [
(asm_operands/v ("# insn 1") ("") 0 []
[]
[
(label_ref:DI 21)
] pr103908.c:7)
(clobber (reg:CC 17 flags))
]) "pr103908.c":7:5 -1
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))
-> 21)
and similarly else_bb (just with a different asm_operands template).
It checks that those basic blocks have a single successor and
uses last_active_insn which intentionally skips over JUMP_INSNs, sees
both basic blocks contain the same set and merges them (or if the
sets are different, attempts some other noce optimization).
But we can't assume that the jump, even when it has only a single successor,
has no side-effects.
The following patch fixes it by punting if test_bb ends with a JUMP_INSN
that isn't onlyjump_p.
2022-01-06 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/103908
* ifcvt.c (bb_valid_for_noce_process_p): Punt on bbs ending with
asm goto.
* gcc.target/i386/pr103908.c: New test.
Marek Polacek [Wed, 5 Jan 2022 22:53:30 +0000 (17:53 -0500)]
Avoid more -Wformat-diag warnings [PR103758]
Let's use "%<x>, %<y>, or %<z>" rather than "[x|y|z]" as in the rest of
our codebase.
PR c++/103758
gcc/c-family/ChangeLog:
* c-pragma.c (handle_pragma_scalar_storage_order): Use %< %> in
diagnostic messages.
(handle_pragma_diagnostic): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/sso-6.c: Update dg-warning.
GCC Administrator [Thu, 6 Jan 2022 00:16:32 +0000 (00:16 +0000)]
Daily bump.
Bill Schmidt [Wed, 5 Jan 2022 22:53:29 +0000 (16:53 -0600)]
rs6000: Skip overload instances with uninitialized fntype (PR103622)
2022-01-05 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
PR target/103622
* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Skip over instances with undefined function types.
Andrew Pinski [Wed, 5 Jan 2022 22:00:07 +0000 (22:00 +0000)]
Fix target/103910: missing GTY on x86_mfence causing PCH usage to ICE
With -O3 -march=opteron, a mfence builtin is added after the loop
to say the nontemporal stores are no longer needed. This all good
without precompiled headers as the function decl that is referneced
by x86_mfence is referenced in another variable but with precompiled
headers, x86_mfence is all messed up and the decl was GC'ed away.
This fixes the problem by marking x86_mfence as GTY to save/restore
during precompiled headers just like most other variables in
the header file.
Committed as obvious after a bootstrap/test on x86_64-linux-gnu.
gcc/ChangeLog:
PR target/103910
* config/i386/i386.h (x86_mfence): Mark with GTY.
Uros Bizjak [Wed, 5 Jan 2022 22:16:34 +0000 (23:16 +0100)]
i386: Introduce V2QImode minmax, abs and uavgv2hi3_ceil [PR103861]
Add V2QImode minmax, abs and uavxv2qi3_ceil operations with SSE registers.
2022-01-05 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
PR target/103861
* config/i386/mmx.md (VI_16_32): New mode iterator.
(VI1_16_32): Ditto.
(mmxvecsize): Handle V2QI mode.
(<smaxmin:code><mode>3): Rename from <smaxmin:code>v4qi3.
Use VI1_16_32 mode iterator.
(<umaxmin:code><mode>3): Rename from <umaxmin:code>v4qi3.
Use VI1_16_32 mode iterator.
(abs<mode>2): Use VI_16_32 mode iterator.
(uavgv2qi3_ceil): New insn pattern.
gcc/testsuite/ChangeLog:
PR target/103861
* gcc.target/i386/pr103861-3.c: New test.
* g++.dg/vect/slp-pr98855.cc (dg-final): Check that
no vectorization using SLP was performed.
François Dumont [Mon, 20 Jan 2020 07:17:09 +0000 (08:17 +0100)]
libstdc++: Optimize operations on small size hashtable [PR 68303]
When hasher is identified as slow and the number of elements is limited in the
container use a brute-force loop on those elements to look for a given key using
the key_equal functor. For the moment the default threshold to consider the
container as small is 20.
libstdc++-v3/ChangeLog:
PR libstdc++/68303
* include/bits/hashtable_policy.h
(_Hashtable_hash_traits<_Hash>): New.
(_Hash_code_base<>::_M_hash_code(const _Hash_node_value<>&)): New.
(_Hashtable_base<>::_M_key_equals): New.
(_Hashtable_base<>::_M_equals): Use latter.
(_Hashtable_base<>::_M_key_equals_tr): New.
(_Hashtable_base<>::_M_equals_tr): Use latter.
* include/bits/hashtable.h
(_Hashtable<>::__small_size_threshold()): New, use _Hashtable_hash_traits.
(_Hashtable<>::find): Loop through elements to look for key if size is lower
than __small_size_threshold().
(_Hashtable<>::_M_emplace(true_type, _Args&&...)): Likewise.
(_Hashtable<>::_M_insert_unique(_Kt&&, _Args&&, const _NodeGenerator&)): Likewise.
(_Hashtable<>::_M_compute_hash_code(const_iterator, const key_type&)): New.
(_Hashtable<>::_M_emplace(const_iterator, false_type, _Args&&...)): Use latter.
(_Hashtable<>::_M_find_before_node(const key_type&)): New.
(_Hashtable<>::_M_erase(true_type, const key_type&)): Use latter.
(_Hashtable<>::_M_erase(false_type, const key_type&)): Likewise.
* src/c++11/hashtable_c++0x.cc: Include <bits/functional_hash.h>.
* testsuite/util/testsuite_performance.h
(report_performance): Use 9 width to display memory.
* testsuite/performance/23_containers/insert_erase/unordered_small_size.cc:
New performance test case.
Martin Sebor [Wed, 5 Jan 2022 20:28:37 +0000 (13:28 -0700)]
Avoid -Wformat-diag.
gcc/ChangeLog:
* gimple-ssa-warn-access.cc (pass_waccess::maybe_warn_memmodel): Use
%qs to avoid -Wformat-diag.
Uros Bizjak [Wed, 5 Jan 2022 19:08:15 +0000 (20:08 +0100)]
i386: Fix type of one_cmplv2qi2 alternatives 1,2 [PR103915]
2022-01-05 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
PR target/103915
* config/i386/mmx.md (one_cmplv2qi2): Change
alternatives 1,2 type from sselog to sselog1.
gcc/testsuite/ChangeLog:
PR target/103915
* gcc.target/i386/pr103915.c: New test.
Uros Bizjak [Wed, 5 Jan 2022 19:06:03 +0000 (20:06 +0100)]
i386: Fix expand_vec_perm_pshufb for narrow modes [PR103905]
2022-01-05 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
PR target/103905
* config/i386/i386-expand.c (expand_vec_perm_pshufb): Fix number of
narrow mode remapped elements for !one_operand_p case.
gcc/testsuite/ChangeLog:
PR target/103905
* gcc.target/i386/pr103905.c: New test.
Sandra Loosemore [Wed, 5 Jan 2022 02:18:13 +0000 (18:18 -0800)]
Fortran: Fix ICE caused by missing error for untyped symbol [PR103258]
The bit on a symbol to mark that it had already been diagnosed as
lacking a type was getting set even when the error was suppressed or
discarded, specifically when doing early resolution on a character
length expression to see if it can be constant-folded. Explicitly
suppress errors before doing that, then check whether they are
suppressed before setting the bit.
2022-01-04 Sandra Loosemore <sandra@codesourcery.com>
PR fortran/103258
gcc/fortran/
* decl.c (gfc_match_char_spec): Suppress errors around call
to gfc_reduce_init_expr.
* error.c (gfc_query_suppress_errors): New.
* gfortran.h (gfc_query_suppress_errors): Declare.
* symbol.c (gfc_set_default_type): Check gfc_query_suppress_errors.
gcc/testsuite/
* gfortran.dg/pr103258.f90: New.
Jonathan Wakely [Wed, 5 Jan 2022 15:16:33 +0000 (15:16 +0000)]
libstdc++: Fix overconstrained std::string constructor [PR103919]
The C++17 basic_string(const T&, size_t, size_t) constructor is
overconstrained, so it can't be used for a NTBS and a temporary string
gets constructed (potentially allocating memory). There is no
corresponding constructor taking an NTBS, so no need to disambiguate
from it. Accepting an NTBS avoids the temporary (and potential
allocation) and is what the standard requires.
libstdc++-v3/ChangeLog:
PR libstdc++/103919
* include/bits/basic_string.h (basic_string(const T&, size_t, size_t)):
Relax constraints on string_view parameter.
* include/bits/cow_string.h (basic_string(const T&, size_t, size_t)):
Likewise.
* testsuite/21_strings/basic_string/cons/char/103919.cc: New test.
Jonathan Wakely [Wed, 5 Jan 2022 14:25:37 +0000 (14:25 +0000)]
libstdc++: Implement P1328 "Making std::type_info::operator== constexpr"
This feature is present in the C++23 draft.
With Jakub's recent front-end changes we can implement constexpr
equality by comparing the addresses of std::type_info objects. We do not
need string comparisons, because for constant evaluation cases we know
we aren't dealing with std::type_info objects defined in other
translation units.
The ARM EABI requires that the type_info::operator== function can be
defined out-of-line (and suggests that should be the default), but to be
a constexpr function it must be defined inline (at least for C++23
mode). To meet these conflicting requirements we make the inline version
of operator== call a new __equal function when called at runtime. That
is an alias for the non-inline definition of operator== defined in
libsupc++.
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export new symbol for
ARM EABI.
* include/bits/c++config (_GLIBCXX23_CONSTEXPR): Define.
* include/std/version (__cpp_lib_constexpr_typeinfo): Define.
* libsupc++/tinfo.cc: Add #error to ensure non-inline definition
is emitted.
(type_info::__equal): Define alias symbol.
* libsupc++/typeinfo (type_info::before): Combine different
implementations into one.
(type_info::operator==): Likewise. Use address equality for
constant evaluation. Call __equal for targets that require the
definition to be non-inline.
* testsuite/18_support/type_info/constexpr.cc: New test.
Jonathan Wakely [Wed, 22 Sep 2021 12:56:21 +0000 (13:56 +0100)]
libstdc++: Improvements to standard error category objects (part deux)
In r12-3860 the error categories in <system_error> were made final and
immortal, but I missed the categories for <future> and <ios>. This makes
the same changes to those.
libstdc++-v3/ChangeLog:
* src/c++11/cxx11-ios_failure.cc (io_error_category): Define
class and virtual functions as 'final'.
(io_category_instance): Use constinit union to make the object
immortal.
* src/c++11/future.cc (future_error_category): Define class and
virtual functions as 'final'.
(future_category_instance): Use constinit union.
Jonathan Wakely [Wed, 5 Jan 2022 14:06:43 +0000 (14:06 +0000)]
libstdc++: Fix std::error_code pretty printer for versioned namespace
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Strip
versioned namespace from the type name that is printed.
Jonathan Wakely [Wed, 5 Jan 2022 11:16:06 +0000 (11:16 +0000)]
libstdc++: Add pretty printer for std::regex internals
This helps visualize the NFA states in a std::regex. It probably isn't
very useful for users, but helps when working on the implementation.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdRegexStatePrinter): New
printer for std::regex NFA states.
Jonathan Wakely [Wed, 5 Jan 2022 11:14:02 +0000 (11:14 +0000)]
libstdc++: Fix comments in std::forward_list tests
libstdc++-v3/ChangeLog:
* testsuite/23_containers/forward_list/operations/1.cc: Fill in
placeholders in comments.
* testsuite/23_containers/forward_list/operations/2.cc:
Likewise.
* testsuite/23_containers/forward_list/operations/3.cc:
Likewise.
* testsuite/23_containers/forward_list/operations/4.cc:
Likewise.
* testsuite/23_containers/forward_list/operations/5.cc:
Likewise.
* testsuite/23_containers/forward_list/operations/6.cc:
Likewise.
* testsuite/23_containers/forward_list/operations/7.cc:
Likewise.
Jonathan Wakely [Tue, 4 Jan 2022 21:57:16 +0000 (21:57 +0000)]
libstdc++: Avoid -Wzero-as-null-pointer-constant warning [PR103848]
libstdc++-v3/ChangeLog:
PR libstdc++/103848
* include/bits/stl_deque.h (operator-): Do not use 0 as null
pointer constant.
Jonathan Wakely [Tue, 4 Jan 2022 16:39:01 +0000 (16:39 +0000)]
libstdc++: Simplify std::allocator_traits<allocator<void>>::construct
We don't need a preprocessor condition to decide whether to use
placement new or std::construct_at, because std::_Construct already does
that.
libstdc++-v3/ChangeLog:
* include/bits/alloc_traits.h (allocator_traits<allocator<void>>):
Use std::_Construct for construct.
Jonathan Wakely [Tue, 4 Jan 2022 15:54:16 +0000 (15:54 +0000)]
libstdc++: Fix example preprocessor command in FAQ [PR103877]
libstdc++-v3/ChangeLog:
PR libstdc++/103877
* doc/xml/faq.xml: Add '-x c++' to preprocessor command.
* doc/html/faq.html: Regenerate.
Jonathan Wakely [Fri, 17 Dec 2021 18:04:28 +0000 (18:04 +0000)]
libstdc++: Reduce template instantiations in <regex>
This moves the last two template parameters of __regex_algo_impl to be
runtime function parameters instead, so that we don't need four
different instantiations for the possible ways to call it. Most of the
function (and what it instantiates) is the same in all cases, so making
them compile-time choices doesn't really have much benefit.
Use 'if constexpr' for conditions that check template parameters, so
that when we do depend on a compile-time condition we only instantiate
what we need to.
libstdc++-v3/ChangeLog:
* include/bits/regex.h (__regex_algo_impl): Change __policy and
__match_mode template parameters to be function parameters.
(regex_match, regex_search): Pass policy and match mode as
function arguments.
* include/bits/regex.tcc (__regex_algo_impl): Change template
parameters to function parameters.
* include/bits/regex_compiler.h (_RegexTranslatorBase): Use
'if constexpr' for conditions using template parameters.
(_RegexTranslator): Likewise.
* include/bits/regex_executor.tcc (_Executor::_M_handle_accept):
Likewise.
* testsuite/util/testsuite_regex.h (regex_match_debug)
(regex_search_debug): Move template arguments to function
arguments.
Jonathan Wakely [Fri, 17 Dec 2021 17:58:09 +0000 (17:58 +0000)]
libstdc++: Compare match_results for failed regex_match
The regex_match_debug testsuite helper doesn't compare the
std::match_results objects after a failed match, but it should do. The
standard says that the effects of a failed match on the match-results
are unspecified, except that [conditions testable by operator==]. So we
can check that the two sets of results compare equal even if the match
failed.
libstdc++-v3/ChangeLog:
* testsuite/util/testsuite_regex.h (regex_match_debug): Compare
results even if the match failed.
Jonathan Wakely [Thu, 16 Dec 2021 13:39:09 +0000 (13:39 +0000)]
libstdc++: Improve std::regex_error::what() strings
This replaces the vague "regex_error" for std::regex_error::what() with
a string that corresponds to the error_type enum passed to the
constructor. This allows us to remove many of the strings passed to
__throw_regex_error, because the default string is at least as good.
When a string argument to __throw_regex_error is kept it should add some
context-specific detail absent from the default string.
Also remove full stops (periods) from the end of those strings, to make
it easier to include them in logs and other output. I've left them
starting with an upper-case letter, which is consistent with strerror
output for (at least) Glibc, Solaris and BSD. I'm ambivalent whether
that's the right choice.
This also adds the missing noreturn attribute to __throw_regex_error.
libstdc++-v3/ChangeLog:
* include/bits/regex_compiler.tcc: Adjust all calls to
__throw_regex_error.
* include/bits/regex_error.h (__throw_regex_error): Add noreturn
attribute.
* include/bits/regex_scanner.tcc: Likewise.
* src/c++11/regex.cc (desc): New helper function.
(regex_error::regex_error(error_type)): Use desc to get a string
corresponding to the error code.