Commit Graph

193374 Commits

Author SHA1 Message Date
Arnaud Charlet
679ed5b02b [Ada] Fix compilation of raise-gcc.c with -DSTANDALONE under windows
This is needed in particular by GNAT LLVM builds.

gcc/ada/

	* raise-gcc.c: Fix compilation with -DSTANDALONE under windows.
2022-05-19 14:05:31 +00:00
Eric Botcazou
4b3cf84164 [Ada] Preserve and reuse original type in Narrow_Large_Operation
Instead of using that of Original_Node (N) after rewriting, which does not
work if N had previously been rewritten.

gcc/ada/

	* exp_ch4.adb (Narrow_Large_Operation): Preserve and reuse Etype.
2022-05-19 14:05:31 +00:00
Javier Miranda
8a03acaace [Ada] Wrong interface dynamic dispatch via access parameter
When the prefix of an Access attribute is an explicit dereference of an
access parameter (or a renaming of such a dereference, or a subcomponent
of such a dereference), the context is a general access type to a
class-wide interface type, and an accessibility check must be generated,
the frontend silently skips generating an implicit type conversion to
force the displacement of the pointer to reference the secondary
dispatch table.

gcc/ada/

	* exp_attr.adb (Add_Implicit_Interface_Type_Conversion): New
	subprogram which factorizes code.
	(Expand_N_Attribute_Reference): Call the new subprogram to add
	the missing implicit interface type conversion.
2022-05-19 14:05:31 +00:00
Piotr Trojanek
eff70bcc1f [Ada] Ignore Predicate_Failure in GNATprove mode
In GNATprove mode we are don't want predicate failure to pollute the
predicate expression extracted from the predicate function.

gcc/ada/

	* sem_ch13.adb (Build_Predicate_Function): Ignore predicate
	failure in GNATprove mode.
2022-05-19 14:05:30 +00:00
Steve Baird
55a11c7e34 [Ada] Fix bug in handling of Predicate_Failure aspect
The run-time behavior of the Ada 2022 Predicate_Failure aspect was
incorrectly implemented. This could cause incorrect exception messages
at execution time in the case of a predicate check failure, as
demonstrated by ACATS test C324006. In addition, a new attribute
(Predicate_Expression) is defined in order to improve the FE/SPARK
interface.

gcc/ada/

	* einfo-utils.ads, einfo-utils.adb: Delete Predicate_Function_M
	function and Set_Predicate_Function_M procedure.
	* einfo.ads: Delete comments for Is_Predicate_Function_M and
	Predicate_Function_M functions. Add comment for new
	Predicate_Expression function. Update comment describing
	predicate functions.
	* exp_util.ads, exp_util.adb (Make_Predicate_Call): Replace Mem
	formal parameter with Static_Mem and Dynamic_Mem formals.
	(Make_Predicate_Check): Delete Add_Failure_Expression and call
	to it.
	* exp_ch4.adb (Expand_N_In.Predicate_Check): Update
	Make_Predicate_Call call to match profile change.
	* gen_il-fields.ads: Delete Is_Predicate_Function_M field, add
	Predicate_Expression field.
	* gen_il-gen-gen_entities.adb: Delete Is_Predicate_Function_M
	use, add Predicate_Expression use.
	* sem_ch13.adb (Build_Predicate_Functions): Rename as singular,
	not plural; we no longer build a Predicate_M function. Delete
	Predicate_M references. Add new Boolean parameter for predicate
	functions when needed. Restructure body of generated predicate
	functions to implement required Predicate_Failure behavior and
	to set new Predicate_Expression attribute. Remove special
	treatment of raise expressions within predicate expressions.
	* sem_util.ads (Predicate_Failure_Expression,
	Predicate_Function_Needs_Membership_Parameter): New functions.
	* sem_util.adb (Is_Current_Instance): Fix bugs which caused
	wrong result.
	(Is_Current_Instance_Reference_In_Type_Aspect): Delete
	Is_Predicate_Function_M reference.
	(Predicate_Failure_Expression): New function.
	(Propagate_Predicate_Attributes): Delete Is_Predicate_Function_M
	references.
2022-05-19 14:05:30 +00:00
Eric Botcazou
8be71a90b1 [Ada] Avoid copy operation for returns involving function calls
The underlying issue is that the front-end does not create transient scopes
for return statements, so objects copied for these statements can never be
finalized properly.

gcc/ada/

	* exp_ch6.adb (Expand_Call_Helper): Adjust comment.
	(Expand_Simple_Function_Return): For the case of a type which needs
	finalization and is returned on the primary stack, do not create a
	copy if the expression originates from a function call.
	* exp_ch7.adb (Transient Scope Management): Adjust comment.
	* exp_util.ads (Is_Related_To_Func_Return): Add WARNING line.
	* fe.h (Is_Related_To_Func_Return): Declare.
