190996 Commits

Author SHA1 Message Date
Harald Anlauf
2e63128306 Fortran: reject invalid non-constant pointer initialization targets
gcc/fortran/ChangeLog:

	PR fortran/101762
	* expr.c (gfc_check_pointer_assign): For pointer initialization
	targets, check that subscripts and substring indices in
	specifications are constant expressions.

gcc/testsuite/ChangeLog:

	PR fortran/101762
	* gfortran.dg/pr101762.f90: New test.
2022-01-09 22:08:14 +01:00
Mikael Morin
c1c17a43e1 Fortran: Ignore KIND argument of a few more intrinsics. [PR103789]
After PR97896 for which some code was added to ignore the KIND argument
of the INDEX intrinsics, and PR87711 for which that was extended to LEN_TRIM
as well, this propagates it further to MASKL, MASKR, SCAN and VERIFY.

	PR fortran/103789

gcc/fortran/ChangeLog:

	* trans-array.c (arg_evaluated_for_scalarization): Add MASKL, MASKR,
	SCAN and VERIFY to the list of intrinsics whose KIND argument is to be
	ignored.

gcc/testsuite/ChangeLog:

	* gfortran.dg/maskl_1.f90: New test.
	* gfortran.dg/maskr_1.f90: New test.
	* gfortran.dg/scan_3.f90: New test.
	* gfortran.dg/verify_3.f90: New test.
2022-01-09 14:34:15 +01:00
Sandra Loosemore
57fe1f6ad3 Testsuite: Make dependence on -fdelete-null-pointer-checks explicit
nios2-elf target defaults to -fno-delete-null-pointer-checks, breaking
tests that implicitly depend on that optimization.  Add the option
explicitly on these tests.

2022-01-08  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/testsuite/
	* g++.dg/cpp0x/constexpr-compare1.C: Add explicit
	-fdelete-null-pointer-checks option.
	* g++.dg/cpp0x/constexpr-compare2.C: Likewise.
	* g++.dg/cpp0x/constexpr-typeid2.C: Likewise.
	* g++.dg/cpp1y/constexpr-94716.C: Likewise.
	* g++.dg/cpp1z/constexpr-compare1.C: Likewise.
	* g++.dg/cpp1z/constexpr-if36.C: Likewise.
	* gcc.dg/init-compare-1.c: Likewise.

	libstdc++-v3/
	* testsuite/18_support/type_info/constexpr.cc: Add explicit
	-fdelete-null-pointer-checks option.
2022-01-08 22:17:18 -08:00
GCC Administrator
2848ef1411 Daily bump. 2022-01-09 00:16:20 +00:00
Roger Sayle
fad14a028f x86_64: Improve (interunit) moves from TImode to V1TImode.
This patch improves the code generated when moving a 128-bit value
in TImode, represented by two 64-bit registers, to V1TImode, which
is a single SSE register.

Currently, the simple move:
typedef unsigned __int128 uv1ti __attribute__ ((__vector_size__ (16)));
uv1ti foo(__int128 x) { return (uv1ti)x; }

is always transferred via memory, as:
foo:    movq    %rdi, -24(%rsp)
        movq    %rsi, -16(%rsp)
        movdqa  -24(%rsp), %xmm0
        ret

with this patch, we now generate (with -msse2):
foo:    movq    %rdi, %xmm1
        movq    %rsi, %xmm2
        punpcklqdq      %xmm2, %xmm1
        movdqa  %xmm1, %xmm0
        ret

and with -mavx2:
foo:    vmovq   %rdi, %xmm1
        vpinsrq $1, %rsi, %xmm1, %xmm0
        ret

Even more dramatic is the improvement of zero extended transfers.

uv1ti bar(unsigned char c) { return (uv1ti)(__int128)c; }

Previously generated:
bar:    movq    $0, -16(%rsp)
        movzbl  %dil, %eax
        movq    %rax, -24(%rsp)
        vmovdqa -24(%rsp), %xmm0
        ret

Now generates:
bar:    movzbl  %dil, %edi
        movq    %rdi, %xmm0
        ret

