Commit Graph

193561 Commits

Author SHA1 Message Date
Justin Squirek
507ed659e0 [Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects
This patch corrects an error in the compiler whereby spurious
unreferenced warnings are generated on formal parameters of null generic
subprograms.

These changes also fix the parsing of aspects on formal parameters such
that the aspects now get properly set for all formal parameters in a
parameter list.

gcc/ada/

	* par-ch6.adb (P_Formal_Part): Set Aspect_Specifications on all
	formals instead of just the last in a formal id list.
	* sem_ch6.adb (Analyze_Null_Procedure): Mark expanded null
	generic procedures as trivial in order to avoid spurious
	unreferenced warnings.
2022-05-30 08:29:03 +00:00
Romain Beguet
f55e8fd165 [Ada] Fix illegal Ada in s-dwalin.adb
Both the `System.Mmap` and `System.Object_Reader` packages are defining
entities named `Offset` and they are both `use`d at the top of
s-dwalin.adb.

Therefore, the references to `Offset` throughout this file are
ambiguous, and GNAT is supposed to complain. Since it does not for the
moment, we fix the ambiguity by declaring a subtype `Offset` at the top
of the file simply renames `System.Object_Reader.Offset`.

gcc/ada/

	* libgnat/s-dwalin.adb: Add a subtype declaration to fix the
	ambiguity.
2022-05-30 08:29:03 +00:00
Steve Baird
ebddfe50d8 [Ada] Incorrect determination of whether an expression is predicate-static
The expression given in a Static_Predicate aspect specification is
required to be predicate-static. The implementation of this compile-time
check was incorrect in some cases. There were problems in both
directions: expressions that are not predicate-static were incorrectly
treated as though they were and vice versa. This led to both accepting
invalid code and to rejecting valid code.

gcc/ada/

	* sem_ch13.adb (Is_Predicate_Static): Do not generate warnings
	about subexpressions of enclosing expressions. Generate warnings
	for predicates that are known to be always true or always false,
	except in the case where the predicate is expressed as a Boolean
	literal. Deal with non-predicate-static expressions that have
	been transformed into predicate-static expressions.  Add missing
	Is_Type_Ref call to N_Membership_Test case.
2022-05-30 08:29:03 +00:00
Eric Botcazou
567bf44932 [Ada] Fix expansion of aggregate for discriminated limited extension
The presence of the discriminants prevents the values associated with the
components of the parent type from being put into the sub-aggregate built
for the _Parent component.

gcc/ada/

	* exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End_Aggregate):
	Skip the discriminants at the start of the component list before
	looking for the components inherited from the parent in the case
	of a tagged extension.
2022-05-30 08:29:02 +00:00
Eric Botcazou
878ded4f9a [Ada] Do not freeze specifically for dispatch tables
The left-overs of the old freezing code in Make_DT are now redundant since
the semantic analyzer performs the same task for the 'Access attribute.

gcc/ada/

	* exp_disp.adb (Make_DT): Remove remaining freezing code.
2022-05-30 08:29:02 +00:00
Eric Botcazou
79b7ab68bc [Ada] Do not analyze expression functions for dispatch tables
There is no need to analyze expression functions that are primitives of a
tagged type for its dispatch table because they will be analyzed at the end
of the current scope.

gcc/ada/

	* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Don't analyze
	the body of an expression function in the case of a dispatch table.
2022-05-30 08:29:02 +00:00
Arnaud Charlet
764169055b [Ada] Introduce Opt.CCG_Mode
To handle code common to the old and the new CCG code generator.

gcc/ada/

	* gnat1drv.adb, opt.ads, sem_ch7.adb: Introduce CCG_Mode.
2022-05-30 08:29:02 +00:00
Yannick Moy
40e01041b3 [Ada] Update proofs of double arithmetic unit after prover changes
Changes in GNATprove (translation to Why3 and provers) result in proofs
being much less automatic, and requiring ghost code to detail
intermediate steps. In some cases, it is better to use the new By
mechanism to prove assertions in steps, as this avoids polluting the
proof context for other proofs. For that reason, add units s-spark.ads
and s-spcuop.ads/b to the runtime sources.

gcc/ada/

	* Makefile.rtl: Add new units.
	* libgnat/s-aridou.adb (Scaled_Divide): Add ghost code for provers.
	* libgnat/s-spcuop.adb: New unit for ghost cut operations.
	* libgnat/s-spcuop.ads: New unit for ghost cut operations.
	* libgnat/s-spark.ads: New unit.