2022-05-19 14:05:30 +00:00
Piotr Trojanek
ca03325fb3 [Ada] Fix invalid expanded code for entry families
Expansion of entry families created a slightly illegal AST with
Elsif_Parts being an empty list. Cleanup uncovered by the work on
detection of uninitialized scalars.

gcc/ada/

	* exp_ch9.adb (Build_Find_Body_Index): Remove empty Elsif_Parts
	from the constructed IF statement.
2022-05-19 14:05:30 +00:00
Piotr Trojanek
b626498f6e [Ada] Cleanup expansion of protected entry families
Expansion of entry families contained a condition that was always true.
Cleanup related to detection of uninitialized scalar objects (which
uncovered that expansion of entry families creates a slightly illegal
AST with Elsif_Parts being an empty list).

gcc/ada/

	* exp_ch9.adb (Build_Find_Body_Index): Remove IF statement whose
	condition was true-by-construction; remove excessive assertion
	(since the call to Elsif_Parts will check that Nod is present
	and it is an if-statement).
2022-05-19 14:05:30 +00:00
Arnaud Charlet
4e474137e7 [Ada] Remove remaining references to gnatfind/gnatxref
gcc/ada/

	* gnat1drv.adb, gnatcmd.adb: Remove references to gnatfind/xref.
	* doc/gnat_ugn/building_executable_programs_with_gnat.rst,
	doc/gnat_ugn/the_gnat_compilation_model.rst: Ditto.
	* gnat_ugn.texi: Regenerate.
	* gnatfind.adb, gnatxref.adb, xr_tabls.adb, xr_tabls.ads,
	xref_lib.adb, xref_lib.ads: Removed, no longer used.
2022-05-19 14:05:29 +00:00
Claire Dross
c92f4fddd6 [Ada] Fix proof of runtime unit a-strfix and a-strsup
Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

	* libgnat/a-strfix.adb: Add assertions.
	* libgnat/a-strsup.adb: Idem.
2022-05-19 14:05:29 +00:00
Ed Schonberg
10c257afea [Ada] Support Ada 2022 null array aggregates
Add support for Ada 2022's "[]" null array aggregates (thanks to Ed
Schonberg for producing most of this patch).

gcc/ada/

	* erroutc.ads: Fix a single-character typo in a comment.
	* exp_aggr.adb: Fix a single-character typo in a comment.
	Replace several pairs of calls to Low_Bound and
	High_Bound (which do not handle an identifier that denotes a
	scalar subtype) with corresponding calls to Get_Index_Bounds
	(which does handle that case).
	* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Set the
	Component_Associations attribute of a null array aggregate to
	New_List.
	* sem_aggr.ads: New visible function
	Is_Null_Array_Aggregate_High_Bound.
	* sem_aggr.adb (Is_Null_Array_Aggregate_High_Bound,
	Is_Null_Aggregate, Resolve_Null_Array_Aggregate): New functions.
	(Resolve_Aggregate): Recognize null array aggregates (using
	Is_Null_Aggregate) and, when one is recognized, resolve
	it (using Resolve_Null_Array_Aggregate).  Avoid calling
	Array_Aggr_Subtype for a null array aggregate; the needed
	subtype is built in Resolve_Null_Array_Aggregate. Do not
	incorrectly flag a null aggregate (after it is transformed by
	expansion) as being both positional and named.
	* sem_attr.adb (Eval_Attribute): Special treatment for null
	array aggregate high bounds to avoid incorrectly flagging
	something like Integer'Pred (Integer'First) as an illegal static
	expression.
	* sem_eval.adb (Out_Of_Range): Special treatment for null array
	aggregate high bounds to avoid incorrectly flagging something
	like Integer'Pred (Integer'First) as an illegal static
	expression.
2022-05-19 14:05:29 +00:00
Yannick Moy
054cf924ac [Ada] Further adapt proof of double arithmetic runtime unit
After changes in Why3 and generation of VCs, ghost code needs to be
adapted for proofs to remain automatic.

gcc/ada/

	* libgnat/s-aridou.adb (Lemma_Abs_Range,
	Lemma_Double_Shift_Left, Lemma_Shift_Left): New lemmas.
	(Double_Divide): Add ghost code.
	(Lemma_Concat_Definition, Lemma_Double_Shift_Left,
	Lemma_Shift_Left, Lemma_Shift_Right): Define or complete lemmas.
	(Scaled_Divide): Add ghost code.