My first attempt at this functionality attempted to use a simple
define_split, but unfortunately, this triggers very late during the
compilation preventing some of the simplifications we'd like (in
combine).  For example the foo case above becomes:

foo:    movq    %rsi, -16(%rsp)
        movq    %rdi, %xmm0
        movhps  -16(%rsp), %xmm0

transferring half directly, and the other half via memory.
And for the bar case above, GCC fails to appreciate that
movq/vmovq clears the high bits, resulting in:

bar:    movzbl  %dil, %eax
        xorl    %edx, %edx
        vmovq   %rax, %xmm1
        vpinsrq $1, %rdx, %xmm1, %xmm0
        ret

Hence the solution (i.e. this patch) is to add a special case
to ix86_expand_vector_move for TImode to V1TImode transfers.

2022-01-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/i386/i386-expand.c (ix86_expand_vector_move): Add
	special case for TImode to V1TImode moves, going via V2DImode.

gcc/testsuite/ChangeLog
	* gcc.target/i386/sse2-v1ti-mov-1.c: New test case.
	* gcc.target/i386/sse2-v1ti-zext.c: New test case.
2022-01-08 12:27:50 +00:00
Jakub Jelinek
51d464b608 c++, match.pd: Evaluate in constant evaluation comparisons like &var1 + 12 == &var2 + 24 [PR89074]
The match.pd address_comparison simplification can only handle
ADDR_EXPR comparisons possibly converted to some other type (I wonder
if we shouldn't restrict it in address_compare to casts to pointer
types or pointer-sized integer types, I think we shouldn't optimize
(short) (&var) == (short) (&var2) because we really don't know whether
it will be true or false).  On GIMPLE, most of pointer to pointer
casts are useless and optimized away and further we have in
gimple_fold_stmt_to_constant_1 an optimization that folds
&something p+ const_int
into
&MEM_REF[..., off]
On GENERIC, we don't do that and e.g. for constant evaluation it
could be pretty harmful if e.g. such pointers are dereferenced, because
it can lose what exact field it was starting with etc., all it knows
is the base and offset, type and alias set.
Instead of teaching the match.pd address_compare about 3 extra variants
where one or both compared operands are pointer_plus, this patch attempts
to fold operands of comparisons similarly to gimple_fold_stmt_to_constant_1
before calling fold_binary on it.
There is another thing though, while we do have (x p+ y) p+ z to
x p+ (y + z) simplification which works on GIMPLE well because of the
useless pointer conversions, on GENERIC we can have pointer casts in between
and at that point we can end up with large expressions like
((type3) (((type2) ((type1) (&var + 2) + 2) + 2) + 2))
etc.  Pointer-plus doesn't really care what exact pointer type it has as
long as it is a pointer, so the following match.pd simplification for
GENERIC only (it is useless for GIMPLE) also moves the cast so that nested
p+ can be simplified.

Note, I've noticed we don't really diagnose going out of bounds with
pointer_plus (unlike e.g. with ARRAY_REF) during constant evaluation, I
think another patch for cxx_eval_binary_expression with POINTER_PLUS will be
needed.  But it isn't clear to me what exactly it should do in case of
subobjects.  If we start with address of a whole var, (&var), I guess we
should diagnose if the pointer_plus gets before start of the var (i.e.
"negative") or 1 byte past the end of the var, but what if we start with
&var.field or &var.field[3] ?  For &var.field, shall we diagnose out of
bounds of field (except perhaps flexible members?) or the whole var?
For ARRAY_REFs, I assume we must at least strip all the outer ARRAY_REFs
and so start with &var.field too, right?

2022-01-08  Jakub Jelinek  <jakub@redhat.com>

	PR c++/89074
gcc/
	* match.pd ((ptr) (x p+ y) p+ z -> (ptr) (x p+ (y + z))): New GENERIC
	simplification.
gcc/cp/
	* constexpr.c (cxx_maybe_fold_addr_pointer_plus): New function.
	(cxx_eval_binary_expression): Use it.
