Commit Graph

185017 Commits

Author SHA1 Message Date
GCC Administrator
6bcdcc522f Daily bump. 2021-07-29 00:18:27 +00:00
Martin Uecker
b2d98d7311 Correct a mistake in a warnung for -Wnonnull.
In the warning for -Wnonnull when warning about array parameters
with bounds > 0 and which are NULL the numbers referring to the
two arguments are switched. This patch corrects the mistake.

2021-07-28  Martin Uecker  <muecker@gwdg.de>

gcc/
	* calls.c (maybe_warn_rdwr_sizes): Correct argument
	numbers in warning that were switched.

gcc/testsuite/
	* gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.
2021-07-28 21:17:54 +02:00
Harald Anlauf
35c7067f7b Fortran: extend check for array arguments and reject CLASS array elements.
gcc/fortran/ChangeLog:

	PR fortran/101536
	* check.c (array_check): Adjust check for the case of CLASS
	arrays.

gcc/testsuite/ChangeLog:

	PR fortran/101536
	* gfortran.dg/pr101536.f90: New test.

(cherry picked from commit e314cfc371)
2021-07-28 21:14:20 +02:00
Harald Anlauf
1645998adc Fortran: ICE, OOM while calculating sizes of derived type array components
gcc/fortran/ChangeLog:

	PR fortran/101514
	* target-memory.c (gfc_interpret_derived): Size of array component
	of derived type can only be computed here for explicit shape.
	* trans-types.c (gfc_get_nodesc_array_type): Do not dereference
	NULL pointers.

gcc/testsuite/ChangeLog:

	PR fortran/101514
	* gfortran.dg/pr101514.f90: New test.

(cherry picked from commit c2b15fe27e)
2021-07-28 21:12:21 +02:00
Harald Anlauf
0b506dcf9f Fortran: reject FORMAT tag of unknown type.
gcc/fortran/ChangeLog:

	PR fortran/101084
	* io.c (resolve_tag_format): Extend FORMAT check to unknown type.

gcc/testsuite/ChangeLog:

	PR fortran/101084
	* gfortran.dg/fmt_nonchar_3.f90: New test.

(cherry picked from commit f527b82334)
2021-07-28 20:17:27 +02:00
Iain Buclaw
d3c268943c d: Wrong evaluation order of binary expressions (PR101640)
The use of fold_build2 can in some cases swap the order of its operands
if that is the more optimal thing to do.  However this breaks semantic
guarantee of left-to-right evaluation in D.

	PR d/101640

gcc/d/ChangeLog:

	* expr.cc (binary_op): Use build2 instead of fold_build2.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr96429.d: Update test.
	* gdc.dg/pr101640.d: New test.

(cherry picked from commit 54ec50bada)
2021-07-28 13:31:13 +02:00
Iain Buclaw
45be6e8088 d: fix ICE at convert_expr(tree_node*, Type*, Type*) (PR101490)
Both the front-end and code generator had a modulo by zero bug when testing if
a conversion from a static array to dynamic array was valid.

	PR d/101490

gcc/d/ChangeLog:

	* d-codegen.cc (build_array_index): Handle void arrays same as byte.
	* d-convert.cc (convert_expr): Handle converting to zero-sized arrays.
	* dmd/dcast.c (castTo): Handle casting to zero-sized arrays.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr101490.d: New test.
	* gdc.test/fail_compilation/fail22144.d: New test.

(cherry picked from commit c936c39f86)
2021-07-28 13:29:54 +02:00
Iain Buclaw
9075f62ddc d: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441)
Backports fix from upstream to allow __FUNCTION__ and
__PRETTY_FUNCTION__ to be used as C string literals.

Reviewed-on: https://github.com/dlang/dmd/pull/12923

	PR d/101441