2022-05-19 14:05:29 +00:00
Bob Duff
88f7b07de7 [Ada] Improve optimization of "=" on bit-packed arrays
This patch fixes a performance regression, introduced by a previous bug
fix.  That fix had the unintended side effect of removing the
optimization in cases where the two operands are of two different
compiler-generated modular types.

gcc/ada/

	* exp_pakd.adb (Expand_Packed_Eq): Replace the check for *same*
	modular type, with a check for any modular type, and assert that
	the two types have the same modulus and so on.
	* exp_pakd.ads: Minor comment improvements.
2022-05-19 14:05:29 +00:00
Bob Duff
5cc07f401a [Ada] Casing style on record components
This patch fixes a bug where the -gnatyr switch fails to detect
incorrect casing of record components.

gcc/ada/

	* style.adb (Check_Identifier): Deal with the case where a
	record component definition has been transformed; we want to
	warn if the original came from source.
	* libgnat/s-objrea.ads, libgnat/s-objrea.adb: Fix casing of MF
	to be consistent.
	* uname.adb: Fix casing of Chars to be consistent.
	* sem_util.ads: Minor comment fix.
2022-05-19 14:05:28 +00:00
Eric Botcazou
c697f593f4 [Ada] Get rid of secondary stack for controlled components
This eliminates the use of the secondary stack to return composite types
with controlled components from functions, by exposing the return slot of
these functions through the support interface of memory pools, much like
for the secondary stack itself.  This is piggybacked on the support of a
specific intrinsic function by the code generator, and can be disabled if
this support is not available, as well with the -gnatd_r debug switch.

The change also streamlines a bit the implementation by consistently using
the Needs_Finalization predicate, or its derivatives, in various places.

gcc/ada/

	* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-retsta.
	* debug.adb (d_r): Document usage.
	* exp_ch4.adb (Expand_N_Allocato): Deal with the return stack pool.
	* exp_ch6.adb (Expand_Simple_Function_Return): Replace calls to
	Requires_Transient_Scope with Returns_On_Secondary_Stack.  Deal
	with types that need finalization returned on the primary stack,
	use CW_Or_Needs_Finalization for those returned on the secondary.
	* exp_util.adb (Build_Allocate_Deallocate_Proc): Return early
	for the return stack pool.
	(Remove_Side_Effects): Call CW_Or_Needs_Finalization.
	* fe.h (Requires_Transient_Scope): Delete.
	(Returns_On_Secondary_Stack): Declare.
	* gnat1drv.adb (Adjust_Global_Switches): Set Back_End_Return_Slot
	to False when generating C code or if -gnatd_r is specified.
	* opt.ads (Back_End_Return_Slot): New boolean variable.
	* rtsfind.ads (RTU_Id): Add System_Return_Stack.
	(RE_Id): Add RE_RS_Allocate and RE_RS_Pool.
	(RE_Unit_Table): Add entries for RE_RS_Allocate and RE_RS_Pool.
	* sem_util.ads (CW_Or_Has_Controlled_Part): Delete.
	(CW_Or_Needs_Finalization): Declare.
	(Requires_Transient_Scope): Adjust description.
	(Returns_On_Secondary_Stack): Declare.
	* sem_util.adb (Compute_Returns_By_Ref): Set Returns_By_Ref on types
	which need finalization if they are returned on the secondary stack.
	(CW_Or_Has_Controlled_Part): Rename to...
	(CW_Or_Needs_Finalization): ...this.
	(Requires_Transient_Scope): Move bulk of implementation to...
	(Returns_On_Secondary_Stack): ...here.  Return true for types which
	need finalization only if the back-end return slot is not supported.
	* libgnat/s-retsta.ads: New file.
	* gcc-interface/ada-builtin-types.def (BT_FN_PTR_SSIZE): Define.
	* gcc-interface/ada-builtins.def (return_slot): Likewise.
	* gcc-interface/ada-tree.h (BUILT_IN_RETURN_SLOT): Likewise.
	* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Replace call to
	Requires_Transient_Scope with Returns_On_Secondary_Stack.
	* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
	In the return by invisible reference, skip the copy if the source
	is the same as the destination.
	* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Deal with
	the return stack pool.
2022-05-19 14:05:28 +00:00
Eric Botcazou
e08f1aad6f [Ada] Small housekeeping work continued
No functional changes.

gcc/ada/

	* gcc-interface/trans.cc: Fix formatting issues in comments.
	(Subprogram_Body_to_gnu): Tidy up.
	(Exception_Handler_to_gnu_gcc): Rename into...
	(Exception_Handler_to_gnu): ...this.
	(gnat_to_gnu) <N_Exception_Handler>: Adjust to above renaming.