2022-05-30 08:29:02 +00:00
Alexandre Oliva
33dec214f0 [Ada] Tweaks to hardening docs
Mention when security hardening features are available in other
languages.

Expand the strub documentation a little, for clarity and completeness.

Add missing 'aliased' and attribute to variables in strub example.

gcc/ada/

	* doc/gnat_rm/security_hardening_features.rst: Mention
	availability in other languages when applicable.
	(Stack Scrubbing): Associate the attribute with types, expand
	some comments, fix the example involving access to variables.
	* gnat_rm.texi: Regenerate.
2022-05-30 08:29:02 +00:00
Piotr Trojanek
4609660b77 [Ada] Fix typo in comment for functional sets
Minor fix in a recently added comment.

gcc/ada/

	* libgnat/a-cofuse.ads (Empty_Set): Fix typo in comment.
2022-05-30 08:29:01 +00:00
Eric Botcazou
fabf93dc1a [Ada] Restore hiding of predefined "=" operator through class-wide type
The previous change introduced a backward incompatibility in the handling
of a user-defined "=" operator for a class-wide type of a tagged type: it
would previously hide the predefined "=" operator of the tagged type in
the private case, but it no longer does in this case, while it still does
in the nonprivate case.

This hiding is a non-portability, but is fundamentally what the compiler
implements, instead of the RM rule which requires homographs.  The reason
lies in the implementation of the "=" operator in GNAT: internally, there
is not a "=" predefined operator for every nonlimited type, but instead
there is a single, universal "=" predefined operator for all the nonlimited
types.  The consequence is that the hiding rule implemented in GNAT for "="
is effectively that a user-declared symmetrical "=" operator returning
boolean hides the predefined "=" operator of any type that is covered by
the user-declared operator.

Whether it is desirable to implement the exact RM rule in GNAT is to be
discussed, but existing code relies on the non-portability and would thus
need to be changed.

gcc/ada/

	* sem_ch6.adb (New_Overloaded_Entity): Deal specifically with the
	overriding of the "=" operator for tagged types.
2022-05-30 08:29:01 +00:00
Eric Botcazou
3e93d2926a [Ada] Do not freeze profiles for dispatch tables
When static dispatch tables are built for library-level tagged types, the
primitives (the subprogram themselves) are frozen; that's necessary because
their address is taken.  However, their profile, i.e. all the types present
therein, is also frozen, which is not necessary after AI05-019 and is also
inconsistent with the handling of attribute references.

The change also removes a couple of pragma Inline on subprograms that are
too large for inlining to bring any benefit.

gcc/ada/

	* exp_ch3.adb (Expand_N_Object_Declaration): Adjust call to Make_DT.
	* exp_disp.ads (Building_Static_DT): Remove pragma Inline.
	(Building_Static_Secondary_DT): Likewise.
	(Convert_Tag_To_Interface): Likewise.
	(Make_DT): Remove second parameter.
	* exp_disp.adb (Make_DT): Likewise.
	(Check_Premature_Freezing): Delete.
	Pass Do_Freeze_Profile as False in call to Freeze_Entity.
	* freeze.ads (Freezing_Library_Level_Tagged_Type): Delete.
	* freeze.adb (Freeze_Profile): Remove obsolete code.
	(Freeze_Entity): Tweak comment.
2022-05-30 08:29:01 +00:00
Yannick Moy
1ea22318ca [Ada] Adapt proof of runtime unit s-arit32
After changes in GNATprove, adapt proof. Simply move an assertion up
before it is first needed here.

gcc/ada/

	* libgnat/s-arit32.adb (Scaled_Divide32): Move assertion up.