gcc/testsuite/
	* g++.dg/cpp1y/constexpr-89074-2.C: New test.
	* g++.dg/cpp1z/constexpr-89074-1.C: New test.
2022-01-08 09:53:00 +01:00
Jason Merrill
787d66eb6c c++: default mem-init of array [PR103946]
In the patch for PR92385 I added asserts to see if we tried to make a
vec_init of a vec_init, but didn't see any in regression testing.  This
testcase is one case, which seems reasonable: we create a VEC_INIT_EXPR for
the aggregate initializer, and then again to express the actual
initialization of the member.  We already do similar collapsing of
TARGET_EXPR.  So let's just remove the asserts.

	PR c++/103946

gcc/cp/ChangeLog:

	* init.c (build_vec_init): Remove assert.
	* tree.c (build_vec_init_expr): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/nsdmi-array1.C: New test.
2022-01-08 01:18:51 -05:00
Jason Merrill
75047f7951 c++: destroying delete, throw in new-expr [PR100588]
The standard says that a destroying operator delete is preferred, but that
only applies to the delete-expression, not the cleanup if a new-expression
initialization throws.  As a result of this patch, several of the destroying
delete tests don't get EH cleanups, but I'm turning off the warning in cases
where the initialization can't throw anyway.

It's unclear what should happen if the class does not declare a non-deleting
operator delete; a proposal in CWG was to call the global delete, which
makes sense to me if the class doesn't declare its own operator new.  If it
does, we warn and don't call any deallocation function if initialization
throws.

	PR c++/100588

gcc/cp/ChangeLog:

	* call.c (build_op_delete_call): Ignore destroying delete
	if alloc_fn.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/destroying-delete5.C: Expect warning.
	* g++.dg/cpp2a/destroying-delete6.C: New test.
2022-01-07 21:03:28 -05:00
GCC Administrator
55e96bf912 Daily bump. 2022-01-08 00:16:27 +00:00
David Malcolm
11a2ff8d98 analyzer: add logging of aliasing
gcc/analyzer/ChangeLog:
	* engine.cc (impl_run_checkers): Pass logger to engine ctor.
	* region-model-manager.cc
	(region_model_manager::region_model_manager): Add logger param and
	use it to initialize m_logger.
	* region-model.cc (engine::engine): New.
	* region-model.h (region_model_manager::region_model_manager):
	Add logger param.
	(region_model_manager::get_logger): New.
	(region_model_manager::m_logger): New field.
	(engine::engine): New.
	* store.cc (store_manager::get_logger): New.
	(store::set_value): Log scope.  Log when marking a cluster as
	unknown due to possible aliasing.
	* store.h (store_manager::get_logger): New decl.
2022-01-07 19:05:16 -05:00
David Malcolm
4409152a4a analyzer: implement __analyzer_dump_escaped
PR analyzer/103546 seems to involve an issue in how the analyzer
tracks which decls have escaped, so this patch adds a way to directly
test this from DejaGnu.

gcc/analyzer/ChangeLog:
	* region-model-impl-calls.cc (cmp_decls): New.
	(cmp_decls_ptr_ptr): New.
	(region_model::impl_call_analyzer_dump_escaped): New.
	* region-model.cc (region_model::on_stmt_pre): Handle
	__analyzer_dump_escaped.
	* region-model.h (region_model::impl_call_analyzer_dump_escaped):
	New decl.
	* store.h (binding_cluster::get_base_region): New accessor.

gcc/ChangeLog:
	* doc/analyzer.texi
	(Special Functions for Debugging the Analyzer): Document
	__analyzer_dump_escaped.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/analyzer-decls.h (__analyzer_dump_escaped): New
	decl.
	* gcc.dg/analyzer/escaping-1.c: New test.
2022-01-07 19:04:01 -05:00
David Malcolm
c1b7d28a59 analyzer: add region::is_named_decl_p
This patch adds a debug function that I've found handy when debugging
a problem with handling the decl "yy_buffer_stack" in PR analyzer/103546.

gcc/analyzer/ChangeLog:
	* region.cc (region::is_named_decl_p): New.
	* region.h (region::is_named_decl_p): New decl.