2022-05-19 14:05:28 +00:00
Eric Botcazou
4e279bd9dc [Ada] Small housekeeping work
No functional changes.

gcc/ada/

	* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Rename a couple
	of local variables and use Is_Generic_Subprogram predicate.
	(process_decls): Likewise.
2022-05-19 14:05:28 +00:00
Eric Botcazou
3b0cd3f02e [Ada] Do not override inlining heuristics for expression functions at -Os
gcc/ada/

	* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Do not deal with
	inlining heuristics for expression functions here but...
	* gcc-interface/decl.cc (inline_status_for_subprog): ...here instead
	and do not override them at -Os.
2022-05-19 14:05:28 +00:00
Piotr Trojanek
20c932f30b [Ada] Remove dead code for scope entity having E_Subprogram_Body kind
In GNAT AST the Scope field always points to the semantic scope (e.g.
subprogram) and never to syntactic scope (e.g. subprogram body).

Cleanup related to handling of circular access-to-record types.

gcc/ada/

	* gcc-interface/decl.cc (gnat_to_gnu_entity): Remove dead code
	which expected Scope to return E_Subprogram_Body entity.
2022-05-19 14:05:27 +00:00
Giuliano Belinassi
16e02662c0 PR105647 Update pr105169* so it does not fail on powerpc64le
On powerpc64le, the tests related to pr105169 failed because the
.localentry was not on a power of two address due to the extra nop
instruction taking one byte and thus moving its position one byte
further. Generating two nops instead moves .localentry to a valid
position.

gcc/testsuite/ChangeLog
2022-05-18  Giuliano Belinassi  <gbelinassi@suse.de>

	PR target/105647
	* g++.dg/modules/pr105169_a.C: Change -fpatchable-function-entry to 2.
	* g++.dg/modules/pr105169_b.C: Likewise.
2022-05-19 10:00:09 -03:00
David Malcolm
19258b1138 analyzer: update docs about -fanalyzer-checker=taint
gcc/ChangeLog:
	* doc/invoke.texi (-fanalyzer-checker=): Add
	-Wanalyzer-va-list-leak and -Wanalyzer-va-list-use-after-va-end to
	the list of analyzer warnings disabled by
	-fanalyzer-checker=taint.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-05-19 08:50:54 -04:00
Jakub Jelinek
213cfa8d0a cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR105630]
This is similar to the earlier patch to avoid having MEM_EXPRs
referencing global vars without varpool nodes, but this time
the difference is that during gimplification some hashing
actually created DECL_RTLs for the n VAR_DECL and the previous
change was in the if above this when DECL_RTL is NULL and we are
considering creating it.

The following patch drops on the floor references to vars where
we've optimized away the varpool node even when it has DECL_RTL.