gcc/d/ChangeLog:

	* dmd/expression.c (FuncInitExp::resolveLoc): Set type as `string'.
	(PrettyFuncInitExp::resolveLoc): Likewise.

gcc/testsuite/ChangeLog:

	* gdc.test/compilable/b19002.d: New test.

(cherry picked from commit 1a2306ffe7)
2021-07-28 13:27:13 +02:00
Iain Buclaw
89f0f83cdd d: Compile-time reflection for supported built-ins (PR101127)
In order to allow user-code to determine whether a back-end builtin is
available without error, LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE has been
defined to delay putting back-end builtin functions until the ISA that
defines them has been declared.

However in D, there is no global namespace.  All builtins get pushed
into the `gcc.builtins' module, which is constructed during the semantic
analysis pass, which has already finished by the time target attributes
are evaluated.  So builtins are not pushed by the new langhook because
they would be ultimately ignored.  Builtins exposed to D code then can
now only be altered by the command-line.

	PR d/101127

gcc/d/ChangeLog:

	* d-builtins.cc (d_builtin_function_ext_scope): New function.
	* d-lang.cc (LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE): Define.
	* d-tree.h (d_builtin_function_ext_scope): Declare.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr101127a.d: New test.
	* gdc.dg/pr101127b.d: New test.

(cherry picked from commit b2f6e1de24)
2021-07-28 13:25:07 +02:00
Iain Buclaw
aa706e1618 d: Change in DotTemplateExp type semantics leading to regression (PR101619)
By giving dot templates a type, meant that properry resolving silently
started passing for code that should never have passed.  The simple fix
is to provide implementations for checkType and checkValue that give an
error about dot templates having neither a value nor type.

Reviewed-on: https://github.com/dlang/dmd/pull/12920

	PR d/101619

gcc/d/ChangeLog:

	* dmd/expression.c (DotTemplateExp::checkType): New function.
	(DotTemplateExp::checkValue): New function.
	* dmd/expression.h (class DotTemplateExp): Declare checkType and
	checkValue.

gcc/testsuite/ChangeLog:

	* gdc.test/fail_compilation/fail7424b.d: Update test.
	* gdc.test/fail_compilation/fail7424c.d: Update test.
	* gdc.test/fail_compilation/fail7424d.d: Update test.
	* gdc.test/fail_compilation/fail7424e.d: Update test.
	* gdc.test/fail_compilation/fail7424f.d: Update test.
	* gdc.test/fail_compilation/fail7424g.d: Update test.
	* gdc.test/fail_compilation/fail7424h.d: Update test.
	* gdc.test/fail_compilation/fail7424i.d: Update test.
	* gdc.test/compilable/test22133.d: New test.
	* gdc.test/fail_compilation/fail22133.d: New test.

(cherry picked from commit 3e21361174)
2021-07-28 13:21:55 +02:00
Jakub Jelinek
117a880acb gimple-fold: Fix up __builtin_clear_padding on classes with virtual inheritence [PR101586]
For the following testcase, B is 16-byte type, containing 8-byte
virtual pointer and 1-byte A member, and C contains two FIELD_DECLs,
one with B type and size of just 8-byte and then a field with type
A and 1-byte size.
The __builtin_clear_padding code was upset about the B typed FIELD_DECL
containing FIELD_DECLs beyond the field size and triggered
assertion failure.
This patch makes it ignore all FIELD_DECLs that are (fully) beyond the sz
passed from the caller (except for the flexible array member
diagnostics that is kept).

2021-07-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/101586
	* gimple-fold.c (clear_padding_type): Ignore FIELD_DECLs with byte
	positions above or equal to sz except for diagnostics of flexible
	array members.

	* g++.dg/torture/builtin-clear-padding-4.C: New test.

(cherry picked from commit a21bd3cebd)
2021-07-28 11:04:08 +02:00
Jakub Jelinek
6d9619f05b expmed: Fix store_integral_bit_field [PR101562]
Our documentation says that paradoxical subregs shouldn't appear
in strict_low_part:
'(strict_low_part (subreg:M (reg:N R) 0))'
     This expression code is used in only one context: as the
     destination operand of a 'set' expression.  In addition, the
     operand of this expression must be a non-paradoxical 'subreg'
     expression.
but on the testcase below that triggers UB at runtime
store_integral_bit_field emits exactly that.