gcc/ChangeLog:
	* doc/analyzer.texi (Other Debugging Techniques): Document
	region::is_named_decl_p.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-07 19:03:28 -05:00
Jason Merrill
6cd51207f5 c++: check delete access with trivial init [PR20040]
Apparently we need to check the accessibility of the deallocation function
even if there is no initialization.

	PR c++/20040

gcc/cp/ChangeLog:

	* init.c (build_new_1): Also build pointer cleanup if
	TYPE_GETS_DELETE.
	* cp-tree.h (TYPE_GETS_VEC_DELETE): New.

gcc/testsuite/ChangeLog:

	* g++.dg/init/delete4.C: New test.
2022-01-07 17:11:56 -05:00
Andrew Pinski
997130f778 target: [PR102941] Fix inline-asm flags with non-REG_P output
So the problem here is that arm_md_asm_adjust would
just create a set directly to the output memory which is wrong.
It needs to output to a temp register first and then do a
move.

OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions.
I have no way to test on arm even though this touches common code.

	PR target/102941

gcc/ChangeLog:

	* config/arm/aarch-common.c (arm_md_asm_adjust):
	Use a temp if !REG_P.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/asm-flag-7.c: New test.
	* gcc.target/arm/asm-flag-7.c: New test.
2022-01-07 22:02:44 +00:00
Uros Bizjak
42ae7ebfb2 i386: Robustify V2QI and V4QI move patterns
Add sse2 isa attribute where needed and remove where not needed.

2022-01-07  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	* config/i386/mmx.md (*move<V_32:mode>_internal): Add isa attribute.
	(*movv2qi_internal): Remve sse2 requirement for alternatives 4,5.
2022-01-07 20:41:30 +01:00
Patrick Bernardi
a64478660e [Ada] Read directory in Ada.Directories.Start_Search rather than Get_Next_Entry
gcc/ada/

	* libgnat/a-direct.adb (Search_Data): Remove type.
	(Directory_Vectors): New package instantiation.
	(Search_State): New type.
	(Fetch_Next_Entry): Remove.
	(Close): Remove.
	(Finalize): Rewritten.
	(Full_Name): Ditto.
	(Get_Next_Entry): Return next entry from Search results vector
	rather than querying the directory directly using readdir.
	(Kind): Rewritten.
	(Modification_Time): Rewritten.
	(More_Entries): Use Search state cursor to determine if more
	entries are available for users to read.
	(Simple_Name): Rewritten.
	(Size): Rewritten.
	(Start_Search_Internal): Rewritten to load the contents of the
	directory that matches the pattern and filter into the search
	object.
	* libgnat/a-direct.ads (Search_Type): New type.
	(Search_Ptr): Ditto.
	(Directory_Entry_Type): Rewritten to support new Start_Search
	procedure.
	* libgnat/s-filatt.ads (File_Length_Attr): New function.
2022-01-07 16:24:15 +00:00
Etienne Servais
9b573d421a [Ada] Fix the check of the 'Old prefix
gcc/ada/

	* sem_attr.adb (Check_Reference): Fix condition.
2022-01-07 16:24:15 +00:00
Ghjuvan Lacambre
657fc14ca7 [Ada] Fix uses of pragma Unreferenced in MinGW runtime unit
gcc/ada/

	* libgnarl/s-taprop__mingw.adb (Timed_Sleep): Remove "pragma
	Unreferenced" for Result.
	(Timed_Delay): Likewise.
2022-01-07 16:24:15 +00:00
Piotr Trojanek
22a69380dc [Ada] Fix layout of pragma Inline in generated AST unit
gcc/ada/

	* gen_il-gen.adb (Put_Make_Decls): Put pragma Inline in a
	dedicated line, so that the current indentation is taken into
	account.
2022-01-07 16:24:15 +00:00
Piotr Trojanek
8313d0ee55 [Ada] Fix style in expansion of multi-dimensional array aggregates
gcc/ada/

	* exp_aggr.adb (Build_Array_Aggr_Code): Fix inconsistent style
	in comments and code.