2022-05-30 08:29:01 +00:00
Yannick Moy
5b7630f2f2 [Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit
The internal unit System.Generic_Array_Operations defines only generic
subprograms. Thus, pragma Assertion_Policy inside the spec has no
effect, as each instantiation is only subject to the assertion policy at
the program point of the instantiation. Remove this confusing pragma,
and add the pragma inside each generic body making use of additional
assertions or ghost code, so that running time of instantiations is not
impacted by assertions meant for formal verification.

gcc/ada/

	PR ada/105303
	* libgnat/s-gearop.adb: Add pragma Assertion_Policy in generic
	bodies making use of additional assertions or ghost code.
	* libgnat/s-gearop.ads: Remove confusing Assertion_Policy.
2022-05-30 08:29:01 +00:00
Steve Baird
55c19dda8c [Ada] Delete no-longer-used Convert_To_Return_False flag
As a result of other recent changes, the Convert_To_Return_False flag
is never set. The flag can be therefore be deleted.

gcc/ada/

	* exp_ch11.adb (Expand_N_Raise_Expression): Remove
	Convert_To_Return_False test.
	* gen_il-fields.ads: Remove Convert_To_Return_False field.
	* gen_il-gen-gen_nodes.adb: Remove use of
	Convert_To_Return_False field.
	* sinfo.ads: Remove comment describing Convert_To_Return_False
	flag.
2022-05-30 08:29:01 +00:00
Julien Bortolussi
efaee961d9 [Ada] Add empty constructors to the functional containers
This patch adds empty constructors to the functional containers so that
we can use them in expression functions.

gcc/ada/

	* libgnat/a-cofuma.ads, libgnat/a-cofuma.adb,
	libgnat/a-cofuse.ads, libgnat/a-cofuse.adb,
	libgnat/a-cofuve.ads, libgnat/a-cofuve.adb: Add empty
	constructors.
2022-05-30 08:29:01 +00:00
Ghjuvan Lacambre
96b2e17066 [Ada] Fix new CUDA kernel registration scheme
Removal of the previous kernel registration scheme unearthed mistakes in
the new one, which were:
- The new kernel registration code relied on the binder expansion phase,
  which didn't happen because the registration code was already
  generated by the binder.
- The kernel handle passed to CUDA_Register_Function was the first eight
  bytes of the code of the host-side procedure representing the kernel
  rather than its address.

gcc/ada/

	* bindgen.adb (Gen_CUDA_Init): Remove code generating CUDA
	definitions.
	(Gen_CUDA_Defs): New function, generating definitions
	initialized by Gen_CUDA_Init.
	(Gen_Output_File_Ada): Call Gen_CUDA_Defs instead of
	Gen_CUDA_Init.
	(Gen_Adainit): Call Gen_CUDA_Init.
2022-05-30 08:29:00 +00:00
Prathamesh Kulkarni
b4e04a78bb [ARM] Fix prototype for vec_perm_const hook.
gcc/ChangeLog:

	* config/arm/arm.cc (arm_vectorize_vec_perm_const): Adjust prototype.
2022-05-30 13:23:50 +05:30
Vineet Gupta
7915f65513 RISC-V/testsuite: constraint some of tests to hard_float
Commit 9ddd44b586 ("RISC-V: Provide `fmin'/`fmax' RTL pattern") added
tests which check for hard float instructions which obviously fails on
soft-float ABI builds.

And my recent commit b646d7d279 ("RISC-V: Inhibit FP <--> int register
moves via tune param") is guilty of same crime.

So constraint with "dg-require-effective-target hard_float"

This reduces bunch of new RV failures.

|               ========= Summary of gcc testsuite =========
|                            | # of unexpected case / # of unique unexpected case
|                            |          gcc |          g++ |     gfortran |
|   rv64imac/   lp64/ medlow |  134 /    22 |    0 /     0 |            - |  BEFORE
|   rv64imac/   lp64/ medlow |   22 /     9 |    0 /     0 |            - |  AFTER
|

gcc/testsuite/Changelog:
	* gcc.target/riscv/fmax.c: Add dg-require-effective-target hard_float.
	* gcc.target/riscv/fmaxf.c: Ditto.
	* gcc.target/riscv/fmin.c: Ditto.
	* gcc.target/riscv/fminf.c: Ditto.
	* gcc.target/riscv/smax-ieee.c: Ditto.
	* gcc.target/riscv/smax.c: Ditto.
	* gcc.target/riscv/smaxf-ieee.c: Ditto.
	* gcc.target/riscv/smaxf.c: Ditto.
	* gcc.target/riscv/smin-ieee.c: Ditto.
	* gcc.target/riscv/smin.c: Ditto.
	* gcc.target/riscv/sminf-ieee.c: Ditto.
	* gcc.target/riscv/sminf.c: Ditto.
	* gcc.target/riscv/pr105666.c: Ditto.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
2022-05-30 10:09:04 +08:00
GCC Administrator
05f220c205 Daily bump. 2022-05-30 00:16:21 +00:00
Jakub Jelinek
58a40e76eb libcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]
The first part of the following testcase (m1-m3 macros and its use)
regressed with my PR89971 fix, but as the m1,m4-m5 and its use part shows,
the problem isn't new, we can emit a CPP_PADDING token to avoid it from
being adjacent to whatever comes after the __VA_OPT__ (in this case there
is nothing afterwards, true).

In most cases these CPP_PADDING tokens don't matter, all other
callers of cpp_get_token_with_location either ignore CPP_PADDING tokens
completely (e.g. c_lex_with_flags) or they just remember them and
take them into account when printing stuff whether there should be
added whitespace or not (scan_translation_unit + token_streamer::stream).
So, I think we should just ignore CPP_PADDING tokens the same way in
_cpp_parse_expr.

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

	PR preprocessor/105732
	* expr.cc (_cpp_parse_expr): Handle CPP_PADDING by just another
	token.

	* c-c++-common/cpp/va-opt-10.c: New test.
2022-05-29 21:57:51 +02:00
Iain Sandoe
794737976b Darwin: Fix empty g++ command lines [PR105599].
An empty g++ command line should produce a diagnostic that there are no
inputs.  The PR is that currently Darwin produces a dignostic about missing
link items instead - this is because (errnoeously), for this driver, we are
creating a link job for empty command lines.

The problem occurs in four stages:

 The g++ driver appends -shared-libgcc to the command line.

 The Darwin driver_init code in the backend does not see this (it sees an
 empty command line).

 When the back end driver code driver sees an empty command line, it does not
 add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
 avoid anything being claimed as an input_file and therefore triggering a link
 line.

 Since we do not have a value for asm-macosx-version-min when processing the
 driver specs, we unconditionally inject 'multiply_defined suppress' which is
 used with shared libgcc (but only intended on very old Darwin).  This then
 causes the generation of a link job.

The solution, for the present, is to move version-specific link params to the
LINK_SPEC so that they are only processed when a link job has already been
decided.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

	PR target/105599

gcc/ChangeLog:

	* config/darwin.h: Move versions-specific handling of multiply_defined
	from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.
2022-05-29 19:27:14 +01:00
Eric Gallager
da5f0cc2f5 sourcebuild.texi: Document toplevel directories
Fixes PR82383

gcc/ChangeLog:

	PR other/82383
	* doc/sourcebuild.texi: Add entries for the c++tools,
	gotools, libbacktrace, libcc1, libcody, liboffloadmic,
	and libsanitizer directories. Remove entry for boehm-gc.
	Fix alphabetization for libquadmath.
2022-05-29 00:57:05 -04:00
GCC Administrator
37b3b5dabd Daily bump. 2022-05-29 00:16:31 +00:00
Joel Holdsworth
919822adc9 [PATCH 1/2] avr: Added AVR-DA and DB MCU series
gcc/
	* config/avr/avr-mcus.def: Add device definitions.
	* doc/avr-mmcu.texi: Corresponding changes.
	* config/avr/gen-avr-mmcu-texi.cc: Added support for avr
	device prefix.
	* config/avr/gen-avr-mmcu-specs.cc: Prevent -mmcu=avr* flags
	from leaking into cc1.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2022-05-28 13:17:39 -06:00
Tobias Burnus
e3803f9cbb OpenMP/Fortran: Add support for enter clause on declare target
Fortran version to C/C++ commit r13-797-g0ccba4ed8571c18c7015413441e971

gcc/fortran/ChangeLog:

	* dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER.
	* gfortran.h: Add OMP_LIST_ENTER.
	* openmp.cc (enum omp_mask2, OMP_DECLARE_TARGET_CLAUSES): Add
	OMP_CLAUSE_ENTER.
	(gfc_match_omp_clauses, gfc_match_omp_declare_target,
	resolve_omp_clauses): Handle 'enter' clause.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.2): Mark 'enter' clause as supported.
	* testsuite/libgomp.fortran/declare-target-1.f90: Extend to test
	explicit 'to' and 'enter' clause.
	* testsuite/libgomp.fortran/declare-target-2.f90: Update accordingly.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/declare-target-2.f90: Add 'enter' clause test.
	* gfortran.dg/gomp/declare-target-4.f90: Likewise.