Bootstrapped/regtested on x86_64-linux and i686-linux, plus
bootstrapped on those without the cfgexpand.cc change, reapplied
it and rebuilt stage3 cc1/cc1plus, the resulting cc1/cc1plus
binaries on both targets were identical except for the 16-byte
executable_checksum (I've done the second bootstraps in the same
directory as the first one after moving the previous one elsewhere,
so pathnames were the same, just checksum hasn't been regenerated).
So, at least on those binaries this patch doesn't affect debug info
at all.

2022-05-19  Jakub Jelinek  <jakub@redhat.com>

	PR debug/105630
	* cfgexpand.cc (expand_debug_expr): For VAR_DECL, punt for
	global vars without symtab node even when they have DECL_RTL
	set.

	* gcc.dg/pr105630.c: New test.
2022-05-19 11:58:15 +02:00
Jakub Jelinek
3b4daa0b3c pointer-query: Fix ICE with non-pointer param [PR105635]
The gimple_parm_array_size function comment talks about pointe parameters
but doesn't actually verify it, it checks whether an attribute is present
on the function and then just uses TREE_TYPE (TREE_TYPE (var)) which
assumes a pointer type (or in theory could work for ARRAY_TYPE but
c-family languages which only have that attribute will never have ARRAY_TYPE
parameters; and for VECTOR_TYPE/COMPLEX_TYPE it would mean something quite
different).

So, this patch punts early if var doesn't have pointer/reference type.

2022-05-19  Jakub Jelinek  <jakub@redhat.com>

	PR c/105635
	* pointer-query.cc (gimple_parm_array_size): Return NULL if var
	doesn't have pointer or reference type.

	* gcc.dg/pr105635.c: New test.
2022-05-19 11:57:36 +02:00
Julia Lapenko
b8944f0438 compiler: traverse expressions when exporting constants
When exporting a constant A that is expressed through a constant
B from another package, it is necessary to traverse an expression
representing the constant A to generate a sequence of type casts
from the constant B. Current implementation doesn't collect types
of constants contained in such expressions. This change fetches
these types.

Fixes golang/go#51291

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405976
2022-05-18 19:34:49 -07:00
GCC Administrator
1cda629f96 Daily bump. 2022-05-19 00:16:32 +00:00
Marek Polacek
7da9a08960 c: Implement new -Wenum-int-mismatch warning [PR105131]
In C, an enumerated type is compatible with char, a signed integer type,
or an unsigned integer type (6.7.2.2/5).  Therefore this code compiles:

  enum E { l = -1, z = 0, g = 1 };
  int foo(void);
  enum E foo(void) { return z; }

if the underlying type of 'enum E' is 'int' (if not, we emit an error).
This is different for typedefs, where C11 permits typedefs to be
redeclared to the same type, but not to compatible types.  In C++, the
code above is invalid.

It seems desirable to emit a warning in the C case, because it is
probably a mistake and definitely a portability error, given that the
choice of the underlying type is implementation-defined.

To that end, this patch implements a new -Wenum-int-mismatch warning.
Conveniently, we already have comptypes_check_enum_int to detect such
mismatches.  This warning is enabled by either -Wall or -Wc++-compat.

	PR c/105131

gcc/c-family/ChangeLog:

	* c.opt (Wenum-int-mismatch): New.

gcc/c/ChangeLog:

	* c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type
	mismatches.
	* c-tree.h (comptypes_check_enum_int): Declare.
	* c-typeck.cc (comptypes): No longer static.

gcc/ChangeLog:

	* doc/invoke.texi: Document -Wenum-int-mismatch.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wenum-int-mismatch-1.c: New test.
	* gcc.dg/Wenum-int-mismatch-2.c: New test.
	* gcc.dg/Wenum-int-mismatch-3.c: New test.
	* gcc.dg/Wenum-int-mismatch-4.c: New test.
	* gcc.dg/Wenum-int-mismatch-5.c: New test.
2022-05-18 17:43:56 -04:00
Paul A. Clarke
1875214cd1 Revert move of g++.dg/pr69667.C
Commit eccbd7fcee moved the subject file to
g++.target/powerpc.  Unfortunately, test g++.dg/tsan/pr88018.C includes
"../pr69667.C".

Revert the move of this file.

Commit 14e678a2c4 relaxed some DejaGnu
directives in g++.dg/tsan/pr88018.C, given its more restrictive environment
within g++.target/powerpc.  Revert these changes in that file as well.

2022-05-18  Paul A. Clarke  <pc@us.ibm.com>

gcc/testsuite
	PR target/105620
	* g++.target/powerpc/pr69667.C: Move to ...
	* g++.dg/pr69667.C: here. Also, revert recent dg directives changes.
2022-05-18 15:45:56 -05:00
Uros Bizjak
c86b726c04 x86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACK
Since commit c163647ffb -fsplit-stack
is only supported on glibc targets. However, this original commit
required some fixups. As part of the fixup, the changes to the
gnu-user-common.h and gnu.h were partially reverted in commit
60953a23d5 thus causing TARGET_CAN_SPLIT_STACK
to be defined for non-glibc targets even though -fsplit-stack is
actually not supported and attempting to use it causes a runtime error.

This causes gcc internal code, such as ./gcc/go/gospec.c to not
correctly detect that -fsplit-stack is not supported and thus causes
gccgo to fail compilation on non-glibc targets.

This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the
default libc is glibc. It is presently unclear to me if there is a
better way to detect glibc at pre-processor time.

The proposed changes have been tested on x86 and x86_64 Alpine Linux
(which uses musl libc) and fix compilation of gccgo for this target.

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>

gcc/ChangeLog:

	* config/i386/gnu-user-common.h (defined): Only define
	TARGET_CAN_SPLIT_STACK for glibc targets.
	* config/i386/gnu.h (defined): Ditto.
2022-05-18 20:10:24 +02:00
Roger Sayle
4a9be8d511 Correct ix86_rtx_cost for multi-word multiplication.
This is the i386 backend specific piece of my revised patch for
PR middle-end/98865, where Richard Biener has suggested that I perform
the desired transformation during RTL expansion where the backend can
control whether it is profitable to convert a multiplication into a
bit-wise AND and a negation.  This works well for x86_64, but alas
exposes a latent bug with -m32, where a DImode multiplication incorrectly
appears to be cheaper than negdi2+anddi3(!?).  The fix to ix86_rtx_costs
is to report that a DImode (multi-word) multiplication actually requires
three SImode multiplications and two SImode additions.  This also corrects
the cost of TImode multiplication on TARGET_64BIT.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/i386/i386.cc (ix86_rtx_costs) [MULT]: When mode size
	is wider than word_mode, a multiplication costs three word_mode
	multiplications and two word_mode additions.
2022-05-18 16:23:01 +01:00
Roger Sayle
30405ccc14 Avoid andn and generate shorter not;and with -Oz on x86.
The x86 instruction encoding for SImode andn is longer than the
equivalent notl/andl sequence when the source for the not operand
is the same register as the destination.  This patch adds post_reload
splitters to i386.md to avoid "-mbmi" (which enables andn) increasing
code size with "-Oz".

One minor subtlety with this patch is that the splitter for
*andn_si_ccno swaps the order of operands (match_dup 2 and match_dup 3)
as memory operands need to appear first in *test<mode>_1 patterns.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/i386/i386.md (define_split):  Split *andsi_1
	and *andn_si_ccno after reload with -Oz.

gcc/testsuite/ChangeLog
	* gcc.target/i386/bmi-andn-3.c: New test case.
2022-05-18 16:18:22 +01:00
Marek Polacek
60fdce11dc c, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]
This PR complains that we emit the "enumeration value not handled in
switch" warning even though the enumerator was marked with the
[[maybe_unused]] attribute.

