Commit Graph

181888 Commits

Author SHA1 Message Date
Jakub Jelinek
9715663f7d c++: Change __builtin_source_location to use __PRETTY_FUNCTION__ instead of __FUNCTION__ [PR80780]
On Tue, Dec 01, 2020 at 01:03:52PM +0000, Jonathan Wakely via Gcc-patches wrote:
> I mentioned in PR 80780 that a __builtin__PRETTY_FUNCTION would have
> been nice, because __FUNCTION__ isn't very useful for C++, because of
> overloading and namespace/class scopes. There are an unlimited number
> of functions that have __FUNCTION__ == "s", e.g. "ns::s(int)" and
> "ns::s()" and "another_scope::s::s<T...>(T...)" etc.
>
> Since __builtin_source_location() can do whatever it wants (without
> needing to add __builtin__PRETTY_FUNCTION) it might be nice to use the
> __PRETTY_FUNCTION__ string. JeanHeyd's tests would still need changes,
> because the name would be "s::s(void*)" not "s::s" but that still
> seems better for users.

When I've added template tests for the previous patch, I have noticed that
the current __builtin_source_location behavior is not really __FUNCTION__,
just close, because e.g. in function template __FUNCTION__ is still
"bar" but __builtin_source_location gave "bar<0>".

Anyway, this patch implements above request to follow __PRETTY_FUNCTION__
(on top of the earlier posted patch).

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/80780
	* cp-gimplify.c (fold_builtin_source_location): Use 2 instead of 0
	as last argument to cxx_printable_name.

	* g++.dg/cpp2a/srcloc1.C (quux): Use __PRETTY_FUNCTION__ instead of
	function.
	* g++.dg/cpp2a/srcloc2.C (quux): Likewise.
	* g++.dg/cpp2a/srcloc15.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.
	* g++.dg/cpp2a/srcloc17.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.

	* testsuite/18_support/source_location/1.cc (main): Adjust for
	__builtin_source_location using __PRETTY_FUNCTION__-like names instead
	__FUNCTION__-like.
	* testsuite/18_support/source_location/consteval.cc (main): Likewise.
2020-12-04 08:08:39 +01:00
GCC Administrator
b8dd0ef74d Daily bump. 2020-12-04 00:16:36 +00:00
Jason Merrill
61371884fb c++: XFAIL testcase for PR98019
Apparently it isn't actually fixed on trunk yet, was just passing because of
some WIP in my tree.  So XFAIL for now.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-nodiscard1.C: XFAIL.
2020-12-03 17:59:01 -05:00
Jason Merrill
9a7f5e3906 c++: Fix bootstrap on 32-bit hosts [PR91828]
Using the releasing_vec op[] with an int index was breaking on 32-bit hosts
because of ambiguity with the built-in operator and the conversion
function.  Since the built-in operator has a ptrdiff_t, this was fine on
64-bit targets where ptrdiff_t is larger than int, but broke on 32-bit
targets where it's the same as int, making the conversion for that argument
better than the member function.  Fixed by changing the member function to
also use ptrdiff_t for the index.

gcc/cp/ChangeLog:

	* cp-tree.h (releasing_vec::operator[]): Change parameter type to
	ptrdiff_t.
2020-12-03 17:49:17 -05:00
Martin Sebor
dce6c58db8 Add support for detecting mismatched allocation/deallocation calls.
PR c++/90629 - Support for -Wmismatched-new-delete
PR middle-end/94527 - Add an __attribute__ that marks a function as freeing an object

gcc/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* builtins.c (access_ref::access_ref): Initialize new member.
	(compute_objsize): Use access_ref::deref.  Handle simple pointer
	assignment.
	(expand_builtin): Remove handling of the free built-in.
	(call_dealloc_argno): Same.
	(find_assignment_location): New function.
	(fndecl_alloc_p): Same.
	(gimple_call_alloc_p): Same.
	(call_dealloc_p): Same.
	(matching_alloc_calls_p): Same.
	(warn_dealloc_offset): Same.
	(maybe_emit_free_warning): Same.
	* builtins.h (struct access_ref): Declare new member.
	(maybe_emit_free_warning): Make extern.  Make use of access_ref.
	Handle -Wmismatched-new-delete.
	* calls.c (initialize_argument_information): Call
	maybe_emit_free_warning.
	* doc/extend.texi (attribute malloc): Update.
	* doc/invoke.texi (-Wfree-nonheap-object): Expand documentation.
	(-Wmismatched-new-delete): Document new option.
	(-Wmismatched-dealloc): Document new option.

gcc/c-family/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* c-attribs.c (handle_dealloc_attribute): New function.
	(handle_malloc_attribute): Handle argument forms of attribute.
	* c.opt (-Wmismatched-dealloc): New option.
	(-Wmismatched-new-delete): New option.