The following patch fixes it by ensuring the requirement is satisfied.

2021-07-23  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/101562
	* expmed.c (store_integral_bit_field): Only use movstrict_optab
	if the operand isn't paradoxical.

	* gcc.c-torture/compile/pr101562.c: New test.

(cherry picked from commit 8408d34570)
2021-07-28 11:03:25 +02:00
Richard Biener
32e6acb399 Update BASE-VER to 11.2.1
This updates BASE-VER to 11.2.1 after the 11.2 release.

2021-07-28  Richard Biener  <rguenther@suse.de>

	* BASE-VER: Set to 11.2.1
2021-07-28 09:07:20 +02:00
Richard Biener
7ca388565a Update ChangeLog and version files for release 2021-07-28 06:55:28 +00:00
GCC Administrator
42190825d5 Daily bump. 2021-07-28 00:17:58 +00:00
GCC Administrator
439bc4e392 Daily bump. 2021-07-27 00:18:03 +00:00
Joseph Myers
f31aad8184 Regenerate gcc.pot.
* gcc.pot: Regenerate.
2021-07-26 15:23:30 +00:00
GCC Administrator
55bca3fc55 Daily bump. 2021-07-26 00:18:03 +00:00
GCC Administrator
1e67eeb420 Daily bump. 2021-07-25 00:17:50 +00:00
GCC Administrator
bf59a106b1 Daily bump. 2021-07-24 00:18:18 +00:00
GCC Administrator
9ca1fa731d Daily bump. 2021-07-23 00:18:07 +00:00
Alan Modra
c8ccb1828b [POWER10] __morestack calls from pcrel code
Compiling gcc/testsuite/gcc.dg/split-*.c and others with -mcpu=power10
and linking with a non-pcrel libgcc results in crashes due to the
power10 pcrel code not having r2 set for the generic-morestack.c
functions called from __morestack.  There is also a problem when
non-pcrel code calls a pcrel libgcc.  See the patch comments.

A similar situation theoretically occurs with ELFv1 multi-toc
executables, when __morestack might be located in a different toc
group to its caller.  This patch makes no attempt to fix that, since
the gold linker does not support multi-toc (gold is needed for proper
support of -fsplit-stack code) nor does gcc emit __morestack calls
that support multi-toc.

	* config/rs6000/morestack.S (R2_SAVE): Define.
	(__morestack): Save and restore r2.  Set up r2 for called
	functions.

(cherry picked from commit cd6ca96f5d)
2021-07-23 08:54:36 +09:30
GCC Administrator
2016df9f3f Daily bump. 2021-07-22 00:18:23 +00:00
Jakub Jelinek
076930b969 openmp: Fix up omp_check_private [PR101535]
The target data construct shouldn't affect omp_check_private, unless
the decl there is privatized (use_device_* clauses).  The routine
had some code for that, but it just did continue; in a loop that looped
only if the region type is one of selected 4 kinds, so effectively resulted
in return false; instead of looping again.  And not diagnosing lastprivate
(or reduction etc.) on a variable that is private to containing parallel
results in ICEs later on, as there is no original list item to which store
the last result.
The target construct is unclear as it has an implicit parallel region
and it is not obvious if the data privatization clauses on the construct
shall be treated as data privatization on the implicit parallel or just
on the target.  For now treat those as privatization on the implicit
parallel, but treat map clauses as shared on the implicit parallel.

2021-07-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/101535
	* gimplify.c (omp_check_private): Properly skip ORT_TARGET_DATA
	contexts in which decl isn't privatized and for ORT_TARGET return
	false if decl is mapped.

	* c-c++-common/gomp/pr101535-1.c: New test.
	* c-c++-common/gomp/pr101535-2.c: New test.

(cherry picked from commit b136b7a787)
2021-07-21 10:07:14 +02:00
Jakub Jelinek
ae2ce6aadb c++: Ensure OpenMP reduction with reference type references complete type [PR101516]
The following testcase ICEs because we haven't verified if reduction decl
has reference type that TREE_TYPE of the reference is a complete type,
require_complete_type on the decl doesn't ensure that.