I couldn't just check TREE_USED, because the enumerator could have been
used earlier in the function, which doesn't play well with the
c_do_switch_warnings warning.  Instead, I had to check the attributes on
the CONST_DECL.  This is easy since the TYPE_VALUES of an enum type are
now consistent between C and C++, both of which store the CONST_DECL in
its TREE_VALUE.

	PR c++/105497

gcc/c-family/ChangeLog:

	* c-warn.cc (c_do_switch_warnings): Don't warn about unhandled
	enumerator when it was marked with attribute unused.

gcc/testsuite/ChangeLog:

	* c-c++-common/Wswitch-1.c: New test.
	* g++.dg/warn/Wswitch-4.C: New test.
2022-05-18 10:34:30 -04:00
Marek Polacek
dfe38b8d5d c++: fix SIGFPE with -Wclass-memaccess [PR105634]
Here we crash because we attempt to % by 0.  Thus fixed.
While at it, I've moved the -Wclass-memaccess tests into warn/.
I've checked that the # of expected passes is the same before/after
the move.

	PR c++/105634

gcc/cp/ChangeLog:

	* call.cc (maybe_warn_class_memaccess): Avoid % by zero.

gcc/testsuite/ChangeLog:

	* g++.dg/Wclass-memaccess-2.C: Moved to...
	* g++.dg/warn/Wclass-memaccess-2.C: ...here.
	* g++.dg/Wclass-memaccess-3.C: Moved to...
	* g++.dg/warn/Wclass-memaccess-3.C: ...here.
	* g++.dg/Wclass-memaccess-4.C: Moved to...
	* g++.dg/warn/Wclass-memaccess-4.C: ...here.
	* g++.dg/Wclass-memaccess-5.C: Moved to...
	* g++.dg/warn/Wclass-memaccess-5.C: ...here.
	* g++.dg/Wclass-memaccess-6.C: Moved to...
	* g++.dg/warn/Wclass-memaccess-6.C: ...here.
	* g++.dg/Wclass-memaccess.C: Moved to...
	* g++.dg/warn/Wclass-memaccess.C: ...here.
	* g++.dg/warn/Wclass-memaccess-7.C: New test.
2022-05-18 10:33:13 -04:00
Eric Botcazou
0d189b16f8 Reduce usage of limited_with clauses with -fdump-ada-spec
The problem is that subtypes are not part of the limited view of a package
so we need to use types in conjunction with limited_with clauses, which is
not always desirable as this yields less portable Ada bindings.  The patch
also contains a small enhancement for complex floating-point types.

gcc/c-family/
	* c-ada-spec.cc (dump_ada_node) <COMPLEX_TYPE>: Deal with usual
	floating-point complex types.
	<POINTER_TYPE>: Do not use limited_with clause if the designated
	type is a scalar type.
2022-05-18 16:30:48 +02:00
Kewen Lin
297a69068d testsuite/rs6000: Move pr83660.C to g++.target
Move pr83660.C to g++.target.  As comment #3 of PR83660,
rename it to c isn't one option.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr83660.C: Moved to...
	* g++.target/powerpc/pr83660.C: ...here.
2022-05-18 09:08:10 -05:00
Frederik Harwath
21e2bc9fb4 graphite: Extend SCoP detection dump output
Extend dump output to make understanding why Graphite rejects to
include a loop in a SCoP easier (for GCC developers).