gcc/testsuite/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* g++.dg/asan/asan_test.cc: Fix a bug.
	* g++.dg/warn/delete-array-1.C: Add expected warning.
	* g++.old-deja/g++.other/delete2.C: Add expected warning.
	* g++.dg/warn/Wfree-nonheap-object-2.C: New test.
	* g++.dg/warn/Wfree-nonheap-object.C: New test.
	* g++.dg/warn/Wmismatched-new-delete.C: New test.
	* g++.dg/warn/Wmismatched-dealloc-2.C: New test.
	* g++.dg/warn/Wmismatched-dealloc.C: New test.
	* gcc.dg/Wmismatched-dealloc.c: New test.
	* gcc.dg/analyzer/malloc-1.c: Prune out expected warning.
	* gcc.dg/attr-malloc.c: New test.
	* gcc.dg/free-1.c: Adjust text of expected warning.
	* gcc.dg/free-2.c: Same.
	* gcc.dg/torture/pr71816.c: Prune out expected warning.
	* gcc.dg/tree-ssa/pr19831-2.c: Add an expected warning.
	* gcc.dg/Wfree-nonheap-object-2.c: New test.
	* gcc.dg/Wfree-nonheap-object-3.c: New test.
	* gcc.dg/Wfree-nonheap-object.c: New test.

libstdc++-v3/ChangeLog:

	* testsuite/ext/vstring/modifiers/clear/56166.cc: Suppress a false
	positive warning.
2020-12-03 15:43:32 -07:00
Nathan Sidwell
a3f7a6957a c++: Exported using decls
With modules we need to record whethe a (namespace-scope) using decl
is exporting the named entities.  Record this on the OVERLOAD marking
the used decl.

	gcc/cp/
	* cp-tree.h (OVL_EXPORT): New.
	(class ovl_iterator): Add get_using, exporting_p.
	* tree.c (ovl_insert): Extend using_or_hidden meaning to include
	an exported using.
2020-12-03 12:40:09 -08:00
Nathan Sidwell
f7aeb823d9 c++: uninstantiated template friends
template friends need to be recognized by module streaming and
associated with the befriending class.  but their context is that of
the friend (a namespace or other class).  This adds a flag to mark
such templates, and uses their DECL_CHAIN to point at the befriender.

	gcc/cp
	* cp-tree.h (DECL_UNINSTANTIATED_TEMPLATE_FRIEND): New.
	* pt.c (push_template_decl): Set it.
	(tsubst_friend_function): Clear it.
2020-12-03 12:40:09 -08:00
Ian Lance Taylor
3089f5feef Go testsuite: update new tests to version in source repo 2020-12-03 12:08:05 -08:00
Michael Meissner
9f1a650199 PowerPC: PR libgcc/97543 and libgcc/97643, fix long double issues
If you use a compiler with long double defaulting to 64-bit instead of 128-bit
with IBM extended double, you get linker warnings about mis-matches in the gnu
attributes for long double (PR libgcc/97543).  Even if the compiler is
configured to have long double be 64 bit as the default with the configuration
option '--without-long-double-128' you get the warnings.

You also get the same issues if you use a compiler with long double defaulting
to IEEE 128-bit instead of IBM extended double (PR libgcc/97643).

The issue is the way libgcc.a/libgcc.so is built.  Right now when building
libgcc under Linux, the long double size is set to 128-bits when building
libgcc.  However, the gnu attributes are set, leading to the warnings.

One feature of the current GNU attribute implementation is if you have a shared
library (such as libgcc_s.so), the GNU attributes for the shared library is an
inclusive OR of all of the objects within the library.  This means if any
object file that uses the -mlong-double-128 option and uses long double, the GNU
attributes for the library will indicate that it uses 128-bit IBM long
doubles.  If you have a static library, you will get the warning only if you
actually reference an object file  with the attribute set.

This patch does two things:

    1)	All of the object files that support IBM 128-bit long doubles
	explicitly set the ABI to IBM extended double.

    2)	I turned off GNU attributes for building the shared library or for
        building the IBM 128-bit long double support.

libgcc/
2020-12-03  Michael Meissner  <meissner@linux.ibm.com>

	PR libgcc/97543
	PR libgcc/97643
	* config/rs6000/t-linux (IBM128_STATIC_OBJS): New make variable.
	(IBM128_SHARED_OBJS): New make variable.
	(IBM128_OBJS): New make variable.  Set all objects to use the
	explicit IBM format, and disable gnu attributes.
	(IBM128_CFLAGS): New make variable.
	(gcc_s_compile): Add -mno-gnu-attribute to all shared library
	modules.
2020-12-03 14:50:26 -05:00
Harald Anlauf
30b606bb9b PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913
Add checks for NULL pointers before dereferencing them.

gcc/fortran/ChangeLog:

	PR fortran/95342
	* decl.c (gfc_match_function_decl): Avoid NULL pointer dereference.
	(gfc_match_subroutine): Likewise.

gcc/testsuite/ChangeLog:

	PR fortran/95342
	* gfortran.dg/pr95342.f90: New test.
2020-12-03 20:33:22 +01:00
Jonathan Wakely
656131e06a libstdc++: Fix typos in #error strings
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Remove stray
	word from copy&paste.
	* testsuite/26_numerics/bit/bit.cast/version.cc: Likewise.