2021-07-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101516
	* semantics.c (finish_omp_reduction_clause): Also call
	complete_type_or_else and return true if it fails.

	* g++.dg/gomp/pr101516.C: New test.

(cherry picked from commit aea199f96c)
2021-07-21 10:07:00 +02:00
GCC Administrator
70e5a8ffde Daily bump. 2021-07-21 00:18:30 +00:00
Jakub Jelinek
dc386b0208 rs6000: Fix up easy_vector_constant_msb handling [PR101384]
The following gcc.dg/pr101384.c testcase is miscompiled on
powerpc64le-linux.
easy_altivec_constant has code to try construct vector constants with
different element sizes, perhaps different from CONST_VECTOR's mode.  But as
written, that works fine for vspltis[bhw] cases, but not for the vspltisw
x,-1; vsl[bhw] x,x,x case, because that creates always a V16QImode, V8HImode
or V4SImode constant containing broadcasted constant with just the MSB set.
The vspltis_constant function etc. expects the vspltis[bhw] instructions
where the small [-16..15] or even [-32..30] constant is sign-extended to the
remaining step bytes, but that is not the case for the 0x80...00 constants,
with step 1 we can't handle e.g.
{ 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff }
vectors but do want to handle e.g.
{ 0, 0, 0, 0x80, 0, 0, 0, 0x80, 0, 0, 0, 0x80, 0, 0, 0, 0x80 }
and similarly with copies 1 we do want to handle e.g.
{ 0x80808080, 0x80808080, 0x80808080, 0x80808080 }.

This is a simpler version of the fix for backports, which limits the EASY_VECTOR_MSB case
matching to step == 1 && copies == 1, because that is the only case the
splitter handles correctly.

2021-07-20  Jakub Jelinek  <jakub@redhat.com>

	PR target/101384
	* config/rs6000/rs6000.c (vspltis_constant): Accept EASY_VECTOR_MSB
	only if step and copies are equal to 1.

	* gcc.dg/pr101384.c: New test.
2021-07-20 16:41:29 +02:00
Iain Sandoe
5dd3fe90a5 X86: Provide a CTOR for stringop_algs [PR100246].
Several older compilers fail to build modern GCC because of missing
or incomplete C++11 support.

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

PR bootstrap/100246 - [11/12 Regression] GCC will not bootstrap with clang 3.4/3.5 [xcode 5/6, Darwin 12/13]

	PR bootstrap/100246

gcc/ChangeLog:

	* config/i386/i386.h (struct stringop_algs): Define a CTOR for
	this type.

(cherry picked from commit f99f6eb58e)
2021-07-20 07:58:03 +01:00
Iain Sandoe
3a93c67f21 coroutines: Adjust outlined function names [PR95520].
The mechanism used to date for uniquing the coroutine helper
functions (actor, destroy) was over-complicating things and
leading to the noted PR and also difficulties in setting
breakpoints on these functions (so this will help PR99215 as
well).

This implementation delegates the adjustment to the mangling
to write_encoding() which necessitates some book-keeping so
that it is possible to determine which of the coroutine
helper names is to be mangled.

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

PR c++/95520 - [coroutines] __builtin_FUNCTION() returns mangled .actor instead of original function name

	PR c++/95520

gcc/cp/ChangeLog:

	* coroutines.cc (struct coroutine_info): Add fields for
	actor and destroy function decls.
	(to_ramp): New.
	(coro_get_ramp_function): New.
	(coro_get_actor_function): New.
	(coro_get_destroy_function): New.
	(act_des_fn): Set up mapping between ramp, actor and
	destroy functions.
	(morph_fn_to_coro): Adjust interface to the builder for
	helper function decls.
	* cp-tree.h (DECL_ACTOR_FN, DECL_DESTROY_FN, DECL_RAMP_FN,
	JOIN_STR): New.
	* mangle.c (write_encoding): Handle coroutine helpers.
	(write_unqualified_name): Handle lambda coroutine helpers.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr95520.C: New test.