2022-05-28 20:42:38 +02:00
Vladimir Makarov
ce1580252e Fix ICE on sh
gcc/
	PR target/103722
	* config/sh/sh.cc (sh_register_move_cost): Avoid cost "2" (which
	is special) for various scenarios.
2022-05-28 12:14:39 -06:00
Bruce Korb
ad8f6e2392 Vim swap files not ignored
ChangeLog:

	* .gitignore: Ignore vim swap files
2022-05-28 09:38:29 -06:00
Ian Lance Taylor
f535f9d7b0 libbacktrace: update README
PR libbacktrace/105721
	* README: Update.
2022-05-28 07:59:16 -07:00
Iain Sandoe
65aebf1987 Darwin: Amend REAL_LIBGCC_SPEC comment [NFC].
This comment had got out of sync with reality, partly due to merging
of patches.  Updated to reflect the current implementation.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/ChangeLog:

	* config/darwin.h (REAL_LIBGCC_SPEC): Update the comment block
	describing this macro.
2022-05-28 11:55:00 +01:00
Alexandre Oliva
163fa9a648 Rename OSCONS_CC to GCC_FOR_ADA_RTS
Several gnatlib* targets perform, with a subshell and sed, the same
GCC_FOR_TARGET pathname transformation that OSCONS_CC performs with
make subst macros.  Rename OSCONS_CC to a more general name, and use
it for gnatlib as well.