gcc/ChangeLog:

	* graphite-scop-detection.cc (scop_detection::can_represent_loop):
	Output reason for failure to dump file.
	(scop_detection::harmful_loop_in_region): Likewise.
	(scop_detection::graphite_can_represent_expr): Likewise.
	(scop_detection::stmt_has_simple_data_refs_p): Likewise.
	(scop_detection::stmt_simple_for_scop_p): Likewise.
	(print_sese_loop_numbers): New function.
	(scop_detection::add_scop): Use from here.

gcc/testsuite/ChangeLog:

	* gcc.dg/graphite/scop-22a.c: New test.
2022-05-18 14:51:46 +02:00
Nathan Sidwell
65851d65fb demangler: Reorganize for module demangling
Module demangling requires some changes in how substitutions are
handled.  This adjusts things to make that possible.

	libiberty/
	* cp-demangle.c (d_name): Add SUBSTABLE parameter,
	push substitution if requested. Adjust unscoped name handling.
	(d_prefix): Reorder main loop. Adjust all calls.
	(d_unqualified_name): Add SCOPE parameter, create qualified
	name here. Adjust all calls.
	(cplus_demangle_type): Do not handle 'S' here, leave all
	to d_class_enum_type.
	(d_class_enum_type): Add SUBSTABLE parameter.
2022-05-18 03:58:55 -07:00
Thomas Schwinge
86f64400a5 'include/cuda/cuda.h': Add parts necessary for nvptx-tools 'nvptx-run'
include/
	* cuda/cuda.h (enum CUjit_option): Add
	'CU_JIT_GENERATE_DEBUG_INFO', 'CU_JIT_GENERATE_LINE_INFO'.
	(enum CUlimit): Add 'CU_LIMIT_STACK_SIZE',
	'CU_LIMIT_MALLOC_HEAP_SIZE'.
	(cuCtxSetLimit, cuGetErrorName): Add.
2022-05-18 12:06:20 +02:00
Thomas Schwinge
bdd1dc1bfb 'include/cuda/cuda.h': For C++, wrap in 'extern "C"'
include/
	* cuda/cuda.h: For C++, wrap in 'extern "C"'.
2022-05-18 12:06:20 +02:00
Tobias Burnus
ba8563693f OpenMP: Add Fortran support for inoutset depend-kind
Fortran additions to the C/C++ + ME/libgomp commit
r13-556-g2c16eb3157f86ae561468c540caf8eb326106b5f

gcc/fortran/ChangeLog:

	* gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET.
	(gfc_omp_clauses): Enlarge ENUM_BITFIELD.
	* dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle
	'inoutset' depend modifier.
	* openmp.cc (gfc_match_omp_clauses, gfc_match_omp_depobj): Likewise.
	* trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj):
	Likewise.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.1): Set 'inoutset' to Y.
	(OpenMP Context Selectors): Add missing comma.
	* testsuite/libgomp.fortran/depend-5.f90: Add inoutset test.
	* testsuite/libgomp.fortran/depend-6.f90: Likewise.
	* testsuite/libgomp.fortran/depend-7.f90: Likewise.
	* testsuite/libgomp.fortran/depend-inoutset-1.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/all-memory-1.f90: Add inoutset test.
	* gfortran.dg/gomp/all-memory-2.f90: Likewise.
	* gfortran.dg/gomp/depobj-1.f90: Likewise.
	* gfortran.dg/gomp/depobj-2.f90: Likewise.
2022-05-18 12:04:21 +02:00
Claire Dross
9f068ad0f2 [Ada] Fix proof of runtime unit s-imageu
Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

	* libgnat/s-imageu.adb (Set_Image_Unsigned): Change assertion.