(cherry picked from commit 237ab3ee49)
2021-07-20 07:55:43 +01:00
Iain Sandoe
feef2e414d coroutines: Factor code. Match original source location in helpers [NFC].
This is primarily a source code refactoring, the only change is to
ensure that the outlined functions are marked to begin at the same
line as the original.  Otherwise, they get the default (which seems
to be input_location, which corresponds to the closing brace at the
point that this is done).  Having the source location point to that
confuses some debuggers.

This is a contributory fix to:
PR c++/99215 - coroutines: debugging with gdb

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

gcc/cp/ChangeLog:

	* coroutines.cc (build_actor_fn): Move common code to
	act_des_fn.
	(build_destroy_fn): Likewise.
	(act_des_fn): Build the void return here.  Ensure that the
	source location matches the original function.

(cherry picked from commit d5b1bb0d19)
2021-07-20 07:54:56 +01:00
Iain Sandoe
76f694de99 coroutines: Fix a typo in rewriting the function.
When amending the function re-write code, I made a typo in
the block connections.  This has not shown up in any test
fails (as far as can be seen) but is a regression in debug
info.

Fixed thus.

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

gcc/cp/ChangeLog:

	* coroutines.cc
	(coro_rewrite_function_body): Connect the replacement
	function block to the block nest correctly.

(cherry picked from commit 0d5db79a61)
2021-07-20 07:54:01 +01:00
Iain Sandoe
383295aaad Darwin, X86: Adjust call clobbers to allow for lazy-binding [PR 100152].
We allow public functions defined in a TU to bind locally for PIC
code (the default) on 64bit Mach-O.

If such functions are not inlined, we cannot tell at compile-time if
they might be called via the lazy symbol resolver (this can depend on
options given at link-time).  Therefore, we must assume that the lazy
resolver could be used which clobbers R11 and R10.

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

gcc/ChangeLog:

	PR target/100152
	* config/i386/i386-expand.c (ix86_expand_call): If a call is
	to a non-local-binding, or local but to a public symbol, then
	assume that it might be indirected via the lazy symbol binder.
	Mark R10 and R10 as clobbered in that case.

(cherry picked from commit 41bd1b1903)
2021-07-20 07:52:08 +01:00
Uros Bizjak
f2060ae92f i386: Remove atomic_storedi_fpu and atomic_loaddi_fpu peepholes [PR100182]
These patterns result in non-atomic sequence.

2021-07-21  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/100182
	* config/i386/sync.md (define_peephole2 atomic_storedi_fpu):
	Remove.
	(define_peephole2 atomic_loaddi_fpu): Ditto.

gcc/testsuite/
	PR target/100182
	* gcc.target/i386/pr71245-1.c: Remove.
	* gcc.target/i386/pr71245-2.c: Ditto.
2021-07-20 06:29:39 +02:00
GCC Administrator
24014b2b04 Daily bump. 2021-07-20 00:18:11 +00:00
Ian Lance Taylor
d34f3a9312 compiler: avoid aliases in receiver types
If a package declares a method on an alias type, the alias would be
used in the export data.  This would then trigger a compiler
assertion on import: we should not be adding methods to aliases.

Fix the problem by ensuring that receiver types do not use alias types.
This seems preferable to consistently avoiding aliases in export data,
as aliases can cross packages.  And it's painful to try to patch this
while writing the export data, as at that point all the types are known.

Test case is https://golang.org/cl/335172.

Fixes golang/go#47131

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/335729
2021-07-19 16:47:05 -07:00
Bill Schmidt
ac0efe3c6f rs6000: Don't let swaps pass break multiply low-part (PR101129)
Backport from mainline.

2021-07-15  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	PR target/101129
	* config/rs6000/rs6000-p8swap.c (has_part_mult): New.
	(rs6000_analyze_swaps): Insns containing a subreg of a mult are
	not swappable.

gcc/testsuite/
	PR target/101129
	* gcc.target/powerpc/pr101129.c: New.