2022-01-07 16:24:14 +00:00
Piotr Trojanek
d7b2fad2ec [Ada] More default initialization for multi-dim array aggregates
gcc/ada/

	* exp_aggr.adb (Gen_Assign): Remove explicit initialization for
	components of access types.
	(Get_Assoc_Expr): Enable initialization for components of all
	types that require simple initialization.
2022-01-07 16:24:14 +00:00
Javier Miranda
2eed8f16bf [Ada] Crash in class-wide pre/postconditions
gcc/ada/

	* atree.ads (Traverse_Func_With_Parent): New generic subprogram.
	(Traverse_Proc_With_Parent): Likewise.
	* atree.adb (Parents_Stack): New table used to traverse trees
	passing the parent field of each node.
	(Internal_Traverse_With_Parent): New generic subprogram.
	(Traverse_Func_With_Parent): Likewise.
	(Traverse_Proc_With_Parent): Likewise.
	* contracts.adb (Fix_Parents): New subprogram.
	(Restore_Original_Selected_Component): Enhanced to fix the
	parent field of restored nodes.
	(Inherit_Condition): Adding assertions to check the parent field
	of inherited conditions and to ensure that the built inherited
	condition has no reference to the formals of the parent
	subprogram.
	* sem_util.ads, sem_util.adb (Check_Parents): New subprogram.
2022-01-07 16:24:14 +00:00
Etienne Servais
7f4e820d3b [Ada] Fix typo on "Placement" in comment
gcc/ada/

	* sem_attr.adb (Check_Placement_In_Test_Case): Fix typo.
2022-01-07 16:24:13 +00:00
Justin Squirek
72a29376c6 [Ada] Cleanup and modification of unreferenced warnings
gcc/ada/

	* comperr.adb (Delete_SCIL_Files): Replace unnecessary
	Unreferenced pragma with specific pragma Warnings.
	* doc/gnat_rm/implementation_defined_pragmas.rst (Unreferenced):
	Add documentation for new behavior.
	* gnat_rm.texi: Regenerate.
	* erroutc.adb (Set_At): Remove useless assignment.
	* exp_ch2.adb (In_Assignment_Context): Deleted.
	(Is_Object_Renaming_Name): Replace calls to Is_LHS with calls to
	Known_To_Be_Assigned.
	(Expand_Current_Value): Replace calls to May_Be_Lvalue with
	calls to Known_To_Be_Assigned.
	(Expand_Entry_Paramter): Replace calls to In_Assignment_Context
	with calls to Known_To_Be_Assigned.
	* exp_ch4.adb (Expand_N_Op_Rem): Remove unnecessary Unreferenced
	pragma.
	* exp_imgv.adb (Build_Enumeration_Image_Tables): Default
	initialize S_N.
	* ghost.adb (Check_Ghost_Policy): Replace call to May_Be_Lvalue
	with call to Known_To_Be_Assigned.
	* lib-xref.adb (Is_On_LHS): Deleted.
	(OK_To_Set_Referenced): Rewrite subprogram to encompass the new
	pragma Unreferenced behavior.
	(Process_Deferred_References): Replace call to Is_LHS with call
	to Known_To_Be_Assigned.
	* libgnarl/s-taasde.adb, libgnarl/s-tasren.adb,
	libgnarl/s-tpobop.adb, libgnat/a-calend.adb,
	libgnat/a-calfor.adb, libgnat/a-cbdlli.adb,
	libgnat/a-cbhama.adb, libgnat/a-cbhase.adb,
	libgnat/a-cbmutr.adb, libgnat/a-cborma.adb,
	libgnat/a-cborse.adb, libgnat/a-cdlili.adb,
	libgnat/a-cfhama.adb, libgnat/a-cforse.adb,
	libgnat/a-cidlli.adb, libgnat/a-cihama.adb,
	libgnat/a-cihase.adb, libgnat/a-cimutr.adb,
	libgnat/a-ciorma.adb, libgnat/a-ciormu.adb,
	libgnat/a-ciorse.adb, libgnat/a-cohama.adb,
	libgnat/a-cohase.adb, libgnat/a-comutr.adb,
	libgnat/a-convec.adb, libgnat/a-coorma.adb,
	libgnat/a-coormu.adb, libgnat/a-coorse.adb,
	libgnat/a-crdlli.adb, libgnat/a-tigeau.adb,
	libgnat/a-wtgeau.adb, libgnat/a-ztgeau.adb,
	libgnat/g-calend.adb, libgnat/g-comlin.adb,
	libgnat/g-expect.adb, libgnat/g-mbflra.adb,
	libgnat/g-spipat.adb, libgnat/s-fatgen.adb,
	libgnat/s-fileio.adb, libgnat/s-os_lib.adb,
	libgnat/s-regpat.adb, libgnat/s-valued.adb,
	libgnat/s-valuer.adb: Remove unnecessary Unreferenced pragmas
	* sem_ch10.adb (Process_Spec_Clauses): Remove useless
	assignments.
	* sem_ch13.adb (Validate_Literal_Aspect): Default initialize I.
	* sem_ch3.adb (Build_Derived_Concurrent_Type): Default
	initialize Corr_Decl.
	* sem_ch8.adb (Undefined): Replace calls to Is_LHS with calls to
	Known_To_Be_Assigned.
	(In_Abstract_View_Pragma): Likewise.
	* sem_eval.adb (Eval_Selected_Component): Replace calls to
	Is_LHS with calls to Known_To_Be_Assigned.
	* sem_res.adb (Init_Component): Replace calls to May_Be_Lvalue
	with calls to Known_To_Be_Assigned.
	* sem_util.adb, sem_util.ads (End_Label_Loc): Default initialize
	Owner.
	(Explain_Limited_Type): Default initialize Expr_Func.
	(Find_Actual): Modified to handle entry families.
	(Is_LHS): Deleted.
	(May_Be_Lvalue): Deleted.
	(Known_To_Be_Assigned): Modified and improved to handle all
	cases.
	* sem_warn.adb (Traverse_Result): Replace calls to May_Be_Lvalue
	with calls to Known_To_Be_Assigned.
	(Check_Ref): Modify error on unreferenced out parameters to take
	into account different warning flags.