2022-05-18 08:41:09 +00:00
Doug Rupp
17cd8bf5a4 [Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtramp
Fix compilation warning. The code was using a cast to struct sigcontext
*, which doesn't exist. It worked by accident.

gcc/ada/

	* sigtramp-qnx.c: Change struct sigcontext * to mcontext_t *.
2022-05-18 08:41:09 +00:00
Doug Rupp
6999173410 [Ada] arm-qnx-7.1: stack-checking and sigtramp implementation
Rewrite and base on VxWorks RTP implementation.

gcc/ada/

	* sigtramp-arm-qnx.c: Rewrite.
2022-05-18 08:41:08 +00:00
Yannick Moy
c6c9b82bc1 [Ada] Adapt proof of double arithmetic runtime unit
After changes in Why3 and generation of VCs, ghost code needs to be
adapted for proofs to remain automatic.

gcc/ada/

	* libgnat/s-aridou.adb (Big3): Change return type.
	(Lemma_Mult_Non_Negative, Lemma_Mult_Non_Positive): Reorder
	alphabetically.
	(Lemma_Concat_Definition, Lemma_Double_Big_2xxsingle): New
	lemmas.
	(Double_Divide, Scaled_Divide): Add assertions.
2022-05-18 08:41:08 +00:00
Claire Dross
6f8f9d1bcf [Ada] Fix proof of runtime unit s-valeu
Update to provers caused some proof regressions.  Fix the proof by
changing ghost code.

gcc/ada/

	* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertions.
2022-05-18 08:41:08 +00:00
Kévin Le Gouguec
df4451ca66 [Ada] Make sure output variable is always initialized
gcc/ada/

	* libgnat/s-dwalin.adb (Read_Aranges_Header): Initialize output
	parameter in case we return early.
2022-05-18 08:41:07 +00:00
Bob Duff
8502433d82 [Ada] Disable Vet calls when container checks are disabled
Calls to various Vet functions are used throughout the containers
packages to check internal consistency. This patch improves efficiency
by disabling these calls when Container_Checks are suppressed.

gcc/ada/

	* libgnat/a-crbtgo.ads, libgnat/a-rbtgbo.ads,
	libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
	libgnat/a-cbhase.adb, libgnat/a-cdlili.adb,
	libgnat/a-cfdlli.adb, libgnat/a-cfhama.adb,
	libgnat/a-cfhase.adb, libgnat/a-cidlli.adb,
	libgnat/a-cihama.adb, libgnat/a-cihase.adb,
	libgnat/a-cohama.adb, libgnat/a-cohase.adb,
	libgnat/a-crbtgo.adb, libgnat/a-crdlli.adb, libgnat/a-rbtgbo.adb
	(Vet): Make the Vet functions do nothing when
	Container_Checks'Enabled is False, and inline them, so the calls
	disappear when optimizing.
2022-05-18 08:41:07 +00:00
Doug Rupp
db67182120 [Ada] arm-qnx-7.1: undefined reference to fma* symbols
Configure the arm-qnx runtime packages to avoid generating these
symbols.

gcc/ada/

	* Makefile.rtl (arm-qnx): Use default (non-fma) target pair.
2022-05-18 08:41:07 +00:00
Kévin Le Gouguec
91b46ee298 [Ada] Fix DWARF parsing for 32-bit targets on 64-bit hosts
Currently, a 64-bit gnatsymbolize fails to output line numbers and
accurate symbol names when run on 32-bit executables (and vice-versa).
This is because a couple of spots in System.Dwarf_Lines expect the
Address_Size found in the DWARF data to match the host Address'Size.

This patch corrects that assumption.

gcc/ada/

	* libgnat/s-dwalin.adb (Aranges_Lookup, Enable_Cache): Adapt to
	changes in the signature of Read_Aranges_*.
	(Debug_Info_Lookup): Do not control address size read from
	DWARF.
	(Read_Aranges_Header): Do not control address size read from
	DWARF; return this size.
	(Read_Aranges_Entry): Use the size returned by
	Read_Aranges_Header.
2022-05-18 08:41:07 +00:00
Gary Dismukes
72de114c23 [Ada] Improve error messages for occurrence of GNAT extensions without -gnatX
The error message issued for use of GNAT extension features without
specifying -gnatX (or pragma Extensions_Allowed) was confusing in the
presence of a pragma specifying a language version (such as "pragma
Ada_2022;"), because the pragma supersedes the switch.  The message is
improved by testing for use of such a pragma, plus use of pragma
Extensions_Allowed is now suggested, and several cases are changed to
call the common error procedure for flagging uses of extension features.

gcc/ada/

	* errout.ads (Error_Msg_GNAT_Extension): Add formal Loc and
	revise comment.
	* errout.adb (Error_Msg_GNAT_Extension): Condition message on
	the flag Ada_Version_Pragma, and add suggestion to use of pragma
	Extensions_Allowed in messages.
	* par-ch3.adb, par-ch5.adb, par-ch6.adb, par-ch11.adb,
	par-ch12.adb: Add actual Token_Ptr on calls to
	Error_Msg_GNAT_Extension.
	* par-ch4.adb: Change Error_Msg to Error_Msg_GNAT_Extension for
	error calls related to use of extension features.
	* sem_ch13.adb: Likewise.
2022-05-18 08:41:06 +00:00
Johannes Kliemann
b271095d50 [Ada] Fix Ada-QNX task priority conversion
The conversion between OS and Ada priorties should be done in the wider
Interfaces.C.int type rather than Any_Priority otherwise
Constraint_Error will be raised when coverting Any_Priority'Last to int.

gcc/ada/

	* libgnarl/s-osinte__qnx.adb (To_Target_Priority): Perform
	arithmetic in int.
2022-05-18 08:41:06 +00:00