2021-07-19 12:52:00 -05:00
Jonathan Wakely
8000947e54 libstdc++: Fix some problems in PSTL tests
libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc:
	Increase dg-timeout-factor to 4. Fix -Wunused-parameter
	warnings. Replace bitwise AND with logical AND in loop
	condition.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc:
	Replace bitwise AND with logical AND in loop condition.
	* testsuite/util/pstl/test_utils.h: Remove unused parameter
	names.

(cherry picked from commit d1adbe5c1b)
2021-07-19 11:57:23 +01:00
Jonathan Wakely
0e4fc87837 libstdc++: Remove precondition checks from ranges::subrange
The assertion in the subrange constructor causes semantic changes,
because the call to ranges::distance performs additional operations that
are not part of the constructor's specification. That will fail to
compile if the iterator is move-only, because the argument to
ranges::distance is passed by value. It will modify the subrange if the
iterator is not a forward iterator, because incrementing the copy also
affects the _M_begin member. Those problems could be prevented by using
if-constexpr to only do the assertion for copyable forward iterators,
but the call to ranges::distance can also prevent the constructor being
usable in constant expressions. If the member initializers are usable in
constant expressions, but iterator increments of equality comparisons
are not, then the checks done by __glibcxx_assert might
make constant evaluation fail.

This change removes the assertion. Additionally, a new typedef is
introduced to simplify the declarations using __make_unsigned_like_t on
the iterator's difference type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange): Add __size_type typedef
	and use it to simplify declarations.
	(subrange(i, s, n)): Remove assertion.
	* testsuite/std/ranges/subrange/constexpr.cc: New test.

(cherry picked from commit a88fc03ba7)
2021-07-19 11:56:50 +01:00
Jonathan Wakely
6dc150d9a0 libstdc++: Fix std::get<T> for std::tuple [PR101427]
The std::get<T> functions relied on deduction failing if more than one
base class existed for the type T.  However the implementation of Core
DR 2303 (in r11-4693) made deduction succeed (and select the
more-derived base class).

This rewrites the implementation of std::get<T> to explicitly check for
more than one occurrence of T in the tuple elements, making it
ill-formed again. Additionally, the large wall of overload resolution
errors described in PR c++/101460 is avoided by making std::get<T> use
__get_helper<I> directly instead of calling std::get<I>, and by adding a
deleted overload of __get_helper<N> for out-of-range N.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101427
	* include/std/tuple (tuple_element): Improve static_assert text.
	(__get_helper): Add deleted overload.
	(get<i>(tuple<T...>&&), get<i>(const tuple<T...>&&)): Use
	__get_helper directly.
	(__get_helper2): Remove.
	(__find_uniq_type_in_pack): New constexpr helper function.
	(get<T>): Use __find_uniq_type_in_pack and __get_helper instead
	of __get_helper2.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust
	expected errors.
	* testsuite/20_util/tuple/element_access/101427.cc: New test.

(cherry picked from commit 17855eed7f)
2021-07-19 11:54:35 +01:00
GCC Administrator
87aa5a09eb Daily bump. 2021-07-19 00:18:25 +00:00
Tobias Burnus
de8945a366 g++.dg/gomp/clause-3.C: Fix - missing in r12-438-g1580fc7 [PR100422]
gcc/testsuite/
	PR testsuite/100422
	* g++.dg/gomp/clause-3.C: Use 'reduction(&:..)' instead of '...(&&:..)'.

(cherry picked from commit af4e4d35f0)
2021-07-19 01:27:51 +02:00
Jakub Jelinek
9119f51f40 openmp - Fix up && and || reductions [PR94366]
As the testcase shows, the special treatment of && and || reduction combiners
where we expand them as omp_out = (omp_out != 0) && (omp_in != 0) (or with ||)
is not needed just for &&/|| on floating point or complex types, but for all
&&/|| reductions - when expanded as omp_out = omp_out && omp_in (not in C but
GENERIC) it is actually gimplified into NOP_EXPRs to bool from both operands,
which turns non-zero values multiple of 2 into 0 rather than 1.

This patch just treats all &&/|| the same and furthermore uses bool type
instead of int for the comparisons.