2022-01-07 16:24:13 +00:00
Javier Miranda
e2b07ba054 [Ada] Spurious error caused by order of interfaces in full view
gcc/ada/

	* sem_ch3.adb (Reorder_Interfaces): When the conflicting
	interface is identified we just replace the interface in the
	list of interfaces of the tagged type (instead of adding a
	duplicate to the list of interfaces).
2022-01-07 16:24:12 +00:00
Dmitriy Anisimkov
20f6d5e4a8 [Ada] Fix __gnat_kill on Windows
gcc/ada/

	* adaint.c (__gnat_kill): Terminate process only in case of
	SIGKILL, SIGINT, SIGBREAK, SIGTERM, SIGABRT.  Do not call
	OpenProcess if not going to terminate process.
2022-01-07 16:24:11 +00:00
Eric Botcazou
13e0413766 [Ada] Fix a couple of issues with pragma Inspection_Point
gcc/ada/

	* exp_prag.adb (Expand_Pragma_Inspection_Point): Do a single pass
	over the arguments of the pragma.  Set the Address_Taken flag on
	them and use the Has_Delayed_Freeze flag to spot those which have
	their elaboration delayed.  Reuse the location variable Loc.
2022-01-07 16:24:11 +00:00
Piotr Trojanek
d1e0b1be62 [Ada] Remove repeated routines for printing AST in Mixed_Case
gcc/ada/

	* osint.adb (To_Lower): Clarify that only To_Lower function
	causes bootstrap issues; fix style.
	* treepr.adb (Print_Str_Mixed_Case): Reuse existing case
	conversion routine.
	(To_Mixed): Rename from Capitalize; reuse System.Case_Util
	procedure and explain the bootstrap issue.
