aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2020-12-03c++: XFAIL testcase for PR98019Jason Merrill1-0/+1
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-03c++: Fix bootstrap on 32-bit hosts [PR91828]Jason Merrill1-2/+4
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-03Add support for detecting mismatched allocation/deallocation calls.Martin Sebor26-67/+2524
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-03c++: Exported using declsNathan Sidwell2-7/+25
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-03c++: uninstantiated template friendsNathan Sidwell2-1/+20
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-03Go testsuite: update new tests to version in source repoIan Lance Taylor23-59/+50
2020-12-03PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913Harald Anlauf2-0/+22
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-03fix __builtin___clear_cache overrider falloutAlexandre Oliva2-1/+8
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-03Go testsuite: add a bunch of new tests from source repoIan Lance Taylor112-0/+3339
2020-12-03go-test.exp: add -I. when compiling in directoryIan Lance Taylor1-5/+5
* go.test/go-test.exp (go-gc-tests): Add -I. when building all sources in a directory (errorcheckdir, compiledir, rundir, rundircmpout).
2020-12-03c++: Add testcase for PR98019Jason Merrill1-0/+10
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-03testsuite: update existing Go tests to source repoIan Lance Taylor582-10318/+4741
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-03RTEMS: Add Cortex-R52 multilibSebastian Huber1-2/+3
gcc/ * config/arm/t-rtems: Add "-mthumb -mcpu=cortex-r52 -mfloat-abi=hard" multilib.
2020-12-03c++: templatey type creationNathan Sidwell3-11/+26
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-03i386: Fix up ix86_md_asm_adjust for TImode [PR98086]Uros Bizjak2-30/+25
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-03c++: Testcases [PR 98115]Nathan Sidwell2-0/+33
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-03compiler: cast comparison function result to expected bool typeIan Lance Taylor3-6/+49
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-03compiler: defer to middle-end for complex divisionIan Lance Taylor6-2483/+4171
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-03IBM Z: Fix mode in probe_stack patternAndreas Krebbel2-3/+13
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-03c++: Fix array type dependency [PR 98107]Nathan Sidwell1-0/+10
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-03aarch64: Don't fold svundef* at the gimple levelRichard Sandiford2-11/+12
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-03Fix PR middle-end/98099Eric Botcazou2-1/+14
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-03Fix PR middle-end/98082Eric Botcazou2-2/+18
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-03c++: Add __builtin_bit_cast to implement std::bit_cast [PR93121]Jakub Jelinek22-52/+1264
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-03c++: consteval-defarg1.C test variant for templatesJakub Jelinek1-0/+29
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-03tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Do ↵Ilya Leoshkevich1-0/+6
not allow __builtin_constant_p. This is the same as commit 70a62009181f ("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-03Fix division by 0 in printf_strlen_execute when dumpingIlya Leoshkevich1-1/+1
gcc/ChangeLog: 2020-12-03 Ilya Leoshkevich <iii@linux.ibm.com> * tree-ssa-strlen.c (printf_strlen_execute): Avoid division by 0.
2020-12-03RISC-V: Canonicalize --with-archKito Cheng3-75/+111
- 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-03aarch64: Add +flagm to -marchPrzemyslaw Wirkus3-1/+10
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-03testsuite: Add testcase for already fixed PR [PR98104]Jakub Jelinek1-0/+20
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-03Optimize vpsubusw compared to 0 into vpcmpleuw or vpcmpnleuw [PR96906]liuhongt3-1/+107
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-03Fix incorrect replacement of vmovdqu32 with vpblendd which can cause fault.liuhongt14-47/+263
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-02c++: Push parms when late parsing default argsJason Merrill2-6/+37
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-02c++: Fix late-parsed default arg contextJason Merrill3-1/+21
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-03Add popcount<mode> expander to enable popcount auto vectorization under ↵Hongyu Wang5-0/+188
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-02introduce overridable clear_cache emitterAlexandre Oliva17-66/+159
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-02options.exp: unsupport tests that depend on missing languageAlexandre Oliva1-0/+5
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-02Adjust tests even more to avoid ILP32 failures after r11-5622 (PR ↵Martin Sebor3-31/+25
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-03tree-ssa-threadbackward.c (profitable_jump_thread_path): Do not allow ↵Ilya Leoshkevich2-1/+52
__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-03Daily bump.GCC Administrator4-1/+504
2020-12-02c++: Treat OPAQUE_TYPE types as an aggregate type [PR97947]Peter Bergner2-0/+13
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-03dwarf2out: Fix up add_scalar_info not to create invalid DWARFJakub Jelinek1-1/+12
As discussed in https://sourceware.org/bugzilla/show_bug.cgi?id=26987 , for very large bounds (which don't fit into HOST_WIDE_INT) GCC emits invalid DWARF. In DWARF2, DW_AT_{lower,upper}_bound were constant reference class. In DWARF3 they are block constant reference and the Static and Dynamic Properties of Types chapter says: "For a block, the value is interpreted as a DWARF expression; evaluation of the expression yields the value of the attribute." In DWARF4/5 they are constant exprloc reference class. Now, for add_AT_wide we use DW_FORM_data16 (valid in constant class) when -gdwarf-5, but otherwise just use DW_FORM_block1, which is not constant class, but block. For DWARF3 this means emitting clearly invalid DWARF, because the DW_FORM_block1 should contain a DWARF expression, not random bytes containing the constant directly. For DWARF2/DWARF4/5 it could be considered a GNU extension, but a very badly designed one when it means something different in DWARF3. The following patch uses add_AT_wide only if we know we'll be using DW_FORM_data16, and otherwise wastes 2 extra bytes and emits in there DW_OP_implicit_value <size> before the constant. 2020-12-03 Jakub Jelinek <jakub@redhat.com> * dwarf2out.c (add_scalar_info): Only use add_AT_wide for 128-bit constants and only in dwarf-5 or later, where DW_FORM_data16 is available. Otherwise use DW_FORM_block*/DW_FORM_exprloc with DW_OP_implicit_value to describe the constant.
2020-12-03c++: Implement LWG3396 Clarify point of reference for ↵Jakub Jelinek9-15/+500
source_location::current() [PR80780, PR93093] While std::source_location::current () is static consteval source_location current() noexcept; in the standard, it also says with LWG3396: "Any call to current that appears as a default member initializer ([class.mem]), or as a subexpression thereof, should correspond to the location of the constructor definition or aggregate initialization that uses the default member initializer. Any call to current that appears as a default argument ([dcl.fct.default]), or as a subexpression thereof, should correspond to the location of the invocation of the function that uses the default argument ([expr.call])." so it must work as compiler magic rather than normal immediate functions, in particular we need to defer its evaluation when parsing default arguments or nsdmis. This patch actually defers evaluation of all the calls to std::source_location::current () until genericization (or constant expression evaluation when called from constant expression contexts). I had to change constexpr.c too so that it temporarily adjusts current_function_decl from the constexpr evaluation context, but we do the same already from __builtin_FUNCTION (). 2020-12-03 Jakub Jelinek <jakub@redhat.com> PR c++/80780 PR c++/93093 * cp-tree.h (source_location_current_p): Declare. * tree.c (source_location_current_p): New function. * call.c (immediate_invocation_p): New function. (build_over_call): Use it to resolve LWG3396. * constexpr.c (cxx_eval_builtin_function_call): Temporarily set current_function_decl from ctx->call->fundef->decl if any. * cp-gimplify.c (cp_genericize_r) <case CALL_EXPR>: Fold calls to immediate function std::source_location::current (). * g++.dg/cpp2a/srcloc15.C: New test. * g++.dg/cpp2a/srcloc16.C: New test. * g++.dg/cpp2a/srcloc17.C: New test. * g++.dg/cpp2a/srcloc18.C: New test.
2020-12-02rtl-optimization: Fix data flow maintenance bug in reg-stack.c [pr97777]qing zhao2-1/+11
reg-stack pass does not maintain the data flow information correctly. call df_insn_rescan_all after the transformation is done. gcc/ PR rtl-optimization/97777 * reg-stack.c (rest_of_handle_stack_regs): call df_insn_rescan_all if reg_to_stack return true. gcc/testsuite/ PR rtl-optimization/97777 * gcc.target/i386/pr97777.c: New test.
2020-12-02c++: Give better placeholder diagnosticJason Merrill3-1/+24
We were saying 'auto parameter not permitted' in a place where 'auto' is in fact permitted in C++20, but a class template placeholder is not. gcc/cp/ChangeLog: * decl.c (grokdeclarator): Improve diagnostic for disallowed CTAD placeholder. gcc/testsuite/ChangeLog: * g++.dg/other/pr88187.C: Adjust expected error. * g++.dg/cpp2a/class-deduction-abbrev1.C: New test.
2020-12-02c++: Improve init handlingJason Merrill1-3/+11
While looking at another issue I noticed that in a template we were failing to find the INIT_EXPR we were looking for, and so ended up doing redundant processing. No testcase, as the redundant processing ended up getting the right result. gcc/cp/ChangeLog: * decl.c (check_initializer): Also look through STMT_EXPR and BIND_EXPR.
2020-12-02c++: typename_type structural comparisonNathan Sidwell3-12/+19
For modules we need to compare structurally all the way down. This means inhibiting typename_type resolution, independent of comparing specializations. gcc/cp/ * cp-tree.h (comparing_typenames): Declare. * pt.c (comparing_typenames): Define. (spec_hasher::equal): Increment it around comparisons. * typeck.c (structural_comptypes): Adjust TYPENAME resolution check.
2020-12-02c++: Fix ICE with inline variable in template [PR97975]Marek Polacek4-6/+27
In this test, we have static inline const int c = b; in a class template, and we call store_init_value as usual. There, the value is IMPLICIT_CONV_EXPR<const float>(b) which is is_nondependent_static_init_expression but isn't is_nondependent_constant_expression (they only differ in STRICT). We call fold_non_dependent_expr, but that just returns the expression because it only instantiates is_nondependent_constant_expression expressions. Since we're not checking the initializer of a constexpr variable, we go on to call maybe_constant_init, whereupon we crash because it tries to evaluate all is_nondependent_static_init_expression expressions, which our value is, but it still contains a template code. I think the fix is to call fold_non_dependent_init instead of maybe_constant_init, and only call fold_non_dependent_expr on the "this is a constexpr variable" path so as to avoid instantiating twice in a row. Outside a template this should also avoid evaluating the value twice. gcc/cp/ChangeLog: PR c++/97975 * constexpr.c (fold_non_dependent_init): Add a tree parameter. Use it. * cp-tree.h (fold_non_dependent_init): Add a tree parameter with a default value. * typeck2.c (store_init_value): Call fold_non_dependent_expr only when checking the initializer for constexpr variables. Call fold_non_dependent_init instead of maybe_constant_init. gcc/testsuite/ChangeLog: PR c++/97975 * g++.dg/cpp1z/inline-var8.C: New test.
2020-12-02c++: Fix tsubst ICE with invalid code [PR97993, PR97187]Marek Polacek3-0/+28
I had a strong sense of deja vu when looking into this, and no wonder, since this is almost identical to c++/95728. Since r11-423 tsubst_copy_and_build/TREE_LIST uses tsubst_tree_list instead of open coding it. While the latter could return an error node wrapped in a TREE_LIST, the former can return a naked error node. That broke in tsubst_copy_and_build/NEW_EXPR, because we were accessing TREE_VALUE of an error node. gcc/cp/ChangeLog: PR c++/97187 PR c++/97993 * pt.c (tsubst_copy_and_build) <case NEW_EXPR>: Return error_mark_node if init is erroneous. gcc/testsuite/ChangeLog: PR c++/97187 PR c++/97993 * g++.dg/eh/crash2.C: New test. * g++.dg/template/crash132.C: New test.
2020-12-02C++: Module-specific tree flagsNathan Sidwell1-5/+57
gcc/cp/ * cp-tree.h (DECL_MODULE_PURVIEW_P, DECL_MODULE_IMPORT_P) (DECL_MODULE_ENTITY_P): New. (DECL_MODULE_PENDING_SPECIALIZATIONS_P): New. (DECL_MODULE_PENDING_MEMBERS_P): New. (DECL_MODULE_ATTACHMENTS_P): New. (DECL_MODULE_EXPORT_P): New. (struct lang_decl_base): Shrink sel field. Add new module-specific fields.