2021-07-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/94366
gcc/
	* omp-low.c (lower_rec_input_clauses): Rename is_fp_and_or to
	is_truth_op, set it for TRUTH_*IF_EXPR regardless of new_var's type,
	use boolean_type_node instead of integer_type_node as NE_EXPR type.
	(lower_reduction_clauses): Likewise.
libgomp/
	* testsuite/libgomp.c-c++-common/pr94366.c: New test.

(cherry picked from commit 91c771ec8a)
2021-07-18 13:01:39 +02:00
Tobias Burnus
d2904de2cf OpenMP: Support complex/float in && and || reduction
C/C++ permit logical AND and logical OR also with floating-point or complex
arguments by doing an unequal zero comparison; the result is an 'int' with
value one or zero.  Hence, those are also permitted as reduction variable,
even though it is not the most sensible thing to do.

gcc/c/ChangeLog:

	* c-typeck.c (c_finish_omp_clauses): Accept float + complex
	for || and && reductions.

gcc/cp/ChangeLog:

	* semantics.c (finish_omp_reduction_clause): Accept float + complex
	for || and && reductions.

gcc/ChangeLog:

	* omp-low.c (lower_rec_input_clauses, lower_reduction_clauses): Handle
	&& and || with floating-point and complex arguments.

gcc/testsuite/ChangeLog:

	* gcc.dg/gomp/clause-1.c: Use 'reduction(&:..)' instead of '...(&&:..)'.

libgomp/ChangeLog:

	* testsuite/libgomp.c-c++-common/reduction-1.c: New test.
	* testsuite/libgomp.c-c++-common/reduction-2.c: New test.
	* testsuite/libgomp.c-c++-common/reduction-3.c: New test.

(cherry picked from commit 1580fc7644)
2021-07-18 13:01:24 +02:00
Jakub Jelinek
2f49122aec c++: Optimize away NULLPTR_TYPE comparisons [PR101443]
Comparisons of NULLPTR_TYPE operands cause all kinds of problems in the
middle-end and in fold-const.c, various optimizations assume that if they
see e.g. a non-equality comparison with one of the operands being
INTEGER_CST and it is not INTEGRAL_TYPE_P (which has TYPE_{MIN,MAX}_VALUE),
they can build_int_cst (type, 1) to find a successor.

The following patch fixes it by making sure they don't appear in the IL,
optimize them away at cp_fold time as all can be folded.

Though, I've just noticed that clang++ rejects the non-equality comparisons
instead, foo () > 0 with
invalid operands to binary expression ('decltype(nullptr)' (aka 'nullptr_t') and 'int')
and foo () > nullptr with
invalid operands to binary expression ('decltype(nullptr)' (aka 'nullptr_t') and 'nullptr_t')

Shall we reject those too, in addition or instead of parts of this patch?
If so, wouldn't this patch be still useful for backports, I bet we don't
want to start reject it on the release branches when we used to accept it.

2021-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101443
	* cp-gimplify.c (cp_fold): For comparisons with NULLPTR_TYPE
	operands, fold them right away to true or false.

	* g++.dg/cpp0x/nullptr46.C: New test.

(cherry picked from commit 7094a69bd6)
2021-07-18 12:57:27 +02:00
Jakub Jelinek
31b76a815f godump: Fix -fdump-go-spec= reproduceability issue [PR101407]
pot_dummy_types is a hash_set from whose traversal the code prints some type
lines.  hash_set normally uses default_hash_traits which for pointer types
(the hash set hashes const char *) uses pointer_hash which hashes the
addresses of the pointers except of the least significant 3 bits.
With address space randomization, that results in non-determinism in the
-fdump-go-specs= generated file, each invocation can have different order of
the lines emitted from pot_dummy_types traversal.

This patch fixes it by hashing the string contents instead to make the
hashes reproduceable.

2021-07-14  Jakub Jelinek  <jakub@redhat.com>

	PR go/101407
	* godump.c (godump_str_hash): New type.
	(godump_container::pot_dummy_types): Use string_hash instead of
	ptr_hash in the hash_set.