2022-01-07 16:24:11 +00:00
Piotr Trojanek
c31cbf91a0 [Ada] Simplify traversal in hooking of transient scopes
gcc/ada/

	* exp_ch7.adb (Process_Transients_In_Scope): Remove unnecessary
	initialization of Must_Hook; change Detect_Subprogram_Call from
	function to procedure; adapt caller.
2022-01-07 16:24:10 +00:00
Piotr Trojanek
93b2e53e87 [Ada] Remove extra space before THEN keywords
gcc/ada/

	* exp_ch5.adb, exp_disp.adb, exp_util.adb, par-ch4.adb,
	sem_ch13.adb: Remove extra space before THEN that occurs at the
	end of a line.
2022-01-07 16:24:10 +00:00
Dmitriy Anisimkov
9e6274e0a3 [Ada] Fix exit status of GNAT.Expect.Close call on running process
gcc/ada/

	* expect.c (__gnat_waitpid): Use macros WIFEXITED, WEXITSTATUS,
	WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG to get exit status
	or signal that caused the child process to terminate/stop.  Do
	not process exit status in case of error in waitpid call.
	* adaint.c (__gnat_kill): Use of GenerateConsoleCtrlEvent is
	removed in Windows variant as it actually is not working and was
	terminating the calling process.  Set signal number into exit
	code parameter of TerminateProcess to work the same like in
	Linux.
2022-01-07 16:24:10 +00:00
Piotr Trojanek
69a6631a6f [Ada] Remove explicit expansion of block with general case statement
gcc/ada/

	* exp_ch5.adb (Expand_N_Case_Statement): Remove explicit
	expansion.
2022-01-07 16:24:09 +00:00
Etienne Servais
b2a99abba9 [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.
2022-01-07 16:24:09 +00:00
Piotr Trojanek
b1dcd52be1 [Ada] Fix comment about subprogram unnesting and unconstrained arrays
gcc/ada/

	* exp_unst.adb (Unnest_Subprogram): Sync comment with the
	current code.
2022-01-07 16:24:09 +00:00
Piotr Trojanek
57136d60c6 [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.
2022-01-07 16:24:08 +00:00
Piotr Trojanek
c8e99971b6 [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.
2022-01-07 16:24:08 +00:00
Piotr Trojanek
e8a52167ea [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.
2022-01-07 16:24:07 +00:00
Piotr Trojanek
3174b67eef [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.
2022-01-07 16:24:07 +00:00
Etienne Servais
34b8a9b8c0 [Ada] Check scalar range in arrays constructed by concatenation
gcc/ada/

	* sem_res.adb (Resolve_Op_Concat_Arg): Check range when
	concatenating scalars.
2022-01-07 16:24:06 +00:00
Bob Duff
b2f150304d [Ada] treepr: print value only for discrete types
gcc/ada/

	* treepr.adb (Print_Node_Ref): Change "not Is_Array_Type" to
	"Is_Discrete_Type".
2022-01-07 16:24:06 +00:00
Richard Kenner
a3c3de386b [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.
2022-01-07 16:24:06 +00:00
Bob Duff
5e5030df8f [Ada] treepr: Print value of static expression
gcc/ada/

	* treepr.adb (Print_Node_Ref): Print the value if available.
2022-01-07 16:24:05 +00:00
Richard Kenner
1226283cd9 [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.
2022-01-07 16:24:05 +00:00
Bob Duff
0c65ca0625 [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.
2022-01-07 16:24:05 +00:00
Bob Duff
9ceb18d4a2 [Ada] Small cleanup of osint-m.adb
gcc/ada/

	* osint-m.adb: Remove with_clause and pragma.
2022-01-07 16:24:04 +00:00
liuhongt
e7a7dbb5ca 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.
2022-01-07 23:09:05 +08:00
Roger Sayle
659f8161f6 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.
2022-01-07 09:57:21 +00:00
Haochen Gui
add37d3bf4 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.
2022-01-07 14:36:42 +08:00
Jason Merrill
765693be1c 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.
2022-01-07 00:22:56 -05:00
liuhongt
041cfa0ce4 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.
2022-01-07 11:13:00 +08:00