2020-12-03 19:31:19 +00:00
Alexandre Oliva
442b6fb7c0 fix __builtin___clear_cache overrider fallout
Machines that had CLEAR_CACHE_INSN and that would thus issue calls to
__clear_cache with the default call expander, would fail on languages
that did not set up the __clear_cache builtin.  This patch arranges
for all languages to set up this builtin.

Machines or multilibs that had ptr_mode != Pmode, such as aarch64 with
-mabi=ilp32, would fail the RTL mode test of the arguments passed to
__clear_cache, because we'd insist on ptr_mode.  This patch arranges
for Pmode to be accepted as well.


for  gcc/ChangeLog

	* tree.c (build_common_builtin_nodes): Declare
	__builtin___clear_cache for all languages.
	* builtins.c (maybe_emit_call_builtin___clear_cache): Accept
	Pmode arguments.
2020-12-03 16:20:28 -03:00
Jonathan Wakely
44ac1ea0e2 libstdc++: Update C++20 library implementation status
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml: Update C++20 status.
	* doc/html/*: Regenerate.
2020-12-03 19:17:13 +00:00
JeanHeyd Meneide
57d76ee9cf libtdc++: Define std::source_location for C++20
This doesn't define a new _GLIBCXX_HAVE_BUILTIN_SOURCE_LOCATION macro.
because using __has_builtin(__builtin_source_location) is sufficient.
Currently only GCC supports it, but if/when Clang and Intel add it the
__has_builtin check should for them too.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add <source_location>.
	* include/Makefile.am: Add <source_location>.
	* include/Makefile.in: Regenerate.
	* include/std/version (__cpp_lib_source_location): Define.
	* include/std/source_location: New file.
	* testsuite/18_support/source_location/1.cc: New test.
	* testsuite/18_support/source_location/consteval.cc: New test.
	* testsuite/18_support/source_location/srcloc.h: New test.
	* testsuite/18_support/source_location/version.cc: New test.
2020-12-03 19:17:13 +00:00
Jonathan Wakely
9e433b3461 libstdc++: Add std::bit_cast for C++20 [PR 93121]
Thanks to Jakub's addition of the built-in, we can add this to the
library now. The compiler tests for the built-in are quite extensive,
including verifying the constraints, so this only adds minimal tests to
the library testsuite.

This doesn't add a new _GLIBCXX_HAVE_BUILTIN_BIT_CAST because using
__has_builtin(__builtin_bit_cast) works for GCC and versions of Clang
that provide the built-in.

libstdc++-v3/ChangeLog:

	PR libstdc++/93121
	* include/std/bit (__cpp_lib_bit_cast, bit_cast): Define.
	* include/std/version (__cpp_lib_bit_cast): Define.
	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: New test.
	* testsuite/26_numerics/bit/bit.cast/version.cc: New test.
2020-12-03 19:17:13 +00:00
Ian Lance Taylor
adbeeb198a Go testsuite: add a bunch of new tests from source repo 2020-12-03 11:13:03 -08:00
Ian Lance Taylor
2a099fd223 go-test.exp: add -I. when compiling in directory
* go.test/go-test.exp (go-gc-tests): Add -I. when building all
	sources in a directory (errorcheckdir, compiledir, rundir,
	rundircmpout).
2020-12-03 11:11:28 -08:00
Jason Merrill
5ea36d20c3 c++: Add testcase for PR98019
This has already been fixed on trunk, but I don't see a testcase for it.

gcc/testsuite/ChangeLog:

	PR c++/98019
	* g++.dg/cpp2a/concepts-nodiscard1.C: New test.
2020-12-03 13:56:56 -05:00
Ian Lance Taylor
4a3b9f48c3 testsuite: update existing Go tests to source repo
This updates a bunch of existing Go tests to the contents of the
source repo.  This does not add any of the newer tests.
2020-12-03 10:09:48 -08:00
Sebastian Huber
2fb287056e RTEMS: Add Cortex-R52 multilib
gcc/
	* config/arm/t-rtems: Add "-mthumb -mcpu=cortex-r52
	-mfloat-abi=hard" multilib.
2020-12-03 18:51:41 +01:00
Jonathan Wakely
3843fa2d75 libstdc++: Update powerpc-linux baselines for GCC 10.1
This should have been done before the GCC 10.1 release.

libstdc++-v3/ChangeLog:

	* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt:
	Update.
	* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
	Update.
2020-12-03 17:18:28 +00:00
Jonathan Wakely
91cfacc4b5 libstdc++: Disable std::array assertions for C++11 constexpr
The recent changes to add assertions to std::array broke the functions
that need to be constexpr in C++11, because of the restrictive rules for
constexpr functions in C++11.

This simply disables the assertions for C++11 mode, so the functions can
be constexpr again.

libstdc++-v3/ChangeLog:

	* include/std/array (array::operator[](size_t) const, array::front() const)
	(array::back() const) [__cplusplus == 201103]: Disable
	assertions.
	* testsuite/23_containers/array/element_access/constexpr_element_access.cc:
	Check for correct values.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/23_containers/array/debug/constexpr_c++11.cc: New test.
2020-12-03 17:08:01 +00:00
Nathan Sidwell
eb8c2b30b9 c++: templatey type creation
This patch makes a couple of type-creation routines available to
modules.  That needs to create unbound template parms, and canonical
template parms.

	gcc/cp/
	* cp-tree.h (make_unbound_class_template_raw): Declare.
	(canonical_type_parameter): Declare.
	* decl.c (make_unbound_class_template_raw): Break out of ...
	(make_unboud_class_template): ... here.  Call it.
	* pt.c (canonical_type_parameter): Externalize.  Refactor & set
	structural_equality for type parms.
2020-12-03 09:01:43 -08:00
Uros Bizjak
756f55e62f i386: Fix up ix86_md_asm_adjust for TImode [PR98086]
ix86_md_asm_adjust assumes that dest_mode can be only [QHSD]Imode
and nothing else.  The patch rewrites zero-extension part to use
convert_to_mode to handle TImode and hypothetically even wider modes.

2020-12-03  Uroš Bizjak  <ubizjak@gmail.com>
	    Jakub Jelinek  <jakub@redhat.com>

gcc/
	PR target/98086
	* config/i386/i386.c (ix86_md_asm_adjustmd): Rewrite
	zero-extension part to use convert_to_mode.

gcc/testsuite/
	PR target/98086
	* gcc.target/i386/pr98086.c: New test.
2020-12-03 17:51:45 +01:00
Nathan Sidwell
7254a78cf4 c++: Testcases [PR 98115]
These two testcases provide coverage for 98115, which doesn't trigger on all hosts.

	PR c++/98115
	PR c++/98116
	gcc/testsuite/
	* g++.dg/template/pr98115.C: New.
	* g++.dg/template/pr98116.C: New.
2020-12-03 08:43:32 -08:00
Ian Lance Taylor
17c9cf3c17 compiler: cast comparison function result to expected bool type
Otherwise cases like
    type mybool bool
    var b mybool = [10]string{} == [10]string{}
get an incorrect type checking error.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/274446
2020-12-03 08:27:41 -08:00
Ian Lance Taylor
cd34d5f2c4 compiler: defer to middle-end for complex division
Go used to use slightly different semantics than C99 for complex division,
so we used runtime routines to handle the different.  The gc compiler
has changes its behavior to match C99, so changes ours as well.

For golang/go#14644

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/274213
2020-12-03 08:21:02 -08:00
Andreas Krebbel
65af6bc9f8 IBM Z: Fix mode in probe_stack pattern
The probe pattern uses Pmode but the middle-end wants to emit a
word_mode probe check.  This - as usual - breaks on Z with -m31
-mzarch were word_mode doesn't match Pmode.

gcc/ChangeLog:

	* config/s390/s390.md ("@probe_stack2<mode>"): Change mode
	iterator to W.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/stack-clash-4.c: New test.
2020-12-03 17:04:17 +01:00
Nathan Sidwell
62fb1b9e0d c++: Fix array type dependency [PR 98107]
I'd missed some paths through build_cplus_array_type, plus, some
arrays come via the C-type builder.  This propagates dependency in
more places and asserts that in the cases where TYPE_DEPENDENT_P_VALID
is unset, the type is non-dependent.

	PR c++/98107
	gcc/cp/
	* tree.c (build_cplus_array_type): Mark dependency of new variant.
	(cp_build_qualified_type_real, strip_typedefs): Assert
	TYPE_DEPENDENT_P_VALID, or not a dependent type.
2020-12-03 07:56:23 -08:00
Richard Sandiford
9c68134376 aarch64: Don't fold svundef* at the gimple level
As the testcase shows, folding svundef*() at the gimple level
has the unfortunate side-effect of introducing -Wuninitialized
or -Wmaybe-uninitialized warnings.  We don't have a testcase
that relies on the fold, so the easiest fix seems to be to
remove it.

gcc/
	* config/aarch64/aarch64-sve-builtins-base.cc (svundef_impl::fold):
	Delete.

gcc/testsuite/
	* gcc.target/aarch64/sve/acle/general/undef_1.c: New test.
2020-12-03 15:22:52 +00:00
Eric Botcazou
277ff3406d Fix PR middle-end/98099
this replaces the ICE by a sorry message for the use of reverse scalar
storage order with 128-bit decimal floating-point type on 32-bit targets.

gcc/ChangeLog:
	PR middle-end/98099
	* expmed.c (flip_storage_order): In the case of a non-integer mode,
	sorry out if the integer mode to be used instead is not supported.

gcc/testsuite/ChangeLog:
	* gcc.dg/pr98099.c: New test.
2020-12-03 15:56:34 +01:00
Eric Botcazou
5d103763b9 Fix PR middle-end/98082
this fixes an ICE introduced by the fix for PR middle-end/97078 where
use_register_for_decl was changed to return true at -O0 for a parameter
of a thunk.  It turns out that we need to do the same for a result in
this case.

gcc/ChangeLog:
	PR middle-end/98082
	* function.c (use_register_for_decl): Also return true for a result
	if cfun->tail_call_marked is true.

gcc/testsuite/ChangeLog:
	* g++.dg/cpp2a/pr98082.C: New test.
2020-12-03 15:56:33 +01:00
Jakub Jelinek
896048cf43 c++: Add __builtin_bit_cast to implement std::bit_cast [PR93121]
The following patch adds __builtin_bit_cast builtin, similarly to
clang or MSVC which implement std::bit_cast using such an builtin too.
It checks the various std::bit_cast requirements, when not constexpr
evaluated acts pretty much like VIEW_CONVERT_EXPR of the source argument
to the destination type and the hardest part is obviously the constexpr
evaluation.
I've left out PDP11 handling of those, couldn't figure out how exactly are
bitfields laid out there

2020-12-03  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/93121
	* fold-const.h (native_encode_initializer): Add mask argument
	defaulted to nullptr.
	(find_bitfield_repr_type): Declare.
	(native_interpret_aggregate): Declare.
	* fold-const.c (find_bitfield_repr_type): New function.
	(native_encode_initializer): Add mask argument and support for
	filling it.  Handle also some bitfields without integral
	DECL_BIT_FIELD_REPRESENTATIVE.
	(native_interpret_aggregate): New function.
	* gimple-fold.h (clear_type_padding_in_mask): Declare.
	* gimple-fold.c (struct clear_padding_struct): Add clear_in_mask
	member.
	(clear_padding_flush): Handle buf->clear_in_mask.
	(clear_padding_union): Copy clear_in_mask.  Don't error if
	buf->clear_in_mask is set.
	(clear_padding_type): Don't error if buf->clear_in_mask is set.
	(clear_type_padding_in_mask): New function.
	(gimple_fold_builtin_clear_padding): Set buf.clear_in_mask to false.
	* doc/extend.texi (__builtin_bit_cast): Document.

	* c-common.h (enum rid): Add RID_BUILTIN_BIT_CAST.
	* c-common.c (c_common_reswords): Add __builtin_bit_cast.

	* cp-tree.h (cp_build_bit_cast): Declare.
	* cp-tree.def (BIT_CAST_EXPR): New tree code.
	* cp-objcp-common.c (names_builtin_p): Handle RID_BUILTIN_BIT_CAST.
	(cp_common_init_ts): Handle BIT_CAST_EXPR.
	* cxx-pretty-print.c (cxx_pretty_printer::postfix_expression):
	Likewise.
	* parser.c (cp_parser_postfix_expression): Handle
	RID_BUILTIN_BIT_CAST.
	* semantics.c (cp_build_bit_cast): New function.
	* tree.c (cp_tree_equal): Handle BIT_CAST_EXPR.
	(cp_walk_subtrees): Likewise.
	* pt.c (tsubst_copy): Likewise.
	* constexpr.c (check_bit_cast_type, cxx_eval_bit_cast): New functions.
	(cxx_eval_constant_expression): Handle BIT_CAST_EXPR.
	(potential_constant_expression_1): Likewise.
	* cp-gimplify.c (cp_genericize_r): Likewise.

	* g++.dg/cpp2a/bit-cast1.C: New test.
	* g++.dg/cpp2a/bit-cast2.C: New test.
	* g++.dg/cpp2a/bit-cast3.C: New test.
	* g++.dg/cpp2a/bit-cast4.C: New test.
	* g++.dg/cpp2a/bit-cast5.C: New test.
2020-12-03 15:46:54 +01:00
Jakub Jelinek
341035a54a c++: consteval-defarg1.C test variant for templates
We weren't recognizing a default argument for a consteval member function as
being in immediate function context because there was no function parameter
scope to look at.

The following testcase is an attempt to test it with templates, both
non-dependent and dependent consteval calls in both function and class
templates, and with r11-5694 it now passes.

2020-12-03  Jakub Jelinek  <jakub@redhat.com>

	* g++.dg/cpp2a/consteval-defarg2.C: New test.
2020-12-03 15:32:31 +01:00
Ilya Leoshkevich
614aff0adf tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Do not allow __builtin_constant_p.
This is the same as commit 70a6200918 ("tree-ssa-threadbackward.c
(profitable_jump_thread_path): Do not allow __builtin_constant_p."), but
for the old forward threader.

gcc/ChangeLog:

2020-12-03  Ilya Leoshkevich  <iii@linux.ibm.com>

	* tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest):
	Do not allow __builtin_constant_p on a threading path.
2020-12-03 10:50:32 +01:00
Ilya Leoshkevich
73564433f5 Fix division by 0 in printf_strlen_execute when dumping
gcc/ChangeLog:

2020-12-03  Ilya Leoshkevich  <iii@linux.ibm.com>

	* tree-ssa-strlen.c (printf_strlen_execute): Avoid division by
	0.
2020-12-03 10:48:20 +01:00
Kito Cheng
b20cd0c743 RISC-V: Canonicalize --with-arch
- We would like to canonicalize the arch string for --with-arch for
   easier handling multilib, so split canonicalization part to a stand
   along script to shared the logic.

gcc/ChangeLog:

	* config/riscv/multilib-generator (arch_canonicalize): Move
	code to arch-canonicalize, and call that script to canonicalize arch
	string.
	(canonical_order): Move code to arch-canonicalize.
	(LONG_EXT_PREFIXES): Ditto.
	(IMPLIED_EXT): Ditto.
	* config/riscv/arch-canonicalize: New.
	* config.gcc (riscv*-*-*): Canonicalize --with-arch.
2020-12-03 17:39:27 +08:00
Przemyslaw Wirkus
48ff86adfd aarch64: Add +flagm to -march
New +flagm (Condition flag manipulation) feature option for -march command line
option.

Please note that FLAGM stays a Armv8.4-A feature but now can be
assigned to other architectures or CPUs.

gcc/ChangeLog:

	* config/aarch64/aarch64-option-extensions.def
	(AARCH64_OPT_EXTENSION): New +flagm option in -march for AArch64.
	* config/aarch64/aarch64.h (AARCH64_FL_FLAGM): Add new flagm extension bit
	mask.
	(AARCH64_FL_FOR_ARCH8_4): Add flagm to Armv8.4-A.
	* doc/invoke.texi: Update docs with +flagm.
2020-12-03 09:27:28 +00:00
Jakub Jelinek
381d1d0120 testsuite: Add testcase for already fixed PR [PR98104]
This testcase got broken with r11-3826 and got fixed with r11-5628.

2020-12-03  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98104
	* g++.dg/warn/pr98104.C: New test.
2020-12-03 10:04:54 +01:00
liuhongt
7031098249 Optimize vpsubusw compared to 0 into vpcmpleuw or vpcmpnleuw [PR96906]
For signed comparisons, it handles cases that are eq or neq to 0.
For unsigned comparisons, it additionaly handles cases that are le or
gt to 0(equivilent to eq or neq to 0). Transform case eq to leu,
case neq to gtu.

.i.e. for -mavx512bw -mavx512vl transform eq case code from

	vpsubusw        %xmm1, %xmm0, %xmm0
	vpxor   %xmm1, %xmm1, %xmm1
	vpcmpeqw  %xmm1, %xmm0, %k0
to
	vpcmpleuw       %xmm1, %xmm0, %k0

.i.e. for -mavx512bw -mavx512vl transform neq case code from

	vpsubusw        %xmm1, %xmm0, %xmm0
	vpxor   %xmm1, %xmm1, %xmm1
	vpcmpneqw  %xmm1, %xmm0, %k0
to
	vpcmpnleuw       %xmm1, %xmm0, %k0

gcc/ChangeLog
	PR target/96906
	* config/i386/sse.md
	(<avx512>_ucmp<mode>3<mask_scalar_merge_name>): Add a new
	define_split after this insn.

gcc/testsuite/ChangeLog

	* gcc.target/i386/avx512bw-pr96906-1.c: New test.
	* gcc.target/i386/pr96906-1.c: Add -mno-avx512f.
2020-12-03 13:42:39 +08:00
liuhongt
35c4c67e6c Fix incorrect replacement of vmovdqu32 with vpblendd which can cause fault.
gcc/ChangeLog:

	PR target/97642
	* config/i386/i386-expand.c
	(ix86_expand_special_args_builtin): Don't move all-ones mask
	operands into register.
	* config/i386/sse.md (UNSPEC_MASKLOAD): New unspec.
	(*<avx512>_load<mode>_mask): New define_insns for masked load
	instructions.
	(<avx512>_load<mode>_mask): Changed to define_expands which
	specifically handle memory or all-ones mask operands.
	(<avx512>_blendm<mode>): Changed to define_insns which are same
	as original <avx512>_load<mode>_mask with adjustment of
	operands order.
	(*<avx512>_load<mode>): New define_insn_and_split which is
	used to optimize for masked load with all one mask.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512bw-vmovdqu16-1.c: Adjust testcase to
	make sure only masked load instruction is generated.
	* gcc.target/i386/avx512bw-vmovdqu8-1.c: Ditto.
	* gcc.target/i386/avx512f-vmovapd-1.c: Ditto.
	* gcc.target/i386/avx512f-vmovaps-1.c: Ditto.
	* gcc.target/i386/avx512f-vmovdqa32-1.c: Ditto.
	* gcc.target/i386/avx512f-vmovdqa64-1.c: Ditto.
	* gcc.target/i386/avx512vl-vmovapd-1.c: Ditto.
	* gcc.target/i386/avx512vl-vmovaps-1.c: Ditto.
	* gcc.target/i386/avx512vl-vmovdqa32-1.c: Ditto.
	* gcc.target/i386/avx512vl-vmovdqa64-1.c: Ditto.
	* gcc.target/i386/pr97642-1.c: New test.
	* gcc.target/i386/pr97642-2.c: New test.
2020-12-03 13:34:05 +08:00
Jason Merrill
c03a78d8f8 c++: Push parms when late parsing default args
In this testcase we weren't catching the error in A::f because the parameter
'I' wasn't in scope, so the default argument for 'b' found the global
typedef I.  Fixed by pushing the parms before parsing.  This is a bit
complicated because pushdecl clears DECL_CHAIN; do_push_parm_decls deals
with this by nreversing first, but that doesn't work here because we only
want to push them one at a time; if we pushed all of them before parsing,
we'd wrongly reject A::g.

gcc/cp/ChangeLog:

	* parser.c (cp_parser_primary_expression): Distinguish
	parms from vars in error.
	(cp_parser_late_parsing_default_args): Pushdecl parms
	as we go.

gcc/testsuite/ChangeLog:

	* g++.dg/parse/defarg17.C: New test.
2020-12-02 22:15:54 -05:00
Jason Merrill
54f97a226a c++: Fix late-parsed default arg context
Jakub noticed that we weren't recognizing a default argument for a consteval
member function as being in immediate function context because there was no
function parameter scope to look at.

Note that this patch doesn't actually push the parameters into the scope,
that happens in a separate commit.

gcc/cp/ChangeLog:

	* name-lookup.c (begin_scope): Set immediate_fn_ctx_p.
	* parser.c (cp_parser_late_parsing_default_args): Push
	sk_function_parms scope.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/consteval-defarg1.C: New test.
2020-12-02 22:15:48 -05:00
Hongyu Wang
81d590760c Add popcount<mode> expander to enable popcount auto vectorization under AVX512BITALG/AVX512POPCNTDQ target.
gcc/ChangeLog

	PR target/97770
	* config/i386/sse.md (popcount<mode>2): New expander
	for SI/DI vector modes.
	(popcount<mode>2): Likewise for QI/HI vector modes.

gcc/testsuite/ChangeLog

	PR target/97770
	* gcc.target/i386/avx512bitalg-pr97770-1.c: New test.
	* gcc.target/i386/avx512vpopcntdq-pr97770-1.c: Likewise.
	* gcc.target/i386/avx512vpopcntdq-pr97770-2.c: Likewise.
	* gcc.target/i386/avx512vpopcntdqvl-pr97770-1.c: Likewise.
2020-12-03 10:02:14 +08:00
Alexandre Oliva
c05ece92c6 introduce overridable clear_cache emitter
This patch introduces maybe_emit_call_builtin___clear_cache for the
builtin expander machinery and the trampoline initializers to use to
clear the instruction cache, removing a source of inconsistencies and
subtle errors in low-level machinery.

I've adjusted all trampoline_init implementations that used to issue
explicit calls to __clear_cache or similar to use this new primitive.


Specifically on vxworks targets, we needed to drop the __clear_cache
symbol in libgcc, for reasons related with linking that I didn't need
to understand, and we wanted to call cacheTextUpdate directly, despite
the different calling conventions: the second argument is a length
rather than the end address.

So I introduced a target hook to enable target OS-level overriding of
builtin __clear_cache call emission, retaining nearly (*) the same
logic to govern the decision on whether to emit a call (or nothing, or
a machine-dependent insn) but enabling a call to a target
system-defined function with different calling conventions to be
issued, without having to modify .md files of the various
architectures supported by the target system to introduce or modify
clear_cache insns.

(*) I write "nearly" mainly because, when not optimizing, we'd issue a
call regardless, but since the call may now be overridden, I added it
to the set of builtins that are not directly turned into calls when
not optimizing, following the normal expansion path instead.  It
wouldn't be hard to skip the emission of cache-clearing insns when not
optimizing, but it didn't seem very important, especially for the new
uses from trampoline init.

    Another difference that might be relevant is that now we expand
the begin and end arguments unconditionally.  This might make a
difference if they have side effects.  That's prettty much impossible
at expand time, but I thought I'd mention it.


I have NOT modified targets that did not issue cache-clearing calls in
trampoline init to use the new clear_cache-calling infrastructure even
if it would expand to nothing.  I have considered doing so, to have
__builtin___clear_cache and trampoline init call cacheTextUpdate on
all vxworks targets, but decided not to, since on targets that don't
do any cache clearing, cacheTextUpdate ought to be a no-op, even
though rs6000 seems to use icbi and dcbf instructions in the function
called to initialize a trampoline, but AFAICT not in the __clear_cache
builtin.  Hopefully target maintainers will have a look and take
advantage of this new piece of infrastructure to remove such
(apparent?) inconsistencies.  Not rs6000 and other that call asm-coded
trampoline setup instructions, for sure, but they might wish to
introduce a CLEAR_INSN_CACHE macro or a clear_cache expander if they
don't have one.


for  gcc/ChangeLog

	* builtins.c (default_emit_call_builtin___clear_cache): New.
	(maybe_emit_call_builtin___clear_cache): New.
	(expand_builtin___clear_cache): Split into the above.
	(expand_builtin): Do not issue clear_cache call any more.
	* builtins.h (maybe_emit_call_builtin___clear_cache): Declare.
	* config/aarch64/aarch64.c (aarch64_trampoline_init): Use
	maybe_emit_call_builtin___clear_cache.
	* config/arc/arc.c (arc_trampoline_init): Likewise.
	* config/arm/arm.c (arm_trampoline_init): Likewise.
	* config/c6x/c6x.c (c6x_initialize_trampoline): Likewise.
	* config/csky/csky.c (csky_trampoline_init): Likewise.
	* config/m68k/linux.h (FInALIZE_TRAMPOLINE): Likewise.
	* config/tilegx/tilegx.c (tilegx_trampoline_init): Likewise.
	* config/tilepro/tilepro.c (tilepro_trampoline_init): Ditto.
	* config/vxworks.c: Include rtl.h, memmodel.h, and optabs.h.
	(vxworks_emit_call_builtin___clear_cache): New.
	* config/vxworks.h (CLEAR_INSN_CACHE): Drop.
	(TARGET_EMIT_CALL_BUILTIN___CLEAR_CACHE): Define.
	* target.def (trampoline_init): In the documentation, refer to
	maybe_emit_call_builtin___clear_cache.
	(emit_call_builtin___clear_cache): New.
	* doc/tm.texi.in: Add new hook point.
	(CLEAR_CACHE_INSN): Remove duplicate 'both'.
	* doc/tm.texi: Rebuilt.
	* targhooks.h (default_meit_call_builtin___clear_cache):
	Declare.
	* tree.h (BUILTIN_ASM_NAME_PTR): New.

for  libgcc/ChangeLog

	* config/t-vxworks (LIB2ADD): Drop.
	* config/t-vxworks7 (LIB2ADD): Likewise.
	* config/vxcache.c: Remove.
2020-12-02 22:10:32 -03:00
Alexandre Oliva
93d883c773 options.exp: unsupport tests that depend on missing language
There's a help.exp test that checks that the help message for
-Wabsolute-value mentions it's available in C and ObjC, when compiling
a C++ program.

However, if GCC is built with the C++ language disabled, the
.cc file is compiled as C, and the message [available in C...] becomes
[disabled] instead, because that's the default for the flag in C.

I suppose it might also be possible to disable the C language, and
then the multitude of help.exp tests that name c as the source
language will fail.

This patch avoids these fails: it detects the message "compiler not
installed" in the compiler output, and bails out as "unsupported".


for  gcc/testsuite/ChangeLog

	* lib/options.exp (check_for_options_with_filter): Detect
	unavailable compiler for the selected language, and bail out
	as unsupported.
2020-12-02 22:10:26 -03:00
Martin Sebor
5106ff7e60 Adjust tests even more to avoid ILP32 failures after r11-5622 (PR middle-end/97373)
gcc/testsuite/ChangeLog:
	* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust expected warnings
	to correctly reflect the maximum object size.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-11.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-18.c: Same.
2020-12-02 17:29:59 -07:00
Ilya Leoshkevich
70a6200918 tree-ssa-threadbackward.c (profitable_jump_thread_path): Do not allow __builtin_constant_p.
Linux Kernel (specifically, drivers/leds/trigger/ledtrig-cpu.c) build
with GCC 10 fails on s390 with "impossible constraint".

Explanation by Jeff Law:

```
So what we have is a b_c_p at the start of an if-else chain.  Subsequent
tests on the "true" arm of the the b_c_p test may throw us off the
constant path (because the constants are out of range).  Once all the
tests are passed (it's constant and the constant is in range) the true
arm's terminal block has a special asm that requires a constant
argument.   In the case where we get to the terminal block on the true
arm, the argument to the b_c_p is used as the constant argument to the
special asm.

At first glace jump threading seems to be doing the right thing.  Except
that we end up with two paths to that terminal block with the special
asm, one for each of the two constant arguments to the b_c_p call.
Naturally since that same value is used in the asm, we have to introduce
a PHI to select between them at the head of the terminal block.   Now
the argument in the asm is no longer constant and boom we fail.
```

Fix by disallowing __builtin_constant_p on threading paths.

gcc/ChangeLog:

2020-06-03  Ilya Leoshkevich  <iii@linux.ibm.com>

	* tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path):
	Do not allow __builtin_constant_p on a threading path.

gcc/testsuite/ChangeLog:

2020-06-03  Ilya Leoshkevich  <iii@linux.ibm.com>

	* gcc.target/s390/builtin-constant-p-threading.c: New test.
2020-12-03 01:21:10 +01:00
GCC Administrator
11860cf440 Daily bump. 2020-12-03 00:16:47 +00:00
Peter Bergner
7e231b2cfb c++: Treat OPAQUE_TYPE types as an aggregate type [PR97947]
MODE_OPAQUE and the associated OPAQUE_TYPE were added to stop the optimizers
from knowing how the bits in a variable with an opaque type are laid out.
This makes them a kind of pseudo aggregate type and we need to treat them
as such when we process the INIT initializer for variables with an
opaque type.

2020-12-02  Peter Bergner  <bergner@linux.ibm.com>

gcc/cp/
	PR c++/97947
	* typeck2.c (digest_init_r): Handle OPAQUE_TYPE as an aggregate type.

gcc/testsuite/
	PR c++/97947
	* g++.target/powerpc/pr97947.C: New test.
2020-12-02 18:14:04 -06:00