(cherry picked from commit 3be762c2ed)
2021-07-18 12:57:24 +02:00
Jakub Jelinek
122cdd5b21 libgomp: Don't include limits.h instead of hidden visibility block
sem.h is included in between # pragma GCC visibility push(hidden)
and # pragma GCC visibility pop and includes limits.h there, which
since the introduction of sysconf declaration in recent glibcs
in there causes trouble.  libgomp assumes it is compiled by gcc,
so we don't really need to include limits.h there and can use
-__INT_MAX__ - 1 instead (which clang and icc support too for years).

2021-07-13  Jakub Jelinek  <jakub@redhat.com>
	    Florian Weimer  <fweimer@redhat.com>

	* config/linux/sem.h: Don't include limits.h.
	(SEM_WAIT): Define to -__INT_MAX__ - 1 instead of INT_MIN.
	* config/linux/affinity.c: Include limits.h.

(cherry picked from commit 42f10ba5b5)
2021-07-18 12:57:15 +02:00
Jakub Jelinek
135680bdce dwarf2out: Handle COMPOUND_LITERAL_EXPR in loc_list_from_tree_1 [PR101266]
In this case dwarf2out_decl is called from the FEs with GENERIC but not
yet gimplified expressions in it.

As loc_list_from_tree_1 has an exhaustive list of tree codes it wants to
handle and for checking asserts no other codes makes it in, we should
handle even GENERIC trees that shouldn't be valid in GIMPLE.

The following patch handles COMPOUND_LITERAL_EXPR by hnadling it like the
underlying VAR_DECL temporary.

Verified the emitted DWARF is correct (but unoptimized, we emit
DW_OP_lit1 DW_OP_lit1 DW_OP_minus for the upper bound).

2021-07-01  Jakub Jelinek  <jakub@redhat.com>

	PR debug/101266
	* dwarf2out.c (loc_list_from_tree_1): Handle COMPOUND_LITERAL_EXPR.

	* gcc.dg/pr101266.c: New test.

(cherry picked from commit b0ab968999)
2021-07-18 12:56:36 +02:00
Jakub Jelinek
86a9718e16 match.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when sanitizing [PR101210]
When we have (intptr_t) x == cst where x has REFERENCE_TYPE, this
optimization creates x == cst out of it where cst has REFERENCE_TYPE.
If it is done in GENERIC folding, it can results in ubsan failures
where the INTEGER_CST with REFERENCE_TYPE is instrumented.

Fixed by deferring it to GIMPLE folding in this case.

2021-06-29  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101210
	* match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't
	perform the optimization in GENERIC when sanitizing and x has a
	reference type.

	* g++.dg/ubsan/pr101210.C: New test.

(cherry picked from commit 53fd7544af)
2021-07-18 12:54:55 +02:00
Jakub Jelinek
72ff4a04bb c: Fix up c_parser_has_attribute_expression [PR101176]
This function keeps src_range member of the result uninitialized, which at
least under valgrind can show up later when those uninitialized location_t's
can make it into the IL or location_t hash tables.

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

	PR c/101176
	* c-parser.c (c_parser_has_attribute_expression): Set source range for
	the result.

(cherry picked from commit 178fb8df93)
2021-07-18 12:54:32 +02:00
Jakub Jelinek
6c9eaa1de2 c: Fix C cast error-recovery [PR101171]
The following testcase ICEs during error-recovery, as build_c_cast calls
note_integer_operands on error_mark_node and that wraps it into
C_MAYBE_CONST_EXPR which is unexpected and causes ICE later on.
Seems most other callers of note_integer_operands check early if something
is error_mark_node and return before calling note_integer_operands on it.

The following patch fixes it by not calling on error_mark_node, another
possibility would be to handle error_mark_node in note_integer_operands and
just return it.

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

	PR c/101171
	* c-typeck.c (build_c_cast): Don't call note_integer_operands on
	error_mark_node.

	* gcc.dg/pr101171.c: New test.

(cherry picked from commit fdc5522fb0)
2021-07-18 12:54:07 +02:00