for  gcc/ada/ChangeLog

	* gcc-interface/Makefile.in (OSCONS_CC): Rename to...
	(GCC_FOR_ADA_RTS): ... this.  Adjust users.
	(gnatlib): Pass it down as CC.
	(gnatlib-shared-default): Likewise.
	(gnatlib-shared-win32, gnatlib-shared-darwin): Likewise.
2022-05-28 03:50:17 -03:00
Jakub Jelinek
42fd2cd932 libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]
since apparently _aligned_malloc requires freeing with _aligned_free and:
 /* Defined if gomp_aligned_alloc doesn't use fallback version
    and free can be used instead of gomp_aligned_free.  */
 #define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
so the second condition isn't satisfied.  For uses inside of the OpenMP
allocators we can still use _aligned_malloc but we need to call _aligned_free
in gomp_aligned_free.

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

	PR libgomp/105745
	* libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Don't define for
	defined(HAVE__ALIGNED_MALLOC) case.
	* alloc.c (gomp_aligned_alloc): Move defined(HAVE__ALIGNED_MALLOC)
	handling as last option before fallback instead of first.
	(gomp_aligned_free): For defined(HAVE__ALIGNED_MALLOC) call
	_aligned_free.
2022-05-28 08:30:47 +02:00
Jakub Jelinek
931249276a openmp: Adjust diagnostics about same variable in link and to/enter clauses
On Fri, May 27, 2022 at 04:52:17PM +0200, Tobias Burnus wrote:
> The 'TO'/'ENTER' usage is first stored in a linked list – and
> then as attribute to the symbol. I am not sure how to handle it best.

This reminds me I've left the C/C++ FE diagnostics about mixing link and
to/enter on the same variable in separate directives as is, so it always
talked about mixing link and to clauses.

This patch adjusts it, so that if link is first, it talks about the
clause actually used and if link is later, uses to or enter together
in the wording.

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

gcc/c/
	* c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was
	seen first, use "%<to%>" or "%<enter%>" depending on
	OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
	"%<to%> or %<enter%>" wording.
gcc/cp/
	* parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was
	seen first, use "%<to%>" or "%<enter%>" depending on
	OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
	"%<to%> or %<enter%>" wording.
gcc/testsuite/
	* c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of
	link and to/enter clauses on separate directives.
2022-05-28 08:30:15 +02:00
Jason Merrill
221acd67ca c++: lambda in concept [PR105652]
We currently check satisfaction in the context of the constrained
declaration (which may be wrong, see PR104111).  When checking C<int>
for S<int>, we currently substitute into the lambda in the context of
S<T> (rather than S<int>, which seems wrong if the above isn't wrong), so
the new closure type thinks its context is S<T>, which confuses debug
output.  For the moment, let's work around all of this by overriding the
context of the closure.

	PR c++/105652

gcc/cp/ChangeLog:

	* pt.cc (tsubst_lambda_expr): Don't let a namespace-scope lambda
	instantiate into a class-scope lambda.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-lambda20.C: New test.
2022-05-27 23:43:54 -04:00
GCC Administrator
d9176e643f Daily bump. 2022-05-28 00:16:40 +00:00
Iain Buclaw
610d789832 d: Merge upstream dmd 4d07f22f2, druntime f89da313, phobos d46814c86.
D front-end changes:

    - `scope' semantics are now enforced in `@safe' code on pointers to
      stack memory, but only as deprecation warnings.
    - Overriding virtual functions are now marked with the `override'
      and `final' in the generated headers of `-fdump-c++-spec='.
    - `-fpreview=fiximmmutableconv` has been added that disallows
      implicitly converting a return value with indirections to
      immutable if it determines the result must be unique.

D runtime changes:

    - Posix (excluding Darwin): Switch default GC signals from SIGUSR1/2
      to SIGRTMIN/SIGRTMIN+1

Phobos changes:

    - Import latest bug fixes to mainline.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 4d07f22f2
	* d-lang.cc (d_handle_option): Handle OPT_fpreview_fiximmutableconv.
	* lang.opt (fpreview=fiximmutableconv): New option.
	* runtime.def (ARRAYAPPENDT): Remove.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime f89da313.
	* src/MERGE: Merge upstream phobos d46814c86.

Signed-off-by: Iain Buclaw <ibuclaw@gdcproject.org>
2022-05-27 20:19:02 +02:00
Marek Polacek
d822f4bbd7 c++: Fix ICE with -Wmismatched-tags [PR105725]
Here we ICE with -Wmismatched-tags on something like

  template <class T>
  bool B<T, enable_if_t<is_class_v<class T::foo>>>;

Specifically, the "class T::foo" bit.  There, class_decl_loc_t::add gets
a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking
TYPE_BEING_DEFINED will crash.  I think it's OK to allow a TYPENAME_TYPE to
slip into that function; we just shouldn't consider the 'class' tag redundant
(which works as a 'typename').  In fact, every other compiler *requires* it.

	PR c++/105725

gcc/cp/ChangeLog:

	* parser.cc (class_decl_loc_t::add): Check CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wmismatched-tags-10.C: New test.
2022-05-27 12:01:51 -04:00
Marek Polacek
ca4b95069c c-family: fix attribute constructor ICE [PR90658]
Here the C compiler crashes because a FUNCTION_DECL got into
get_priority -> default_conversion, and the C FE's version of d_c
specifically asserts that it doesn't get a FUNCTION_DECL.  All uses
of default_conversion in c-attribs.cc are guarded by != IDENTIFIER_NODE
&& != FUNCTION_DECL, but get_priority was only checking IDENTIFIER_NODE.

	PR c/90658

gcc/c-family/ChangeLog:

	* c-attribs.cc (get_priority): Check FUNCTION_DECL.

gcc/testsuite/ChangeLog:

	* c-c++-common/attr-cdtor-1.c: New test.
2022-05-27 11:55:19 -04:00
Jonathan Wakely
de57440858 libstdc++: Mark non-exported function always_inline [PR105671]
This new function was added for gcc 11.1 but is not exported from the
shared library. Depending on inlining decisions, its callers might get
inlined but an external definition be needed for this function. That
then fails to link.

Since we can't add the export to the gcc-11 release branch now, mark it
always_inline. We can consider exporting it for gcc-13 if/when we bump
the shared library version (and maybe also for gcc-12 which is currently
at the same version as trunk). For now, the attribute will solve the
problem on all affected branches. The function is small enough that
force-inlining it shouldn't cause problems.

libstdc++-v3/ChangeLog:

	PR libstdc++/105671
	* include/std/sstream (basic_stringbuf::_M_high_mark): Add
	always_inline attribute.
2022-05-27 15:21:07 +01:00
Tobias Burnus
8af2665017 Fortran: Fix OpenMP clause name in error message
gcc/fortran/ChangeLog:

	* openmp.cc (gfc_check_omp_requires): Fix clause name in error.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/requires-4.f90: Update dg-error.
	* gfortran.dg/gomp/requires-8.f90: Update dg-error.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
2022-05-27 14:37:54 +02:00
Richard Biener
37c988bc1b Avoid shift in get_ref_base_and_extent
This avoids one instance of a shift from bytes to bits in
get_ref_base_and_extent by using TYPE_SIZE instead of TYPE_SIZE_UNIT.

	* tree-dfa.cc (get_ref_base_and_extent): Avoid shift.
2022-05-27 14:08:18 +02:00
Martin Jambor
f571596f8c
ipa: Check cst type when propagating controled uses info
PR 105639 shows that code with type-mismatches can trigger an assert
after runnning into a branch that was inteded only for references to
variables - as opposed to references to functions.  Fixed by moving
the condition from the assert to the guarding if statement.

gcc/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

	PR ipa/105639
	* ipa-prop.cc (propagate_controlled_uses): Check type of the
	constant before adding a LOAD reference.

gcc/testsuite/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

	PR ipa/105639
	* gcc.dg/ipa/pr105639.c: New test.
2022-05-27 13:06:02 +02:00
Jakub Jelinek
0ccba4ed85 openmp: Add support for enter clause on declare target
OpenMP 5.1 and earlier had 2 different uses of to clause, one for target
update construct with one semantics, and one for declare target directive
with a different semantics.
Under the hood we were using OMP_CLAUSE_TO_DECLARE to represent the latter.
OpenMP 5.2 renamed the declare target clause to to enter, the old one is
kept as a deprecated alias.

As we are far from having full OpenMP 5.2 support, this patch adds support
for the enter clause (and renames OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER
with a flag to tell the spelling of the clause for better diagnostics),
but doesn't deprecate the to clause on declare target just yet (that
should be done as one of the last steps in 5.2 support).

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

gcc/
	* tree-core.h (enum omp_clause_code): Rename OMP_CLAUSE_TO_DECLARE
	to OMP_CLAUSE_ENTER.
	* tree.h (OMP_CLAUSE_ENTER_TO): Define.
	* tree.cc (omp_clause_num_ops, omp_clause_code_name): Rename
	OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER.
	* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_ENTER
	instead of OMP_CLAUSE_TO_DECLARE, if OMP_CLAUSE_ENTER_TO, print
	"to" instead of "enter".
	* tree-nested.cc (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Handle OMP_CLAUSE_ENTER instead of
	OMP_CLAUSE_TO_DECLARE.
gcc/c-family/
	* c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_ENTER.
gcc/c/
	* c-parser.cc (c_parser_omp_clause_name): Parse enter clause.
	(c_parser_omp_all_clauses): For to clause on declare target, use
	OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
	OMP_CLAUSE_TO_DECLARE clause.  Handle PRAGMA_OMP_CLAUSE_ENTER.
	(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
	(c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
	OMP_CLAUSE_TO_DECLARE.
	* c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
	of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
	name in diagnostics instead of
	omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/cp/
	* parser.cc (cp_parser_omp_clause_name): Parse enter clause.
	(cp_parser_omp_all_clauses): For to clause on declare target, use
	OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
	OMP_CLAUSE_TO_DECLARE clause.  Handle PRAGMA_OMP_CLAUSE_ENTER.
	(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
	(cp_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
	OMP_CLAUSE_TO_DECLARE.
	* semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
	of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
	name in diagnostics instead of
	omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/testsuite/
	* c-c++-common/gomp/clauses-3.c: Add tests with enter clause instead
	of to or modify some existing to clauses to enter.
	* c-c++-common/gomp/declare-target-1.c: Likewise.
	* c-c++-common/gomp/declare-target-2.c: Likewise.
	* c-c++-common/gomp/declare-target-3.c: Likewise.
	* g++.dg/gomp/attrs-9.C: Likewise.
	* g++.dg/gomp/declare-target-1.C: Likewise.
libgomp/
	* testsuite/libgomp.c-c++-common/target-40.c: Modify some existing to
	clauses to enter.
	* testsuite/libgomp.c/target-41.c: Likewise.
2022-05-27 12:48:48 +02:00
Richard Biener
e7c482b080 tree-optimization/105726 - adjust array bound heuristic
There's heuristic to detect ptr[1].a[...] out of bound accesses
reasoning that if ptr points to an array of aggregates a trailing
incomplete array has to have size zero.  The following more
thoroughly constrains the cases this applies to avoid false
positive diagnostics.

2022-05-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105726
	* gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset):
	Constrain array-of-flexarray case more.

	* g++.dg/warn/Warray-bounds-27.C: New testcase.
2022-05-27 11:42:31 +02:00
Jakub Jelinek
e2f014fcef fold-const: Fix up -fsanitize=null in C++ [PR105729]
The following testcase triggers a false positive UBSan binding a reference
to null diagnostics.
In the FE we instrument conversions from pointer to reference type
to diagnose at runtime if the operand of such a conversion is 0.
The problem is that a GENERIC folding folds
((const struct Bar *) ((const struct Foo *) this)->data) + (sizetype) range_check (x)
conversion to const struct Bar & by converting to that the first
operand of the POINTER_PLUS_EXPR.  But that changes when the -fsanitize=null
binding to reference runtime check occurs.  Without the optimization,
it is invoked on the result of the POINTER_PLUS_EXPR, and as range_check
call throws, that means it never triggers in the testcase.
With the optimization, it checks whether this->data is NULL and it is.

The following patch avoids that optimization during GENERIC folding when
-fsanitize=null is enabled and it is a cast from non-REFERENCE_TYPE to
REFERENCE_TYPE.

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

	PR sanitizer/105729
	* fold-const.cc (fold_unary_loc): Don't optimize (X &) ((Y *) z + w)
	to (X &) z + w if -fsanitize=null during GENERIC folding.

	* g++.dg/ubsan/pr105729.C: New test.
2022-05-27 11:40:42 +02:00
Tobias Burnus
8255b49ed8 libgomp.texi: Add more to-be-implemented OpenMP 5.2 features
libgomp/
	* libgomp.texi (Other new OpenMP 5.1 features): Add
	'begin declare target'.
	(Other new OpenMP 5.2 features): New.
2022-05-27 10:19:45 +02:00
Roger Sayle
8fb94fc609 Canonicalize X&-Y as X*Y in match.pd when Y is [0,1].
"For every pessimization, there's an equal and opposite optimization".

In the review of my original patch for PR middle-end/98865, Richard
Biener pointed out that match.pd shouldn't be transforming X*Y into
X&-Y as the former is considered cheaper by tree-ssa's cost model
(operator count).  A corollary of this is that we should instead be
transforming X&-Y into the cheaper X*Y as a preferred canonical form
(especially as RTL expansion now intelligently selects the appropriate
implementation based on the target's costs).

With this patch we now generate identical code for:
int foo(int x, int y) { return -(x&1) & y; }
int bar(int x, int y) { return (x&1) * y; }

specifically on x86_64-pc-linux-gnu both use and/neg/and with -O2,
but both use and/mul with -Os.

One minor wrinkle/improvement is that this patch includes three
additional optimizations (that account for the change in canonical
form) to continue to optimize PR92834 and PR94786.

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

gcc/ChangeLog
	* match.pd (match_zero_one_valued_p): New predicate.
	(mult @0 @1): Use zero_one_valued_p for optimization to the
	expression "bit_and @0 @1".
	(bit_and (negate zero_one_valued_p@0) @1): Optimize to MULT_EXPR.
	(plus @0 (mult (minus @1 @0) zero_one_valued_p@2)): New transform.
	(minus @0 (mult (minus @0 @1) zero_one_valued_p@2)): Likewise.
	(bit_xor @0 (mult (bit_xor @0 @1) zero_one_valued_p@2)): Likewise.
	Remove three redundant transforms obsoleted by the three above.

gcc/testsuite/ChangeLog
	* gcc.dg/pr98865.c: New test case.
2022-05-27 09:01:13 +01:00
Roger Sayle
29ae455901 Pre-reload splitter to transform and;cmp into not;test on x86.
A common idiom for testing if a specific set of bits is set in a value
is to use "(X & Y) == Y", which on x86 results in an AND followed by a
CMP.  A slightly improved implementation is to instead use (~X & Y)==0,
that uses a NOT and a TEST (or ANDN where available); still two "fast"
instructions, but typically shorter especially if Y is an immediate
constant.  Because the above transformation would require more gimple
statements in SSA, and may only be a win on targets with flags registers,
it isn't performed by the middle-end, instead leaving this choice to
the backend.

As an example, here's the change in code generation for pr91400-1.c
[which now requires a tweak to its dg-final clauses].

Before:
        movl    __cpu_model+12(%rip), %eax
        andl    $68, %eax	// 3 bytes
        cmpl    $68, %eax	// 3 bytes
        sete    %al
        ret

After:
        movl    __cpu_model+12(%rip), %eax
        notl    %eax		// 2 bytes
        testb   $68, %al	// 2 bytes
        sete    %al
        ret

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

gcc/ChangeLog
	* config/i386/i386.md (*test<mode>_not): New define_insn_and_split
	to split a combined "and;cmp" sequence into "not;test".

gcc/testsuite/ChangeLog
	* gcc.target/i386/pr91400-1.c: Update for improved code generation.
	* gcc.target/i386/pr91400-2.c: Likewise.
	* gcc.target/i386/testnot-1.c: New test case.
	* gcc.target/i386/testnot-2.c: Likewise.
2022-05-27 08:52:03 +01:00
Richard Biener
c62643579d Close gcc-9 branch
This removes gcc-9 from getting DATESTAMP updates.

gcc/contrib/
	* gcc-changelog/git_update_version.py (active_refs): Remove
	releases/gcc-9.
2022-05-27 09:05:39 +02:00
Takayuki 'January June' Suwa
9aad2b2243 xtensa: Improve bswap[sd]i2 insn patterns
This patch makes bswap[sd]i2 better register allocation, and reconstructs
bswapsi2 in order to take advantage of GIMPLE manual byte-swapping
recognition.

gcc/ChangeLog:

	* config/xtensa/xtensa.md (bswapsi2): New expansion pattern.
	(bswapsi2_internal): Revise the template and condition, and add
	detection code for preceding the same insn in order to omit a
	"SSAI 8" instruction of the latter.
	(bswapdi2): Suppress built-in insn expansion with the corresponding
	library call when optimizing for size.

gcc/testsuite/ChangeLog:

	* gcc.target/xtensa/bswap.c: Remove test.
	* gcc.target/xtensa/bswap-O1.c: New.
	* gcc.target/xtensa/bswap-O2.c: Ditto.
	* gcc.target/xtensa/bswap-Os.c: Ditto.
2022-05-26 21:55:01 -07:00