Steve Baird [Tue, 11 Oct 2022 22:21:39 +0000 (15:21 -0700)]
ada: Put_Image aspect spec incorrectly not inherited
In some cases, a Put_Image aspect specification for a scalar type was not
correctly inherited by a descendant of that type.
gcc/ada/
* exp_put_image.adb
(Image_Should_Call_Put_Image): Correctly handle the case of an
inherited Put_Image aspect specification for a scalar type.
Piotr Trojanek [Fri, 9 Sep 2022 15:48:45 +0000 (17:48 +0200)]
ada: Tune layout after switching to Ada 2022 aggregate syntax
Whitespace cleanup only.
gcc/ada/
* libgnarl/s-interr.adb: Tune whitespace.
Piotr Trojanek [Fri, 9 Sep 2022 15:46:22 +0000 (17:46 +0200)]
ada: Cleanup WITH clauses after switching from obsolescent Ada 83 unit
Cleanup after replacing Unchecked_Conversion with
Ada.Unchecked_Conversion.
gcc/ada/
* libgnarl/s-interr.adb: Reorder context items and pragmas.
Piotr Trojanek [Fri, 2 Sep 2022 11:32:27 +0000 (13:32 +0200)]
ada: Create operator nodes in functional style
A recent patch removed two rewritings, where we kept the operator node
but replaced its operands. This patch removes explicit setting of the
operands; instead, the operator is already created together with its
operands, which seems a bit safer and more consistent with how we
typically create operator nodes.
It is a cleanup only; semantics is unaffected.
gcc/ada/
* exp_ch4.adb
(Expand_Modular_Addition): Rewrite using Make_XXX calls.
(Expand_Modular_Op): Likewise.
(Expand_Modular_Subtraction): Likewise.
* exp_imgv.adb
(Expand_User_Defined_Enumeration_Image): Likewise.
Piotr Trojanek [Fri, 2 Sep 2022 20:42:57 +0000 (22:42 +0200)]
ada: Don't reuse operator nodes in expansion
This patch removes handling of references to unset objects that relied
on Original_Node. This handling was only needed because of rewriting
that reused operator nodes, for example, when an array inequality like:
A < B
was rewritten into:
System.Compare_Array_Unsigned_8.Compare_Array_U8
(A'Address, B'Address, A'Length, B'Length) < 0
by keeping the node for operator "<" and only substituting its operands.
It seems safer to simply create an new operator node when rewriting and
not rely on Original_Node afterwards.
Cleanup related to improved detection uninitialized objects.
gcc/ada/
* checks.adb (Apply_Arithmetic_Overflow_Strict): Rewrite using a
newly created operator node.
* exp_ch4.adb (Expand_Array_Comparison): Likewise.
* exp_ch6.adb (Add_Call_By_Copy_Code): Rewriting actual parameter
using its own location and not the location of the subprogram
call.
* sem_warn.adb (Check_References): Looping with Original_Node is
no longer needed.
Piotr Trojanek [Wed, 7 Sep 2022 14:02:42 +0000 (16:02 +0200)]
ada: Simplify detection of pragmas in the context items
Code cleanup; semantics is unaffected.
gcc/ada/
* sem_prag.adb (Is_In_Context_Clause): Rewrite without negations
and inequalities.
Piotr Trojanek [Wed, 7 Sep 2022 13:02:04 +0000 (15:02 +0200)]
ada: Reject misplaced pragma Obsolescent
Pragma Obsolescent appearing before declaration was putting the
Obsolescent flag on the Standard package, which is certainly wrong. The
problem was that we relied on the Find_Lib_Unit_Name routine without
sanitizing the pragma placement with Check_Valid_Library_Unit_Pragma.
Part of cleaning up the warnings machinery to better handle references
to unset objects.
gcc/ada/
* sem_prag.adb (Analyze_Pragma [Pragma_Obsolescent]): Reject
misplaced pragma.
Piotr Trojanek [Wed, 7 Sep 2022 13:01:16 +0000 (15:01 +0200)]
ada: Fix missing tag for with of an obsolescent function
Fix minor inconsistency in tags of warnings about obsolescent entities.
Part of cleaning up the warnings machinery to better handle references
to unset objects.
gcc/ada/
* sem_warn.adb (Output_Obsolescent_Entity_Warnings): Tag warnings
about obsolescent functions just like we tag similar warnings for
packages and procedures.
Piotr Trojanek [Wed, 12 Oct 2022 10:17:34 +0000 (12:17 +0200)]
ada: Remove useless validity suppression for attribute Input
Attributes 'Input and 'Read are similar, but only the 'Read denotes a
subprogram with parameter of mode OUT where operand validity checks need
to be suppressed.
Cleanup related to fix for attributes 'Has_Same_Storage and
'Overlaps_Storage.
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference): Remove useless
skipping for attribute Input.
Kewen Lin [Mon, 7 Nov 2022 08:07:27 +0000 (02:07 -0600)]
vect: Fold LEN_{LOAD,STORE} if it's for the whole vector [PR107412]
As the test case in PR107412 shows, we can fold IFN .LEN_{LOAD,
STORE} into normal vector load/store if the given length is known
to be equal to the length of the whole vector. It would help to
improve overall cycles as normally the latency of vector access
with length in bytes is bigger than normal vector access, and it
also saves the preparation for length if constant length can not
be encoded into instruction (such as on power).
PR tree-optimization/107412
gcc/ChangeLog:
* gimple-fold.cc (gimple_fold_mask_load_store_mem_ref): Rename to ...
(gimple_fold_partial_load_store_mem_ref): ... this, add one parameter
mask_p indicating it's for mask or length, and add some handlings for
IFN LEN_{LOAD,STORE}.
(gimple_fold_mask_load): Rename to ...
(gimple_fold_partial_load): ... this, add one parameter mask_p.
(gimple_fold_mask_store): Rename to ...
(gimple_fold_partial_store): ... this, add one parameter mask_p.
(gimple_fold_call): Add the handlings for IFN LEN_{LOAD,STORE},
and adjust calls on gimple_fold_mask_load_store_mem_ref to
gimple_fold_partial_load_store_mem_ref.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr107412.c: New test.
* gcc.target/powerpc/p9-vec-length-epil-8.c: Adjust scan times for
folded LEN_LOAD.
Hu, Lin1 [Mon, 7 Nov 2022 03:31:15 +0000 (11:31 +0800)]
Initial Grand Ridge support
gcc/ChangeLog:
* common/config/i386/cpuinfo.h
(get_intel_cpu): Handle Grand Ridge.
* common/config/i386/i386-common.cc
(processor_names): Add grandridge.
(processor_alias_table): Ditto.
* common/config/i386/i386-cpuinfo.h:
(enum processor_types): Add INTEL_GRANDRIDGE.
* config.gcc: Add -march=grandridge.
* config/i386/driver-i386.cc (host_detect_local_cpu):
Handle grandridge.
* config/i386/i386-c.cc (ix86_target_macros_internal):
Ditto.
* config/i386/i386-options.cc (m_GRANDRIDGE): New define.
(processor_cost_table): Add grandridge.
* config/i386/i386.h (enum processor_type):
Add PROCESSOR_GRANDRIDGE.
(PTA_GRANDRIDGE): Ditto.
* doc/extend.texi: Add grandridge.
* doc/invoke.texi: Ditto.
gcc/testsuite/ChangeLog:
* g++.target/i386/mv16.C: Add grandridge.
* gcc.target/i386/funcspec-56.inc: Handle new march.
konglin1 [Mon, 7 Nov 2022 03:21:14 +0000 (11:21 +0800)]
i386: Prefer remote atomic insn for atomic_fetch{add, and, or, xor}
Add flag -mprefer-remote-atomic to control whether to generate raoint
insn for atomic operations.
gcc/ChangeLog:
* config/i386/i386.opt:Add -mprefer-remote-atomic.
* config/i386/sync.md (atomic_<plus_logic><mode>):
New define_expand.
(atomic_add<mode>): Rename to below one.
(atomic_add<mode>_1): To this.
(atomic_<logic><mode>): Ditto.
(atomic_<logic><mode>_1): Ditto.
* doc/invoke.texi: Add -mprefer-remote-atomic.
gcc/testsuite/ChangeLog:
* gcc.target/i386/raoint-atomic-fetch.c: New test.
konglin1 [Mon, 7 Nov 2022 02:33:45 +0000 (10:33 +0800)]
Support Intel RAO-INT
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_available_features):
Detect raoint.
* common/config/i386/i386-common.cc (OPTION_MASK_ISA2_RAOINT_SET,
OPTION_MASK_ISA2_RAOINT_UNSET): New.
(ix86_handle_option): Handle -mraoint.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
Add FEATURE_RAOINT.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
raoint.
* config.gcc: Add raointintrin.h
* config/i386/cpuid.h (bit_RAOINT): New.
* config/i386/i386-builtin.def (BDESC): Add new builtins.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__RAOINT__.
* config/i386/i386-isa.def (RAOINT): Add DEF_PTA(RAOINT).
* config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p):
Add -mraoint.
* config/i386/sync.md (rao_a<raointop><mode>): New define insn.
* config/i386/i386.opt: Add option -mraoint.
* config/i386/x86gprintrin.h: Include raointintrin.h.
* doc/extend.texi: Document raoint.
* doc/invoke.texi: Document -mraoint.
* doc/sourcebuild.texi: Document target raoint.
* config/i386/raointintrin.h: New file.
gcc/testsuite/ChangeLog:
* g++.dg/other/i386-2.C: Add -mraoint.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/sse-12.c: Add -mraoint.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Add raoint target.
* gcc.target/i386/sse-23.c: Ditto.
* lib/target-supports.exp: Add check_effective_target_raoint.
* gcc.target/i386/rao-helper.h: New test.
* gcc.target/i386/raoint-1.c: Ditto.
* gcc.target/i386/raoint-aadd-2.c: Ditto.
* gcc.target/i386/raoint-aand-2.c: Ditto.
* gcc.target/i386/raoint-aor-2.c: Ditto.
* gcc.target/i386/raoint-axor-2.c: Ditto.
* gcc.target/i386/x86gprintrin-1.c: Ditto.
* gcc.target/i386/x86gprintrin-2.c: Ditto.
* gcc.target/i386/x86gprintrin-3.c: Ditto.
* gcc.target/i386/x86gprintrin-4.c: Ditto.
* gcc.target/i386/x86gprintrin-5.c: Ditto.
Haochen Jiang [Mon, 7 Nov 2022 03:04:57 +0000 (11:04 +0800)]
Initial Granite Rapids Support
gcc/ChangeLog:
* common/config/i386/cpuinfo.h
(get_intel_cpu): Handle Granite Rapids.
* common/config/i386/i386-common.cc:
(processor_names): Add graniterapids.
(processor_alias_table): Ditto.
* common/config/i386/i386-cpuinfo.h
(enum processor_subtypes): Add INTEL_GRANTIERAPIDS.
* config.gcc: Add -march=graniterapids.
* config/i386/driver-i386.cc (host_detect_local_cpu):
Handle graniterapids.
* config/i386/i386-c.cc (ix86_target_macros_internal):
Ditto.
* config/i386/i386-options.cc (m_GRANITERAPIDS): New.
(processor_cost_table): Add graniterapids.
* config/i386/i386.h (enum processor_type):
Add PROCESSOR_GRANITERAPIDS.
(PTA_GRANITERAPIDS): Ditto.
* doc/extend.texi: Add graniterapids.
* doc/invoke.texi: Ditto.
gcc/testsuite/ChangeLog:
* g++.target/i386/mv16.C: Add graniterapids.
* gcc.target/i386/funcspec-56.inc: Handle new march.
Haochen Jiang [Fri, 4 Nov 2022 07:01:05 +0000 (15:01 +0800)]
Support Intel prefetchit0/t1
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_available_features):
Detect PREFETCHI.
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_PREFETCHI_SET,
OPTION_MASK_ISA2_PREFETCHI_UNSET): New.
(ix86_handle_option): Handle -mprefetchi.
* common/config/i386/i386-cpuinfo.h
(enum processor_features): Add FEATURE_PREFETCHI.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY
for prefetchi.
* config.gcc: Add prfchiintrin.h.
* config/i386/cpuid.h (bit_PREFETCHI): New.
* config/i386/i386-builtin-types.def:
Add DEF_FUNCTION_TYPE (VOID, PCVOID, INT)
and DEF_FUNCTION_TYPE (VOID, PCVOID, INT, INT, INT).
* config/i386/i386-builtin.def (BDESC): Add new builtins.
* config/i386/i386-c.cc (ix86_target_macros_internal):
Define __PREFETCHI__.
* config/i386/i386-expand.cc: Handle new builtins.
* config/i386/i386-isa.def (PREFETCHI):
Add DEF_PTA(PREFETCHI).
* config/i386/i386-options.cc
(ix86_valid_target_attribute_inner_p): Handle prefetchi.
* config/i386/i386.md (prefetchi): New define_insn.
* config/i386/i386.opt: Add option -mprefetchi.
* config/i386/predicates.md (local_func_symbolic_operand):
New predicates.
* config/i386/x86gprintrin.h: Include prfchiintrin.h.
* config/i386/xmmintrin.h (enum _mm_hint): New enum for
prefetchi.
(_mm_prefetch): Handle the highest bit of enum.
* doc/extend.texi: Document prefetchi.
* doc/invoke.texi: Document -mprefetchi.
* doc/sourcebuild.texi: Document target prefetchi.
* config/i386/prfchiintrin.h: New file.
gcc/testsuite/ChangeLog:
* g++.dg/other/i386-2.C: Add -mprefetchi.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/avx-1.c: Ditto.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/sse-13.c: Add -mprefetchi.
* gcc.target/i386/sse-23.c: Ditto.
* gcc.target/i386/x86gprintrin-1.c: Ditto.
* gcc.target/i386/x86gprintrin-2.c: Ditto.
* gcc.target/i386/x86gprintrin-3.c: Ditto.
* gcc.target/i386/x86gprintrin-4.c: Ditto.
* gcc.target/i386/x86gprintrin-5.c: Ditto.
* gcc.target/i386/prefetchi-1.c: New test.
* gcc.target/i386/prefetchi-2.c: Ditto.
* gcc.target/i386/prefetchi-3.c: Ditto.
* gcc.target/i386/prefetchi-4.c: Ditto.
Co-authored-by: Hongtao Liu <hongtao.liu@intel.com>
GCC Administrator [Mon, 7 Nov 2022 00:16:42 +0000 (00:16 +0000)]
Daily bump.
Uros Bizjak [Sun, 6 Nov 2022 19:51:01 +0000 (20:51 +0100)]
optabs: Use operand[2] mode in can_vec_set_var_idx_p
Use operand[2] mode in can_vec_set_var_idx_p when checking vec_set_optab.
This change allows non-VOID index operand in vec_set_optab.
2022-11-06 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
* optabs.cc (can_vec_set_var_idx_p): Use operand[2]
mode when checking vec_set_optab.
Patrick Palka [Sun, 6 Nov 2022 16:30:47 +0000 (11:30 -0500)]
libstdc++: Declare const global variables inline
The changes inside the regex_constants and execution namespaces seem to
be (the only) unimplemented parts of P0607R0 "Inline Variable for the
Standard Library"; the rest of the changes are to implementation details.
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (_detail::__platform_wait_alignment):
Declare inline. Remove redundant static specifier.
(__detail::__atomic_spin_count_relax): Declare inline.
(__detail::__atomic_spin_count): Likewise.
* include/bits/regex_automaton.h (__detail::_S_invalid_state_id):
Declare inline for C++17. Declare constexpr. Remove
redundant const and static specifiers.
* include/bits/regex_error.h (regex_constants::error_collate):
Declare inline for C++17 as per P0607R0.
(regex_constants::error_ctype): Likewise.
(regex_constants::error_escape): Likewise.
(regex_constants::error_backref): Likewise.
(regex_constants::error_brack): Likewise.
(regex_constants::error_paren): Likewise.
(regex_constants::error_brace): Likewise.
(regex_constants::error_badbrace): Likewise.
(regex_constants::error_range): Likewise.
(regex_constants::error_space): Likewise.
(regex_constants::error_badrepeat): Likewise.
(regex_constants::error_complexity): Likewise.
(regex_constants::error_stack): Likewise.
* include/ext/concurrence.h (__gnu_cxx::__default_lock_policy):
Likewise. Remove redundant static specifier.
* include/pstl/execution_defs.h (execution::seq): Declare inline
for C++17 as per P0607R0.
(execution::par): Likewise.
(execution::par_unseq): Likewise.
(execution::unseq): Likewise.
Patrick Palka [Sun, 6 Nov 2022 16:16:00 +0000 (11:16 -0500)]
libstdc++: Move stream initialization into compiled library [PR44952]
This patch moves the static object for constructing the standard streams
out from <iostream> and into the compiled library on systems that support
init priorities. This'll mean <iostream> no longer introduces a separate
global constructor in each TU that includes it.
We can do this only if the init_priority attribute is supported because
we need a way to ensure the stream initialization runs first before any
user global initializer, particularly when linking with a static
libstdc++.a.
PR libstdc++/44952
PR libstdc++/39796
PR libstdc++/98108
libstdc++-v3/ChangeLog:
* include/std/iostream (__ioinit): No longer define here if
the init_priority attribute is usable.
* src/c++98/ios_init.cc (__ioinit): Define here instead if
init_priority is usable, via ...
* src/c++98/ios_base_init.h: ... this new file.
Patrick Palka [Sun, 6 Nov 2022 16:09:26 +0000 (11:09 -0500)]
c++: correct __has_attribute(init_priority)
Currently __has_attribute(init_priority) always returns true, even on
targets that don't actually support init priorities, and when using the
attribute on such targets we just get a hard error about them being
unsupported. This makes it impossible to conditionally use the attribute
by querying __has_attribute.
This patch fixes this by including init_priority in the attribute table
only if the target supports init priorities. Thus on such targets
__has_attribute(init_priority) will now return false and we'll treat it
as just another unrecognized attribute (e.g. using it gives a -Wattribute
warning instead of a hard error).
gcc/cp/ChangeLog:
* tree.cc (cxx_attribute_table): Include init_priority entry
only if SUPPORTS_INIT_PRIORITY.
(handle_init_priority_attribute): Add ATTRIBUTE_UNUSED. Assert
SUPPORTS_INIT_PRIORITY is true.
gcc/testsuite/ChangeLog:
* g++.dg/special/initpri3.C: New test.
Jakub Jelinek [Sun, 6 Nov 2022 11:12:47 +0000 (12:12 +0100)]
Manually add ChangeLog entries from r13-3652-ge4cba49413ca429dc82f6aa2e88129ecb3fdd943
This commit caused failure of update_version_git due to the removal of
liboffloadmic with ChangeLog in it, so I had to blacklist that commit
and here I'm adding ChangeLog entries manually.
GCC Administrator [Sun, 6 Nov 2022 11:05:22 +0000 (11:05 +0000)]
Daily bump.
Jakub Jelinek [Sun, 6 Nov 2022 10:59:44 +0000 (11:59 +0100)]
Add another commit to ignore
We can't handle r13-3652-ge4cba49413ca429dc82f6aa2e88129ecb3fdd943
* gcc-changelog/git_update_version.py: Add
e4cba49413ca429dc82f6aa2e88129ecb3fdd943 to ignored commits.
Xi Ruoyao [Fri, 4 Nov 2022 07:12:22 +0000 (15:12 +0800)]
LoongArch: Add fcopysign instructions
Add fcopysign.{s,d} with the names copysign{sf,df}3 so GCC will expand
__builtin_copysign{f,} to a single instruction.
Link: https://sourceware.org/pipermail/libc-alpha/2022-November/143177.html
gcc/ChangeLog:
* config/loongarch/loongarch.md (UNSPEC_FCOPYSIGN): New unspec.
(type): Add fcopysign.
(copysign<mode>3): New instruction template.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/fcopysign.c: New test.
Bernhard Reutner-Fischer [Thu, 3 Nov 2022 20:52:51 +0000 (21:52 +0100)]
Plug memory leak in attribute target_clones
It looks like there was some memory leak in the handling
of attribute target_clones.
Ok for trunk if testing passes?
gcc/ChangeLog:
* multiple_target.cc (expand_target_clones): Free memory.
Signed-off-by: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Bernhard Reutner-Fischer [Thu, 3 Nov 2022 20:20:57 +0000 (21:20 +0100)]
cgraph_node: Remove redundant section clearing
Ok for trunk if testing passes?
gcc/ChangeLog:
* cgraph.cc (cgraph_node::make_local): Remove redundant set_section.
* multiple_target.cc (create_dispatcher_calls): Likewise.
Signed-off-by: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Iain Buclaw [Sat, 5 Nov 2022 18:45:05 +0000 (19:45 +0100)]
d: Adjust test to pass when compiling with -m32
Noticed when running on x86_64-linux-gnu with `-m32', this test
triggered other errors. Adjusted the test to use a different register
that is common between x86 and x86_64.
gcc/testsuite/ChangeLog:
* gdc.dg/attr_register2.d: Adjust test.
Iain Buclaw [Sat, 5 Nov 2022 18:32:17 +0000 (19:32 +0100)]
d: Add support for vector comparison operators
The front-end added semantic support to permit comparing two vector
expressions. This removes the restriction in the code generator, as
well as the intrisics that previously exposed the same operation.
gcc/d/ChangeLog:
* d-target.cc (Target::isVectorOpSupported): Remove cases for
comparison operators.
* intrinsics.cc (maybe_set_intrinsic): Remove cases for vector
comparison intrinsics.
(maybe_warn_intrinsic_mismatch): Likewise.
(expand_intrinsic_vec_cond): Remove.
(maybe_expand_intrinsic): Remove cases for vector comparison
intrinsics.
* intrinsics.def (INTRINSIC_EQUALMASK): Remove.
(INTRINSIC_NOTEQUALMASK): Remove.
(INTRINSIC_GREATERMASK): Remove.
(INTRINSIC_GREATEREQUALMASK): Remove.
libphobos/ChangeLog:
* libdruntime/gcc/simd.d (equalMask): Implement using generics.
(notEqualMask): Likewise.
(greaterMask): Likewise.
(greaterOrEqualMask): Likewise.
(notMask): Likewise.
(andAndMask): Likewise.
(orOrMask): Likewise.
gcc/testsuite/ChangeLog:
* gdc.dg/Wbuiltin_declaration_mismatch2.d: Remove comparision tests.
* gdc.dg/simd2a.d: Update comparison tests.
* gdc.dg/simd2b.d: Likewise.
* gdc.dg/simd2c.d: Likewise.
* gdc.dg/simd2d.d: Likewise.
* gdc.dg/simd2e.d: Likewise.
* gdc.dg/simd2f.d: Likewise.
* gdc.dg/simd2g.d: Likewise.
* gdc.dg/simd2h.d: Likewise.
* gdc.dg/simd2i.d: Likewise.
* gdc.dg/simd2j.d: Likewise.
Lewis Hyatt [Wed, 15 Jun 2022 22:06:53 +0000 (18:06 -0400)]
c++: libcpp: Support raw strings with newlines in directives [PR55971]
It's not currently possible to use a C++11 raw string containing a newline as
part of the definition of a macro, or in any other preprocessing directive,
such as:
#define X R"(two
lines)"
#error R"(this error has
two lines)"
Add support for that by relaxing the conditions under which
_cpp_get_fresh_line() refuses to get a new line. For the case of lexing a raw
string, it's OK to do so as long as there is another line within the current
buffer. The code in cpp_get_fresh_line() was refactored into a new function
get_fresh_line_impl(), so that the new logic is applied only when processing a
raw string and not any other times.
libcpp/ChangeLog:
PR preprocessor/55971
* lex.cc (get_fresh_line_impl): New function refactoring the code
from...
(_cpp_get_fresh_line): ...here.
(lex_raw_string): Use the new version of get_fresh_line_impl() to
support raw strings containing new lines when processing a directive.
gcc/testsuite/ChangeLog:
PR preprocessor/55971
* c-c++-common/raw-string-directive-1.c: New test.
* c-c++-common/raw-string-directive-2.c: New test.
gcc/c-family/ChangeLog:
PR preprocessor/55971
* c-ppoutput.cc (adjust_for_newlines): Update comment.
Jakob Hasse [Tue, 26 Apr 2022 04:03:47 +0000 (12:03 +0800)]
libstdc++: fix pointer type exception catch (no RTTI) [PR105387]
__pbase_type_info::__do_catch(), used to catch pointer type exceptions,
did not check if the type info object to compare against is a pointer
type info object before doing a static down-cast to a pointer type info
object. If RTTI is disabled, this leads to the following situation:
Since a pointer type info object has additional fields, they would
end up being undefined if the actual type info object was not a pointer
type info object.
A simple check has been added before the down-cast happens.
Note that a consequence of this check is that exceptions of type
pointer-to-member cannot be caught anymore.
In case RTTI is enabled, this does not seem to be a problem because
RTTI-based checks would run before and prevent running into the bad
down-cast. Hence, the fix is disabled if RTTI is enabled and exceptions
of type pointer-to-member can still be caught.
libstdc++-v3/ChangeLog:
PR libstdc++/105387
* libsupc++/pbase_type_info.cc (__do_catch) [!__cpp_rtti]: Add
check that the thrown type is actually a pointer.
* testsuite/18_support/105387.cc: New test.
* testsuite/18_support/105387_memptr.cc: New test.
Signed-off-by: Jakob Hasse <jakob.hasse@espressif.com>
Jonathan Wakely [Fri, 4 Nov 2022 15:05:41 +0000 (15:05 +0000)]
libstdc++: Do not use SFINAE for propagate_const conversions [PR107525]
As the PR notes, the current conversion operators are defined as
function templates so that we can use SFINAE. But this changes how they
are considered for overload resolution. This moves those operators into
base classes that can be specialized so the operators are obsent unless
the constraints are satisfied.
libstdc++-v3/ChangeLog:
PR libstdc++/107525
* include/experimental/propagate_const (operator element_type*()):
Move into base class that can be partially specilized to iompose
constraints.
(operator const element_type*()): Likewise.
* testsuite/experimental/propagate_const/observers/107525.cc: New test.
Jonathan Wakely [Fri, 4 Nov 2022 12:10:32 +0000 (12:10 +0000)]
doc: Document correct -fwide-exec-charset defaults [PR41041]
As shown in the PR, the default is not UTF-32 but rather UTF-32BE or
UTF-32LE, avoiding the need for a byte order mark in literals.
gcc/ChangeLog:
PR c/41041
* doc/cppopts.texi: Document -fwide-exec-charset defaults
correctly.
Alexandre Oliva [Sat, 5 Nov 2022 06:14:33 +0000 (03:14 -0300)]
Support multilib-aware target lib flags self-specs overriding
This patch introduces -fmultiflags, short for multilib TFLAGS, as an
option that does nothing by default, but that can be added to TFLAGS
and mapped to useful options by driver self-specs.
for gcc/ChangeLog
* common.opt (fmultiflags): New.
* doc/invoke.texi: Document it.
* gcc.cc (driver_self_specs): Discard it.
* opts.cc (common_handle_option): Ignore it in the driver.
Jakub Jelinek [Fri, 4 Nov 2022 17:20:36 +0000 (18:20 +0100)]
testsuite: Add testcase from C++23 P2314R4 - Character sets and encodings
I've read the paper and I believe we just implement it with no changes
needed (at least since PR67224 and similar libcpp changes in GCC 10),
but I could be wrong.
The following patch at least adds a testcase from the start of the paper.
2022-11-04 Jakub Jelinek <jakub@redhat.com>
* g++.dg/cpp23/charset1.C: New testcase from C++23 P2314R4.
Jakub Jelinek [Fri, 4 Nov 2022 17:18:42 +0000 (18:18 +0100)]
libcpp: Update to Unicode 15
The following pseudo-patch regenerates the libcpp tables with Unicode 15.0.0
which added 4489 new characters.
As mentioned previously, this isn't just a matter of running the
two libcpp/make*.cc programs on the new Unicode files, but one needs
to manually update a table inside of makeuname2c.cc according to
a table in Unicode text (which is partially reflected in the text
files, but e.g. in Unicode 14.0.0 not 100% accurately, in 15.0.0
actually accurately).
I've also added some randomly chosen subset of those 4489 new
characters to a testcase.
2022-11-04 Jakub Jelinek <jakub@redhat.com>
gcc/testsuite/
* c-c++-common/cpp/named-universal-char-escape-1.c: Add tests for some
characters newly added in Unicode 15.0.0.
libcpp/
* makeuname2c.cc (struct generated): Update from Unicode 15.0.0
table 4-8.
* ucnid.h: Regenerated for Unicode 15.0.0.
* uname2c.h: Likewise.
Wilco Dijkstra [Thu, 27 Oct 2022 15:40:17 +0000 (16:40 +0100)]
AArch64: Fix testcase
gcc/testsuite/
* gcc.target/aarch64/mgeneral-regs_3.c: Fix testcase.
Jeff Chapman II [Thu, 3 Nov 2022 19:47:47 +0000 (15:47 -0400)]
input: add get_source_text_between
The c++-contracts branch uses this to retrieve the source form of the
contract predicate, to be returned by contract_violation::comment().
Co-authored-by: Jason Merrill <jason@redhat.com>
gcc/ChangeLog:
* input.cc (get_source_text_between): New fn.
* input.h (get_source_text_between): Declare.
Aldy Hernandez [Fri, 4 Nov 2022 09:20:46 +0000 (10:20 +0100)]
Set nonzero bits for multiplication and divisions by a power of 2.
We're missing a lot of TLC in keeping track of nonzero bits across
range-ops. It isn't an oversight, but just limited amount of hours to
implement stuff.
This patch keeps better track of the nonzero mask (really
maybe_nonzero bits as discussed) across multiplication and division
when the RHS is a power of 2.
It fixes PR107342 and also touches on PR55157. In the latter, the
nonzero mask is being set quite late (CCP2) but could be set by evrp
time if we enhanced range-ops. I have added tests from both PRs.
Tested
PR tree-optimization/107342
gcc/ChangeLog:
* range-op.cc (operator_mult::fold_range): New.
(operator_div::fold_range): New.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp122.c: New test.
* gcc.dg/tree-ssa/vrp123.c: New test.
Eric Botcazou [Fri, 4 Nov 2022 10:23:12 +0000 (11:23 +0100)]
Fix recent thinko in operand_equal_p
There is a thinko in a recent improvement made to operand_equal_p where
the code just looks at operand 2 of COMPONENT_REF, if it is present, to
compare addresses. That's wrong because operand 2 contains the number of
DECL_OFFSET_ALIGN-bit-sized words so, when DECL_OFFSET_ALIGN > 8, not all
the bytes are included and some of them are in DECL_FIELD_BIT_OFFSET, see
get_inner_reference for the model computation.
In other words, you would need to compare operand 2 and DECL_OFFSET_ALIGN
and DECL_FIELD_BIT_OFFSET in this situation, but I'm not sure this is worth
the hassle in practice so the fix just removes this alternate handling.
gcc/
* fold-const.cc (operand_compare::operand_equal_p) <COMPONENT_REF>:
Do not take into account operand 2.
(operand_compare::hash_operand) <COMPONENT_REF>: Likewise.
gcc/testsuite/
* gnat.dg/opt99.adb: New test.
* gnat.dg/opt99_pkg1.ads, gnat.dg/opt99_pkg1.adb: New helper.
* gnat.dg/opt99_pkg2.ads: Likewise.
Eric Botcazou [Fri, 4 Nov 2022 10:15:57 +0000 (11:15 +0100)]
Do not use subword paradoxical subregs in emit_group_store
The goal of the trick is to make life easier for the combiner, but subword
paradoxical subregs make it harder for the register allocator instead.
gcc/
* expr.cc (emit_group_store): Do not use subword paradoxical subregs
Jonathan Wakely [Thu, 3 Nov 2022 11:48:57 +0000 (11:48 +0000)]
libstdc++: Simplify lifetime of eh_globals variable [PR107500]
Since this is a trivial type, we probably don't need to do anything to
ensure it's still accessible after other static dtors.
libstdc++-v3/ChangeLog:
PR libstdc++/107500
* libsupc++/eh_globals.cc (eh_globals): Remove immortalizing
wrapper.
(__cxxabiv1::__cxa_get_globals_fast): Adjust.
(__cxxabiv1::__cxa_get_globals): Adjust.
Jonathan Wakely [Thu, 3 Nov 2022 11:44:47 +0000 (11:44 +0000)]
libstdc++: Define _GNU_SOURCE for secure_getenv on Cygwin [PR107511]
As in r12-6867-ge20486d508afdf we need to define _GNU_SOURCE explicitly
for Cygwin, because configure finds it in libc but it isn't declared
unless we request it.
libstdc++-v3/ChangeLog:
PR libstdc++/107511
* libsupc++/eh_alloc.cc (_GNU_SOURCE): Define.
Justin Squirek [Wed, 12 Oct 2022 09:53:04 +0000 (11:53 +0200)]
ada: Fix for validity checks combined with aliasing checks
Attribute Overlaps_Storage, which can appear implicitly in expansion of
aliasing checks, is now excluded from operand validity checks. Likewise
for attribute Has_Same_Storage.
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference): Skip operand
validity checks for attributes Has_Same_Storage and
Overlaps_Storage.
Eric Botcazou [Wed, 12 Oct 2022 10:41:49 +0000 (12:41 +0200)]
ada: Fix couple of issues with arrays indexed by enumeration type
The first one is that Remove_Warning_Messages reinstates the Original_Node
of an N_Raise_Constraint_Error node in the tree for no clear reasons, and
the Original_Node may contain constructs whose expansion has been stopped
when the Constraint_Error was asserted, eventually causing gigi to stop.
The second one is that a path in Build_Array_Aggr_Code.Gen_Loop does not
copy the loop bounds, unlike other paths, thus triggering a sharing issue.
gcc/ada/
* errout.adb (Remove_Warning_Messages.Check_For_Warning): Do not
reinstate the Original_Node in the tree.
* exp_aggr.adb (Build_Array_Aggr_Code.Gen_Loop): Copy the bounds
on all paths.
Piotr Trojanek [Thu, 1 Sep 2022 08:16:23 +0000 (10:16 +0200)]
ada: Fix typo in comment referring to pragma Restrictions
Comment cleanup only.
gcc/ada/
* libgnat/g-excact.ads
(Register_Global_Action): Refill comment.
(Name_To_Id): Change pragma Restriction from singular to plural.
Piotr Trojanek [Wed, 24 Aug 2022 11:27:49 +0000 (13:27 +0200)]
ada: Cleanup code for warnings about unreferenced formal parameters
Cleanup related to new checks for unset references.
gcc/ada/
* sem_warn.adb (Check_References): Remove redundant guard, as it
is implied by a preceding call to Referenced_Check_Spec.
Piotr Trojanek [Tue, 23 Aug 2022 13:59:32 +0000 (15:59 +0200)]
ada: Cleanup code for unreferenced variables
Further cleanups related to warnings about unreferenced objects.
gcc/ada/
* sem_warn.adb (Check_References): Remove useless query for "spec"
of a variable; refactor nested if-statements into a single
condition.
Piotr Trojanek [Tue, 23 Aug 2022 10:57:35 +0000 (12:57 +0200)]
ada: Cleanup code for warnings about unset references
Cleanup related to new checks for unset references.
gcc/ada/
* sem_util.adb
(In_Pragma_Expression): Add standard guard against searching too
far.
(In_Quantified_Expression): Likewise.
* sem_warn.adb
(May_Need_Initialized_Actual): Remove redundant parens.
(Check_References): Remove guard that duplicates a condition from
the enclosing if-statement; only assign E1T variable when
necessary.
(Within_Postcondition): Fix layout.
(No_Warn_On_In_Out): Balance parens in comment.
Steve Baird [Sat, 8 Oct 2022 00:20:31 +0000 (17:20 -0700)]
ada: Static intrinsic functions are a core language extension.
GNAT-defined Ada extensions are divided into two categories: those that are
enabled by either -gnatX or -gnatX0 and those which require -gnatX0.
Move static intrinsic functions from the second category into the first.
gcc/ada/
* doc/gnat_rm/implementation_defined_pragmas.rst: Add the standard
'... "On" enables this extension.' sentence to the description of
static intrinsic functions.
* sem_ch13.adb
(Analyze_Aspect_Spec): In the call to Error_Msg_GNAT_Extension for
a Static aspect specification for an intrinsic function, specify
Is_Core_Extension => True.
* sem_eval.adb
(Eval_Intrinsic_Call): Test Core_Extensions_Allowed instead of
testing All_Extensions_Allowed.
* gnat_rm.texi: Regenerate.
Piotr Trojanek [Fri, 26 Aug 2022 13:27:31 +0000 (15:27 +0200)]
ada: Remove redundant calls in handling of aspect specifications
Routine Set_Aspect_Specifications sets the Has_Aspect flag, so there is
no need to set this flag again afterwards.
Code cleanup; semantics is unaffected.
gcc/ada/
* aspects.adb (Relocate_Aspect): Remove call to Set_Has_Aspects.
* sem_ch12.adb (Analyze_Formal_Package_Declaration): Likewise.
* sem_util.adb (Copy_Ghost_Aspect, Copy_SPARK_Mode_Aspect):
Likewise.
Javier Miranda [Fri, 7 Oct 2022 18:43:46 +0000 (18:43 +0000)]
ada: Flag unsupported dispatching constructor calls
gcc/ada/
* exp_intr.adb
(Expand_Dispatching_Constructor_Call): Report an error on
unsupported dispatching constructor calls and report a warning on
calls that may fail at run time.
gcc/testsuite/
* gnat.dg/abstract1.ads: Cleanup whitespaces.
* gnat.dg/abstract1.adb: Likewise and add -gnatws to silence new
warning.
Piotr Trojanek [Thu, 1 Sep 2022 08:19:09 +0000 (10:19 +0200)]
ada: Avoid repeated iteration over private protected components
The First_Entity/Next_Entity chain includes private entities, so there
it no need to iterate starting both from First_Entity and
First_Private_Entity.
Code cleanup related to improved detection of references to
uninitialized objects; behavior is unaffected.
gcc/ada/
* sem_util.adb
(Check_Components): Iterate using
First/Next_Component_Or_Discriminant.
(Has_Preelaborable_Initialization): Avoid repeated iteration with
calls to Check_Components with First_Entity and
First_Private_Entity.
(Is_Independent_Object_Entity): Tune indentation.
Piotr Trojanek [Tue, 23 Aug 2022 15:16:44 +0000 (17:16 +0200)]
ada: Cleanup clearing flags on package variables
When killing flags on assignable entities we iterated from First_Entity
and then again from First_Private_Entity. This second iteration was
unnecessary, because the entity chain that starts with First_Entity
contains all entities, including the private ones.
This is just a performance improvement; the behavior is unchanged.
gcc/ada/
* sem_ch7.adb (Clear_Constants): Only iterate from First_Entity
through Next_Entity; only examine variables because packages have
no assignable formal parameters.
Piotr Trojanek [Sun, 9 Oct 2022 20:01:51 +0000 (22:01 +0200)]
ada: Fix various typos in GNAT User's Guide
Fix uncontroversial typos.
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Fix
typos.
* doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Fix typos
and refill as necessary; remove trailing whitespace.
* doc/gnat_ugn/gnat_and_program_execution.rst: Fix typos.
* gnat_ugn.texi: Regenerate.
Marc Poulhiès [Thu, 22 Sep 2022 08:59:42 +0000 (10:59 +0200)]
ada: Fix loop unnesting issue.
During loop unnesting, when the loop statements are wrapped in a code
block, the newly created block's scope must be set to the loop
scope (instead of the previous 'Current_Scope' that would point to an
upper scope).
gcc/ada/
* sem_util.ads (Add_Block_Identifier): Add new extra Scope
argument.
* sem_util.adb (Add_Block_Identifier): Likewise and use this scope
variable instead of Current_Scope.
* exp_util.adb (Wrap_Statements_In_Block): Add new scope argument
to Add_Block_Identifier call.
Piotr Trojanek [Fri, 7 Oct 2022 10:55:14 +0000 (12:55 +0200)]
ada: Fix repeated killing of private entity values
When killing known values of assignable entities we iterated from
First_Entity and then again from First_Private_Entity. This second
iteration was unnecessary, because the entity chain that starts with
First_Entity contains all entities, including the private ones.
This is just a performance improvement; the behavior is unchanged.
gcc/ada/
* sem_util.adb (Kill_Current_Values): Only iterate from
First_Entity through Next_Entity.
Piotr Trojanek [Fri, 7 Oct 2022 19:58:58 +0000 (21:58 +0200)]
ada: Simplify detection of controlling formals
When detecting controlling formals we are only interested in formal
parameters and not in other entities.
gcc/ada/
* sem_ch6.adb (Controlling_Formal): Iterate with First/Next_Formal
and not with First/Next_Entity.
Javier Miranda [Fri, 7 Oct 2022 16:02:02 +0000 (16:02 +0000)]
ada: Skip dynamic interface conversion under configurable runtime
gcc/ada/
* exp_disp.adb
(Expand_Interface_Conversion): Fix typo in comment.
Javier Miranda [Thu, 6 Oct 2022 21:44:43 +0000 (21:44 +0000)]
ada: Skip dynamic interface conversion under configurable runtime
gcc/ada/
* exp_disp.adb
(Expand_Interface_Conversion): Under configurable runtime, when
the target type is an interface that is an ancestor of the operand
type, skip generating code to displace the pointer to reference
the target dispatch table.
* sem_disp.adb
(Propagate_Tag): Handle class-wide types when checking for the
addition of an implicit interface conversion.
Ronan Desplanques [Thu, 6 Oct 2022 12:34:17 +0000 (14:34 +0200)]
ada: Fix typo
Fix typo in documentation.
gcc/ada/
* doc/gnat_rm/standard_library_routines.rst: Fix typo.
* gnat_rm.texi: Regenerate.
Ghjuvan Lacambre [Fri, 30 Sep 2022 13:44:49 +0000 (15:44 +0200)]
ada: Remove sa_messages
Spark and CodePeer do not depend on this unit anymore.
gcc/ada/
* sa_messages.ads, sa_messages.adb: Remove files.
Ghjuvan Lacambre [Sat, 17 Sep 2022 17:35:48 +0000 (19:35 +0200)]
ada: Refactor: replace uses of `not Present(X)` with `No (X)`
`No (X)` is essentially `not Present (X)`, there's no reason for not
using this shorter form.
gcc/ada/
* checks.adb, exp_atag.adb, exp_attr.adb, exp_ch4.adb, exp_ch6.adb,
exp_ch7.adb, exp_dbug.adb, exp_disp.adb, exp_unst.adb, exp_util.adb,
freeze.adb, layout.adb, pprint.adb, rtsfind.adb, sem_aggr.adb,
sem_attr.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb,
sem_ch5.adb, sem_ch6.adb, sem_ch8.adb, sem_dim.adb, sem_prag.adb,
sem_util.adb, sem_warn.adb:
Replace uses of `not Present (X)` with `No (X)`.
Piotr Trojanek [Fri, 7 Oct 2022 10:42:34 +0000 (12:42 +0200)]
ada: Fix various typos in node and entity description comments
Fix typos in units that describe GNAT abstract syntax tree.
gcc/ada/
* einfo.ads: Fix typos in comments; refill as necessary.
* sinfo.ads: Likewise.
Piotr Trojanek [Fri, 7 Oct 2022 10:20:55 +0000 (12:20 +0200)]
ada: Fix various typos in GNAT RM
List of unknown words in files can be produced with:
$ cat *.rst | ispell -l |
tr '[:upper:]' '[:lower:]' | sort | uniq | less
and can be easily filtered with eyes.
gcc/ada/
* doc/gnat_rm/implementation_defined_aspects.rst: Fix typos.
* doc/gnat_rm/implementation_defined_attributes.rst: Likewise
* doc/gnat_rm/implementation_defined_characteristics.rst: Likewise
* doc/gnat_rm/implementation_defined_pragmas.rst: Likewise
* doc/gnat_rm/standard_library_routines.rst: Likewise.
* gnat_rm.texi: Regenerate.
Piotr Trojanek [Thu, 6 Oct 2022 21:42:46 +0000 (23:42 +0200)]
ada: Improve efficiency of scope stack restoration
We save/restore visibility by setting the Is_Immediately_Visible flag
and appending entities to / removing them from the tail of an element
list.
However, the Is_Immediately_Visible flag can be restored in any order,
while the element list is singly-linked and removal from the tail is
inefficient. This change removes a performance hot spot, which accounted
for up to 10% of compilation time of complex applications (e.g. QGen),
at least as measured on GNAT built with profiling support.
gcc/ada/
* sem_ch8.adb (Restore_Scope_Stack): Remove elements from the head
and not the tail of an element list.
Ronan Desplanques [Mon, 3 Oct 2022 08:34:57 +0000 (10:34 +0200)]
ada: Small editorial changes to documentation comments
gcc/ada/
* sinfo.ads: Small editorial changes.
Steve Baird [Fri, 30 Sep 2022 22:27:00 +0000 (15:27 -0700)]
ada: Allow enabling a restricted set of language extensions.
The -gnatX switch (and the related Extensions_Allowed pragma) is currently a
two-valued all-or-nothing option. Add support for enabling a curated subset
of language extensions without enabling others via the -gnatX switch
and for enabling all language extensions via the new -gnatX0 switch.
Similarly, the existing "ON" argument for the Extensions_Allowed pragma
now only enables the curated subset; the new argument "ALL" enables all
language extensions. The subset of language extensions currently includes
prefixed-view notation with an untagged prefix, fixed-low-bound array
subtypes, and casing on composite values.
gcc/ada/
* opt.ads: Replace Ada_Version_Type enumeration literal
Ada_With_Extensions with two literals, Ada_With_Core_Extensions
and Ada_With_All_Extensions. Update uses of the deleted literal.
Replace Extensions_Allowed function with two functions:
All_Extensions_Allowed and Core_Extensions_Allowed.
* errout.ads, errout.adb: Add Boolean parameter to
Error_Msg_GNAT_Extension to indicate whether the construct in
question belongs to the curated subset.
* exp_ch5.adb, par-ch4.adb, sem_case.adb, sem_ch3.adb:
* sem_ch4.adb, sem_ch5.adb, sem_ch8.adb: Replace calls to
Extensions_Allowed with calls to Core_Extensions_Allowed for
constructs that are in the curated subset.
* sem_attr.adb, sem_ch13.adb, sem_eval.adb, sem_util.adb: Replace
calls to Extensions_Allowed with calls to All_Extensions_Allowed
for constructs that are not in the curated subset.
* par-ch3.adb: Override default for new parameter in calls to
Error_Msg_GNAT_Extension for constructs in the curated subset.
* par-prag.adb: Add Boolean parameter to Check_Arg_Is_On_Or_Off to
also allow ALL. Set Opt.Ada_Version appropriately for ALL or ON
arguments.
* sem_prag.adb: Allowed ALL argument for an Extensions_Allowed
pragma. Set Opt.Ada_Version appropriately for ALL or ON arguments.
* switch-c.adb: The -gnatX switch now enables only the curated
subset of language extensions (formerly it enabled all of them);
the new -gnatX0 switch enables all of them.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Document new "-gnatX0" switch and update documentation for
"-gnatX" switch.
* doc/gnat_rm/implementation_defined_pragmas.rst: Document new ALL
argument for pragma Extensions_Allowed and update documentation
for the ON argument. Delete mention of Ada 2022 Reduce attribute
as an extension.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.
Steve Baird [Wed, 5 Oct 2022 22:16:26 +0000 (15:16 -0700)]
ada: Generate missing object decls for adainit/adafinal registration calls
A previous change on this ticket introduced calls to CUDA_Register_Function
for adainit and adafinal, but failed to introduce declarations for the
C string variables that are initialized and then passed as actual parameters
in this call. Provide the missing declarations (and, incidentally, change
the names of the two variables).
gcc/ada/
* bindgen.adb: Introduce two new string constants for the names of
the C-String variables that are assigned the names for adainit and
adafinal. Replace string literals in Gen_CUDA_Init with references
to these constants. In Gen_CUDA_Defs, generate C-String variable
declarations where these constants are the names of the variables.
Piotr Trojanek [Mon, 3 Oct 2022 20:03:20 +0000 (22:03 +0200)]
ada: Support lock-free protected objects with pragma Initialize_Scalars
In general, protected subprograms are only eligible for a lock-free
expansion if they do not reference global assignable objects.
However, it seems reasonable to ignore references to variables in
System.Scalar_Values, which are generated when pragma Initialize_Scalars
is active. Such references appear, for example, when protected
subprogram has formal parameters of mode out.
gcc/ada/
* sem_ch9.adb (Satisfies_Lock_Free_Requirements): Ignore
references to global variables inserted due to pragma
Initialize_Scalars.
Cedric Landet [Mon, 3 Oct 2022 14:04:34 +0000 (16:04 +0200)]
ada: Remove VxWorks 6 and VxWorks 653 2.x content from the UGX
Because they are not supported anymore.
gcc/ada/
* doc/gnat_rm/implementation_defined_pragmas.rst: Remove VxWorks
version 6.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.
Piotr Trojanek [Mon, 3 Oct 2022 21:16:19 +0000 (23:16 +0200)]
ada: Reject expanded global names in lock-free protected objects
Lock-free expansion of protected subprograms is only possible when there
are no references to global assignable objects. We only detected such
references when they appeared as direct names, but we must similarly
detect expanded names.
gcc/ada/
* sem_ch9.adb (Satisfies_Lock_Free_Requirements): Detect
references via expanded names.
Steve Baird [Tue, 4 Oct 2022 21:42:56 +0000 (14:42 -0700)]
ada: Generate host-side CUDA_Register_Function calls for device's adainit/adafinal
To invoke a device-side subprogram from the host (via a CUDA_execute pragma),
the subprogram also has to be registered by calling CUDA_Register_Function.
The host-side adainit and adafinal procedures need to invoke the corresponding
device-side procedures, so corresponding CUDA_Register_Function calls need
to be generated.
gcc/ada/
* bindgen.adb
(Gen_CUDA_Init): Move existing loop body into a new local
procedure, Gen_CUDA_Register_Function_Call, and replace that loop
body with a call to this procedure. This first part is just
semantics-preserving refactoring. The second part is to add
Gen_CUDA_Register_Function_Call calls after the loop for the
device-side adainit and adafinal procedures.
Kyrylo Tkachov [Fri, 4 Nov 2022 10:08:03 +0000 (10:08 +0000)]
aarch64: Fix typo in aarch64-sve.md comment
gcc/ChangeLog:
* config/aarch64/aarch64-sve2.md: Fix typo in Cryptographic
extensions comment.
Thomas Schwinge [Mon, 17 Oct 2022 20:19:55 +0000 (22:19 +0200)]
Remove support for Intel MIC offloading
... after its deprecation in GCC 12.
* Makefile.def: Remove module 'liboffloadmic'.
* Makefile.in: Regenerate.
* configure.ac: Remove 'liboffloadmic' handling.
* configure: Regenerate.
contrib/
* gcc-changelog/git_commit.py (default_changelog_locations):
Remove 'liboffloadmic'.
* gcc_update (files_and_dependencies): Remove 'liboffloadmic'
files.
* update-copyright.py (GCCCmdLine): Remove 'liboffloadmic'
comment.
gcc/
* config.gcc [target *-intelmic-* | *-intelmicemul-*]: Remove.
* config/i386/i386-options.cc (ix86_omp_device_kind_arch_isa)
[ACCEL_COMPILER]: Remove.
* config/i386/intelmic-mkoffload.cc: Remove.
* config/i386/intelmic-offload.h: Likewise.
* config/i386/t-intelmic: Likewise.
* config/i386/t-omp-device: Likewise.
* configure.ac [target *-intelmic-* | *-intelmicemul-*]: Remove.
* configure: Regenerate.
* doc/install.texi (--enable-offload-targets=[...]): Update.
* doc/sourcebuild.texi: Remove 'liboffloadmic' documentation.
include/
* gomp-constants.h (GOMP_DEVICE_INTEL_MIC): Comment out.
(GOMP_VERSION_INTEL_MIC): Remove.
libgomp/
* libgomp-plugin.h (OFFLOAD_TARGET_TYPE_INTEL_MIC): Remove.
* libgomp.texi (OpenMP Context Selectors): Remove Intel MIC
documentation.
* plugin/configfrag.ac <enable_offload_targets>
[*-intelmic-* | *-intelmicemul-*]: Remove.
* configure: Regenerate.
* testsuite/lib/libgomp.exp (libgomp_init): Remove 'liboffloadmic'
handling.
(offload_target_to_openacc_device_type)
[$offload_target = *-intelmic*]: Remove.
(check_effective_target_offload_device_intel_mic)
(check_effective_target_offload_device_any_intel_mic): Remove.
* testsuite/libgomp.c-c++-common/on_device_arch.h
(device_arch_intel_mic, on_device_arch_intel_mic, any_device_arch)
(any_device_arch_intel_mic): Remove.
* testsuite/libgomp.c-c++-common/target-45.c: Remove
'offload_device_any_intel_mic' XFAIL.
* testsuite/libgomp.fortran/target10.f90: Likewise.
liboffloadmic/
* ChangeLog: Remove.
* Makefile.am: Likewise.
* Makefile.in: Likewise.
* aclocal.m4: Likewise.
* configure: Likewise.
* configure.ac: Likewise.
* configure.tgt: Likewise.
* doc/doxygen/config: Likewise.
* doc/doxygen/header.tex: Likewise.
* include/coi/common/COIEngine_common.h: Likewise.
* include/coi/common/COIEvent_common.h: Likewise.
* include/coi/common/COIMacros_common.h: Likewise.
* include/coi/common/COIPerf_common.h: Likewise.
* include/coi/common/COIResult_common.h: Likewise.
* include/coi/common/COISysInfo_common.h: Likewise.
* include/coi/common/COITypes_common.h: Likewise.
* include/coi/sink/COIBuffer_sink.h: Likewise.
* include/coi/sink/COIPipeline_sink.h: Likewise.
* include/coi/sink/COIProcess_sink.h: Likewise.
* include/coi/source/COIBuffer_source.h: Likewise.
* include/coi/source/COIEngine_source.h: Likewise.
* include/coi/source/COIEvent_source.h: Likewise.
* include/coi/source/COIPipeline_source.h: Likewise.
* include/coi/source/COIProcess_source.h: Likewise.
* liboffloadmic_host.spec.in: Likewise.
* liboffloadmic_target.spec.in: Likewise.
* plugin/Makefile.am: Likewise.
* plugin/Makefile.in: Likewise.
* plugin/aclocal.m4: Likewise.
* plugin/configure: Likewise.
* plugin/configure.ac: Likewise.
* plugin/libgomp-plugin-intelmic.cpp: Likewise.
* plugin/offload_target_main.cpp: Likewise.
* runtime/cean_util.cpp: Likewise.
* runtime/cean_util.h: Likewise.
* runtime/coi/coi_client.cpp: Likewise.
* runtime/coi/coi_client.h: Likewise.
* runtime/coi/coi_server.cpp: Likewise.
* runtime/coi/coi_server.h: Likewise.
* runtime/compiler_if_host.cpp: Likewise.
* runtime/compiler_if_host.h: Likewise.
* runtime/compiler_if_target.cpp: Likewise.
* runtime/compiler_if_target.h: Likewise.
* runtime/dv_util.cpp: Likewise.
* runtime/dv_util.h: Likewise.
* runtime/emulator/coi_common.h: Likewise.
* runtime/emulator/coi_device.cpp: Likewise.
* runtime/emulator/coi_device.h: Likewise.
* runtime/emulator/coi_host.cpp: Likewise.
* runtime/emulator/coi_host.h: Likewise.
* runtime/emulator/coi_version_asm.h: Likewise.
* runtime/emulator/coi_version_linker_script.map: Likewise.
* runtime/liboffload_error.c: Likewise.
* runtime/liboffload_error_codes.h: Likewise.
* runtime/liboffload_msg.c: Likewise.
* runtime/liboffload_msg.h: Likewise.
* runtime/mic_lib.f90: Likewise.
* runtime/offload.h: Likewise.
* runtime/offload_common.cpp: Likewise.
* runtime/offload_common.h: Likewise.
* runtime/offload_engine.cpp: Likewise.
* runtime/offload_engine.h: Likewise.
* runtime/offload_env.cpp: Likewise.
* runtime/offload_env.h: Likewise.
* runtime/offload_host.cpp: Likewise.
* runtime/offload_host.h: Likewise.
* runtime/offload_iterator.h: Likewise.
* runtime/offload_omp_host.cpp: Likewise.
* runtime/offload_omp_target.cpp: Likewise.
* runtime/offload_orsl.cpp: Likewise.
* runtime/offload_orsl.h: Likewise.
* runtime/offload_table.cpp: Likewise.
* runtime/offload_table.h: Likewise.
* runtime/offload_target.cpp: Likewise.
* runtime/offload_target.h: Likewise.
* runtime/offload_target_main.cpp: Likewise.
* runtime/offload_timer.h: Likewise.
* runtime/offload_timer_host.cpp: Likewise.
* runtime/offload_timer_target.cpp: Likewise.
* runtime/offload_trace.cpp: Likewise.
* runtime/offload_trace.h: Likewise.
* runtime/offload_util.cpp: Likewise.
* runtime/offload_util.h: Likewise.
* runtime/ofldbegin.cpp: Likewise.
* runtime/ofldend.cpp: Likewise.
* runtime/orsl-lite/include/orsl-lite.h: Likewise.
* runtime/orsl-lite/lib/orsl-lite.c: Likewise.
* runtime/orsl-lite/version.txt: Likewise.
Florian Weimer [Fri, 4 Nov 2022 09:18:03 +0000 (10:18 +0100)]
libgcc: Special-case BFD ld unwind table encodings in find_fde_tail
BFD ld (and the other linkers) only produce one encoding of these
values. It is not necessary to use the general
read_encoded_value_with_base decoding routine. This avoids the
data-dependent branches in its implementation.
libgcc/
* unwind-dw2-fde-dip.c (find_fde_tail): Special-case encoding
values actually used by BFD ld.
Thomas Schwinge [Thu, 3 Nov 2022 16:29:13 +0000 (17:29 +0100)]
Better integrate default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'
... after commit
4ee35c11fd328728c12f3e086ae016ca94624bf8
"Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'".
No functional change.
gcc/
* Makefile.in (OBJS): Remove 'dbxout.o'.
* config/nvptx/nvptx.cc: Don't '#include "dbxout.h"'.
* dbxout.cc: Remove.
* dbxout.h: Likewise.
* target-def.h (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR):
Default to 'default_asm_out_constructor',
'default_asm_out_destructor'.
* targhooks.cc (default_asm_out_constructor)
(default_asm_out_destructor): New.
* targhooks.h (default_asm_out_constructor)
(default_asm_out_destructor): Declare.
Thomas Schwinge [Sun, 9 Oct 2022 20:39:02 +0000 (22:39 +0200)]
Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'
... that got lost in commit
7e0db0cdf01e9c885a29cb37415f5bc00d90c029
"STABS: remove -gstabs and -gxcoff functionality".
Previously, if a back end was not 'USE_COLLECT2', nor manually defined
'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR', or got pointed to the
respective 'default_[...]' functions due to 'CTORS_SECTION_ASM_OP',
'DTORS_SECTION_ASM_OP', or 'TARGET_ASM_NAMED_SECTION', it got pointed to
'default_stabs_asm_out_constructor', 'default_stabs_asm_out_destructor'.
These would emit 'sorry' for any global constructor/destructor they're
run into.
This is now gone, and thus in such a back end configuration case
'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR' don't get defined
anymore, and thus the subsequently following:
#if !defined(TARGET_HAVE_CTORS_DTORS)
# if defined(TARGET_ASM_CONSTRUCTOR) && defined(TARGET_ASM_DESTRUCTOR)
# define TARGET_HAVE_CTORS_DTORS true
# endif
#endif
... doesn't define 'TARGET_HAVE_CTORS_DTORS' anymore, and thus per my
understanding, 'gcc/final.cc:rest_of_handle_final':
if (DECL_STATIC_CONSTRUCTOR (current_function_decl)
&& targetm.have_ctors_dtors)
targetm.asm_out.constructor (XEXP (DECL_RTL (current_function_decl), 0),
decl_init_priority_lookup
(current_function_decl));
if (DECL_STATIC_DESTRUCTOR (current_function_decl)
&& targetm.have_ctors_dtors)
targetm.asm_out.destructor (XEXP (DECL_RTL (current_function_decl), 0),
decl_fini_priority_lookup
(current_function_decl));
... simply does nothing anymore for a 'DECL_STATIC_CONSTRUCTOR',
'DECL_STATIC_DESTRUCTOR'.
This, effectively, means that GCC/nvptx now suddenly appears to "support"
global constructors/destructors, which means that a ton of test cases now
erroneously PASS that previously used to FAIL:
sorry, unimplemented: global constructors not supported on this target
Of course, such support didn't magically happen due to
"STABS: remove -gstabs and -gxcoff functionality", so this is bad. And,
corresponding execution testing then regularly FAILs (due to the global
constructor/destructor functions never being invoked), for example:
[-UNSUPPORTED:-]{+PASS:+} gcc.dg/initpri1.c {+(test for excess errors)+}
{+FAIL: gcc.dg/initpri1.c execution test+}
[-UNSUPPORTED:-]{+PASS:+} g++.dg/special/conpr-1.C {+(test for excess errors)+}
{+FAIL: g++.dg/special/conpr-1.C execution test+}
To restore the previous GCC/nvptx behavior, for traceability, this simply
restores the previous code, stripped down to the bare minimum.
gcc/
* Makefile.in (OBJS): Add 'dbxout.o'.
* config/nvptx/nvptx.cc: '#include "dbxout.h"'.
* dbxout.cc: New.
* dbxout.h: Likewise.
* target-def.h (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR):
Default to 'default_stabs_asm_out_constructor',
'default_stabs_asm_out_destructor'.
Hongyu Wang [Fri, 4 Nov 2022 07:50:55 +0000 (15:50 +0800)]
Support Intel AMX-FP16 ISA
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_available_features): Detect
amx-fp16.
* common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_FP16_SET,
OPTION_MASK_ISA2_AMX_FP16_UNSET): New macros.
(ix86_handle_option): Handle -mamx-fp16.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
Add FEATURE_AMX_FP16.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
amx-fp16.
* config.gcc: Add amxfp16intrin.h.
* config/i386/cpuid.h (bit_AMX_FP16): New.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__AMX_FP16__.
* config/i386/i386-isa.def: Add DEF_PTA for AMX_FP16.
* config/i386/i386-options.cc (isa2_opts): Add -mamx-fp16.
(ix86_valid_target_attribute_inner_p): Add new ATTR.
(ix86_option_override_internal): Handle AMX-FP16.
* config/i386/i386.opt: Add -mamx-fp16.
* config/i386/immintrin.h: Include amxfp16intrin.h.
* doc/extend.texi: Document -mamx-fp16.
* doc/invoke.texi: Document amx-fp16.
* doc/sourcebuild.texi: Document amx_fp16.
* config/i386/amxfp16intrin.h: New file.
gcc/testsuite/ChangeLog:
* g++.dg/other/i386-2.C: Add -mamx-fp16.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/sse-12.c: Ditto.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.
* gcc.target/i386/sse-23.c: Ditto.
* lib/target-supports.exp: (check_effective_target_amx_fp16):
New proc.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/amx-check.h: Add AMX_FP16.
* gcc.target/i386/amx-helper.h: New file to support amx-fp16.
* gcc.target/i386/amxfp16-asmatt-1.c: New test.
* gcc.target/i386/amxfp16-asmintel-1.c: Ditto.
* gcc.target/i386/amxfp16-dpfp16ps-2.c: Ditto.
Co-authored-by: Haochen Jiang <haochen.jiang@intel.com>
Torbjörn SVENSSON [Wed, 19 Oct 2022 09:31:33 +0000 (11:31 +0200)]
arm: Allow to override location of .gnu.sgstubs section
Depending on the DejaGNU board definition, the .gnu.sgstubs section
might be placed on different locations in order to suit the target.
With this patch, the start location of the section is overrideable
from the board definition with the fallback of the previously
hardcoded location.
gcc/testsuite/ChangeLog:
* gcc.target/arm/cmse/bitfield-1.c: Use overridable location.
* gcc.target/arm/cmse/bitfield-2.c: Likewise.
* gcc.target/arm/cmse/bitfield-3.c: Likewise.
* gcc.target/arm/cmse/cmse-20.c: Likewise.
* gcc.target/arm/cmse/struct-1.c: Likewise.
* gcc.target/arm/cmse/cmse.exp (cmse_sgstubs): New.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Torbjörn SVENSSON [Tue, 25 Oct 2022 14:11:05 +0000 (16:11 +0200)]
c++: Use in-process client when networking is disabled
Without the patch, the output for bad-mapper-3.C would be:
/src/gcc/gcc/testsuite/g++.dg/modules/bad-mapper-3.C:2:1: error: unknown Compiled Module Interface: no such module
As this line is unexpected, the test case would fail.
The same problem can also be seen for g++.dg/modules/bad-mapper-2.C.
gcc/cp/ChangeLog:
* mapper-client.cc: Use in-process client when networking is
disabled.
gcc/testsuite/ChangeLog:
* g++.dg/modules/bad-mapper-3.C: Update dg-error pattern.
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Haochen Jiang [Fri, 4 Nov 2022 01:21:03 +0000 (09:21 +0800)]
Initial Sierra Forest Support
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_intel_cpu):
Add Sierra Forest.
* common/config/i386/i386-common.cc
(processor_names): Add Sierra Forest.
(processor_alias_table): Ditto.
* common/config/i386/i386-cpuinfo.h
(enum processor_types): Add INTEL_SIERRAFOREST.
* config.gcc: Add -march=sierraforest.
* config/i386/driver-i386.cc (host_detect_local_cpu):
Handle Sierra Forest.
* config/i386/i386-c.cc (ix86_target_macros_internal):
Ditto.
* config/i386/i386-options.cc (m_SIERRAFOREST): New define.
(processor_cost_table): Add sierra forest.
* config/i386/i386.h (enum processor_type):
Add PROCESSOR_SIERRA_FOREST.
(PTA_SIERRAFOREST): Ditto.
* doc/extend.texi: Add sierra forest.
* doc/invoke.texi: Ditto.
gcc/testsuite/ChangeLog:
* g++.target/i386/mv16.C: Add sierra forest.
* gcc.target/i386/funcspec-56.inc: Handle new march.
Haochen Jiang [Fri, 4 Nov 2022 01:20:54 +0000 (09:20 +0800)]
Support Intel CMPccXADD
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_available_features):
Detect cmpccxadd.
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_CMPCCXADD_SET,
OPTION_MASK_ISA2_CMPCCXADD_UNSET): New.
(ix86_handle_option): Handle -mcmpccxadd.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
Add FEATURE_CMPCCXADD.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
cmpccxadd.
* config.gcc: Add cmpccxaddintrin.h.
* config/i386/cpuid.h (bit_CMPCCXADD): New.
* config/i386/i386-builtin-types.def:
Add DEF_FUNCTION_TYPE(INT, PINT, INT, INT, INT)
and DEF_FUNCTION_TYPE(LONGLONG, PLONGLONG, LONGLONG, LONGLONG, INT).
* config/i386/i386-builtin.def (BDESC): Add new builtins.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__CMPCCXADD__.
* config/i386/i386-expand.cc (ix86_expand_special_args_builtin):
Add new parameter to indicate constant position.
Handle INT_FTYPE_PINT_INT_INT_INT
and LONGLONG_FTYPE_PLONGLONG_LONGLONG_LONGLONG_INT.
* config/i386/i386-isa.def (CMPCCXADD): Add DEF_PTA(CMPCCXADD).
* config/i386/i386-options.cc (isa2_opts): Add -mcmpccxadd.
(ix86_valid_target_attribute_inner_p): Handle cmpccxadd.
* config/i386/i386.opt: Add option -mcmpccxadd.
* config/i386/sync.md (cmpccxadd_<mode>): New define insn.
* config/i386/x86gprintrin.h: Include cmpccxaddintrin.h.
* doc/extend.texi: Document cmpccxadd.
* doc/invoke.texi: Document -mcmpccxadd.
* doc/sourcebuild.texi: Document target cmpccxadd.
* config/i386/cmpccxaddintrin.h: New file.
gcc/testsuite/ChangeLog:
* g++.dg/other/i386-2.C: Add -mcmpccxadd.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/avx-1.c: Ditto.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/sse-13.c: Add -mcmpccxadd.
* gcc.target/i386/sse-23.c: Ditto.
* gcc.target/i386/x86gprintrin-1.c: Ditto.
* gcc.target/i386/x86gprintrin-2.c: Ditto.
* gcc.target/i386/x86gprintrin-3.c: Ditto.
* gcc.target/i386/x86gprintrin-4.c: Ditto.
* gcc.target/i386/x86gprintrin-5.c: Ditto.
* lib/target-supports.exp (check_effective_target_cmpccxadd):
New.
* gcc.target/i386/cmpccxadd-1.c: New test.
* gcc.target/i386/cmpccxadd-2.c: Ditto.
GCC Administrator [Fri, 4 Nov 2022 00:17:58 +0000 (00:17 +0000)]
Daily bump.
Marek Polacek [Tue, 1 Nov 2022 21:05:52 +0000 (17:05 -0400)]
c++: Quash -Wdangling-reference for member operator* [PR107488]
-Wdangling-reference complains here:
std::vector<int> v = ...;
std::vector<int>::const_iterator it = v.begin();
while (it != v.end()) {
const int &r = *it++; // warning
}
because it sees a call to
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator*
which returns a reference and its argument is a TARGET_EXPR representing
the result of
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator++
But 'r' above refers to one of the int elements of the vector 'v', not
to a temporary object. Therefore the warning is a false positive.
I suppose code like the above is relatively common (the warning broke
cppunit-1.15.1 and a few other projects), so presumably it makes sense
to suppress the warning when it comes to member operator*. In this case
it's defined as
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_current; }
and I'm guessing a lot of member operator* are like that, at least when
it comes to iterators. I've looked at _Fwd_list_iterator,
_Fwd_list_const_iterator, __shared_ptr_access, _Deque_iterator,
istream_iterator, etc, and they're all like that, so adding #pragmas
would be quite tedious. :/
PR c++/107488
gcc/cp/ChangeLog:
* call.cc (do_warn_dangling_reference): Quash -Wdangling-reference
for member operator*.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wdangling-reference5.C: New test.
Patrick Palka [Thu, 3 Nov 2022 19:35:18 +0000 (15:35 -0400)]
c++: requires-expr and access checking [PR107179]
Like during satisfaction, we also need to avoid deferring access checks
during substitution of a requires-expr because the outcome of an access
check can determine the value of the requires-expr. Otherwise (in
deferred access checking contexts such as within a base-clause), the
requires-expr may evaluate to the wrong result, and along the way a
failed access check may leak out from it into a non-SFINAE context and
cause a hard error (as in the below testcase).
PR c++/107179
gcc/cp/ChangeLog:
* constraint.cc (tsubst_requires_expr): Make sure we're not
deferring access checks.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-requires31.C: New test.
Andrew MacLeod [Thu, 3 Nov 2022 17:07:33 +0000 (13:07 -0400)]
Add testcases resolved with ranger as VRP1.
gcc/testsuite/
* g++.dg/pr99966.C: New.
* gcc.dg/pr93917.c: New.
* gcc.dg/pr102650.c: New.
Jason Merrill [Thu, 3 Nov 2022 14:51:40 +0000 (10:51 -0400)]
c++: change -fconcepts to mean C++20 concepts
It was always weird that -fconcepts in C++17 mode meant the same thing as
-fconcepts-ts in C++20 mode; this patch harmonizes the flags so that for TS
concepts you always need to write -fconcepts-ts.
In the unlikely event anyone is still using -fconcepts in C++17 mode, they
can either fix their code to work with C++20 concepts or adjust the compiler
flag.
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): -fconcepts no longer implies
-fconcepts-ts before C++20.
gcc/ChangeLog:
* doc/invoke.texi: -fconcepts no longer implies
-fconcepts-ts before C++20.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_template_declaration_after_parameters): Fix
concept parsing below C++20.
gcc/testsuite/ChangeLog:
* g++.dg/concepts/auto1.C:
* g++.dg/concepts/auto3.C:
* g++.dg/concepts/auto4.C:
* g++.dg/concepts/class-deduction1.C:
* g++.dg/concepts/class5.C:
* g++.dg/concepts/class6.C:
* g++.dg/concepts/debug1.C:
* g++.dg/concepts/decl-diagnose.C:
* g++.dg/concepts/deduction-constraint1.C:
* g++.dg/concepts/diagnostic1.C:
* g++.dg/concepts/dr1430.C:
* g++.dg/concepts/equiv.C:
* g++.dg/concepts/equiv2.C:
* g++.dg/concepts/expression.C:
* g++.dg/concepts/expression2.C:
* g++.dg/concepts/expression3.C:
* g++.dg/concepts/fn-concept1.C:
* g++.dg/concepts/fn-concept2.C:
* g++.dg/concepts/fn-concept3.C:
* g++.dg/concepts/fn1.C:
* g++.dg/concepts/fn10.C:
* g++.dg/concepts/fn2.C:
* g++.dg/concepts/fn3.C:
* g++.dg/concepts/fn4.C:
* g++.dg/concepts/fn5.C:
* g++.dg/concepts/fn6.C:
* g++.dg/concepts/fn8.C:
* g++.dg/concepts/fn9.C:
* g++.dg/concepts/generic-fn-err.C:
* g++.dg/concepts/generic-fn.C:
* g++.dg/concepts/inherit-ctor1.C:
* g++.dg/concepts/inherit-ctor3.C:
* g++.dg/concepts/intro1.C:
* g++.dg/concepts/intro2.C:
* g++.dg/concepts/intro3.C:
* g++.dg/concepts/intro4.C:
* g++.dg/concepts/intro5.C:
* g++.dg/concepts/intro6.C:
* g++.dg/concepts/intro7.C:
* g++.dg/concepts/locations1.C:
* g++.dg/concepts/partial-concept-id1.C:
* g++.dg/concepts/partial-concept-id2.C:
* g++.dg/concepts/partial-spec5.C:
* g++.dg/concepts/placeholder2.C:
* g++.dg/concepts/placeholder3.C:
* g++.dg/concepts/placeholder4.C:
* g++.dg/concepts/placeholder5.C:
* g++.dg/concepts/placeholder6.C:
* g++.dg/concepts/pr65634.C:
* g++.dg/concepts/pr65636.C:
* g++.dg/concepts/pr65681.C:
* g++.dg/concepts/pr65848.C:
* g++.dg/concepts/pr67249.C:
* g++.dg/concepts/pr67595.C:
* g++.dg/concepts/pr68434.C:
* g++.dg/concepts/pr71127.C:
* g++.dg/concepts/pr71128.C:
* g++.dg/concepts/pr71131.C:
* g++.dg/concepts/pr71385.C:
* g++.dg/concepts/pr85065.C:
* g++.dg/concepts/template-parm11.C:
* g++.dg/concepts/template-parm12.C:
* g++.dg/concepts/template-parm2.C:
* g++.dg/concepts/template-parm3.C:
* g++.dg/concepts/template-parm4.C:
* g++.dg/concepts/template-template-parm1.C:
* g++.dg/concepts/var-concept1.C:
* g++.dg/concepts/var-concept2.C:
* g++.dg/concepts/var-concept3.C:
* g++.dg/concepts/var-concept4.C:
* g++.dg/concepts/var-concept5.C:
* g++.dg/concepts/var-concept6.C:
* g++.dg/concepts/var-concept7.C:
* g++.dg/concepts/var-templ2.C:
* g++.dg/concepts/var-templ3.C:
* g++.dg/concepts/variadic1.C:
* g++.dg/concepts/variadic2.C:
* g++.dg/concepts/variadic3.C:
* g++.dg/concepts/variadic4.C:
* g++.dg/cpp2a/concepts-pr65575.C:
* g++.dg/cpp2a/concepts-pr66091.C:
* g++.dg/cpp2a/concepts-pr84980.C:
* g++.dg/cpp2a/concepts-pr85265.C: Pass -fconcepts-ts.
* g++.dg/cpp2a/concepts-pr84979-2.C:
* g++.dg/cpp2a/concepts-pr84979-3.C: Same diagnostics
in C++20 and below.
Patrick Palka [Thu, 3 Nov 2022 18:55:35 +0000 (14:55 -0400)]
c++: constexpr error with defaulted virtual dtor [PR93413]
We're rejecting the below testcase with
error: 'virtual constexpr Base::~Base()' used before its definition
error: 'virtual constexpr Derived::~Derived()' used before its definition
due to special handling in mark_used added by r181272 to defer synthesis
of virtual destructors until EOF (where we can set their linkage), which
in turn makes them effectively unusable during constexpr evaluation.
Fortunately it seems this special handling is unnecessary ever since
r208030 enabled us to tentatively set linkage of all defaulted virtual
destructors, including templated ones. So this patch gets rid of this
special handling.
PR c++/93413
gcc/cp/ChangeLog:
* decl2.cc (mark_used): Don't defer synthesis of virtual
functions.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constexpr-virtual21.C: New test.
Kwok Cheung Yeung [Thu, 3 Nov 2022 17:19:11 +0000 (17:19 +0000)]
amdgcn: Fix instruction generation for exp2 and log2 operations
The GCN instructions for the exp2 and log2 operations are v_exp_* and v_log_*
respectively, which unfortunately do not line up with the RTL naming
convention. To deal with this, a new set of int attributes is now used when
generating the assembly for these instructions.
2022-11-03 Kwok Cheung Yeung <kcy@codesourcery.com>
gcc/
* config/gcn/gcn-valu.md (math_unop_insn): New attribute.
(<math_unop><mode>2, <math_unop><mode>2<exec>, <math_unop><mode>2,
<math_unop><mode>2<exec>, *<math_unop><mode>2_insn,
*<math_unop><mode>2<exec>_insn): Use math_unop_insn to generate
assembler output.
gcc/testsuite/
* gcc.target/gcn/unsafe-math-1.c: New.
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for state machines from plugins
gcc/analyzer/ChangeLog:
* analyzer.h: Use std::unique_ptr for state machines from plugins.
* engine.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.c: Use std::unique_ptr for
state machines from plugins.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for known functions
gcc/analyzer/ChangeLog:
* analyzer.h: Use std::unique_ptr for known functions.
* engine.cc: Likewise.
* known-function-manager.cc: Likewise.
* known-function-manager.h: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_kernel_plugin.c: Use std::unique_ptr for
known functions.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr during bifurcation
gcc/analyzer/ChangeLog:
* analysis-plan.cc: Define INCLUDE_MEMORY before including
system.h.
* analyzer-pass.cc: Likewise.
* analyzer-selftests.cc: Likewise.
* analyzer.cc: Likewise.
* analyzer.h: Use std::unique_ptr in bifurcation code.
* call-string.cc: Define INCLUDE_MEMORY before including system.h.
* complexity.cc: Likewise.
* engine.cc: Use std::unique_ptr in bifurcation code.
* exploded-graph.h: Likewise.
* known-function-manager.cc: Define INCLUDE_MEMORY before
including system.h.
* region-model-impl-calls.cc: Use std::unique_ptr in bifurcation
code.
* region-model.cc: Likewise.
* region-model.h: Likewise.
* supergraph.cc: Define INCLUDE_MEMORY before including system.h.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_kernel_plugin.c: Include "make-unique.h".
Use std::unique_ptr in bifurcation code.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for checker_event
gcc/analyzer/ChangeLog:
* call-info.cc: Use std::unique_ptr for checker_event.
* checker-path.cc: Likewise.
* checker-path.h: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* sm-signal.cc: Likewise.
* varargs.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for feasibility_problems and exploded_path
gcc/analyzer/ChangeLog:
* diagnostic-manager.cc: Include "make-unique.h".
Use std::unique_ptr for feasibility_problems and exploded_path.
Delete explicit saved_diagnostic dtor.
* diagnostic-manager.h: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* feasible-graph.cc: Likewise.
* feasible-graph.h: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for custom_edge_info pointers
gcc/analyzer/ChangeLog:
* checker-path.cc (rewind_event::rewind_event): Update for usage of
std::unique_ptr on custom_edge_info.
* engine.cc (exploded_node::on_longjmp): Likewise.
(exploded_edge::exploded_edge): Likewise.
(exploded_edge::~exploded_edge): Delete.
(exploded_graph::add_function_entry): Update for usage of
std::unique_ptr on custom_edge_info.
(exploded_graph::add_edge): Likewise.
(add_tainted_args_callback): Likewise.
(exploded_graph::maybe_create_dynamic_call): Likewise.
(exploded_graph::process_node): Likewise.
* exploded-graph.h (exploded_edge::~exploded_edge): Delete.
(exploded_edge::m_custom_info): Use std::unique_ptr.
(exploded_edge::add_edge): Likewise.
* sm-signal.cc (register_signal_handler::impl_transition): Use
make_unique.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder
gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic): Make
stmt_finder const.
(saved_diagnostic::~saved_diagnostic): Remove explicit delete of
m_stmt_finder.
(diagnostic_manager::add_diagnostic): Make stmt_finder const.
* diagnostic-manager.h (saved_diagnostic::saved_diagnostic):
Likewise.
(saved_diagnostic::m_stmt_finder): Convert to std::unique_ptr.
(diagnostic_manager::add_diagnostic): Make stmt_finder const.
* engine.cc (impl_sm_context::impl_sm_context): Likewise.
(impl_sm_context::m_stmt_finder): Likewise.
(leak_stmt_finder::clone): Convert return type to std::unique_ptr.
* exploded-graph.h (stmt_finder::clone): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for pending_diagnostic/note
gcc/analyzer/ChangeLog:
* call-info.cc: Add define of INCLUDE_MEMORY.
* call-summary.cc: Likewise.
* checker-path.cc: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
(saved_diagnostic::saved_diagnostic): Use std::unique_ptr for
param d and field m_d.
(saved_diagnostic::~saved_diagnostic): Remove explicit delete of m_d.
(saved_diagnostic::add_note): Use std::unique_ptr for
param pn.
(saved_diagnostic::get_pending_diagnostic): Update for conversion
of m_sd.m_d to unique_ptr.
(diagnostic_manager::add_diagnostic): Use std::unique_ptr for
param d. Remove explicit deletion.
(diagnostic_manager::add_note): Use std::unique_ptr for param pn.
(diagnostic_manager::emit_saved_diagnostic): Update for conversion
of m_sd.m_d to unique_ptr.
(null_assignment_sm_context::warn): Use std::unique_ptr for
param d. Remove explicit deletion.
* diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Use
std::unique_ptr for param d.
(saved_diagnostic::add_note): Likewise for param pn.
(saved_diagnostic::m_d): Likewise.
(diagnostic_manager::add_diagnostic): Use std::unique_ptr for
param d.
(diagnostic_manager::add_note): Use std::unique_ptr for param pn.
* engine.cc: Include "make-unique.h".
(impl_region_model_context::warn): Update to use std::unique_ptr
for param, removing explicit deletion.
(impl_region_model_context::add_note): Likewise.
(impl_sm_context::warn): Update to use std::unique_ptr
for param.
(impl_region_model_context::on_state_leak): Likewise for result of
on_leak.
(exploded_node::on_longjmp): Use make_unique when creating
pending_diagnostic.
(exploded_graph::process_node): Likewise.
* exploded-graph.h (impl_region_model_context::warn): Update to
use std::unique_ptr for param.
(impl_region_model_context::add_note): Likewise.
* feasible-graph.cc: Add define of INCLUDE_MEMORY.
* pending-diagnostic.cc: Likewise.
* pending-diagnostic.h: Include analyzer.sm.h"
* program-point.cc: Add define of INCLUDE_MEMORY.
* program-state.cc: Likewise.
* region-model-asm.cc: Likewise.
* region-model-impl-calls.cc: Likewise. Include "make-unique.h".
(region_model::impl_call_putenv): Use make_unique when creating
pending_diagnostic.
* region-model-manager.cc: Add define of INCLUDE_MEMORY.
* region-model-reachability.cc: Likewise.
* region-model.cc: Likewise. Include "make-unique.h".
(region_model::get_gassign_result): Use make_unique when creating
pending_diagnostic.
(region_model::check_for_poison): Likewise.
(region_model::on_stmt_pre): Likewise.
(region_model::check_symbolic_bounds): Likewise.
(region_model::check_region_bounds): Likewise.
(annotating_ctxt: make_note): Use std::unique_ptr for result.
(region_model::deref_rvalue): Use make_unique when creating
pending_diagnostic.
(region_model::check_for_writable_region): Likewise.
(region_model::check_region_size): Likewise.
(region_model::check_dynamic_size_for_floats): Likewise.
(region_model::maybe_complain_about_infoleak): Likewise.
(noop_region_model_context::add_note): Use std::unique_ptr for
param. Remove explicit deletion.
* region-model.h: Include "analyzer/pending-diagnostic.h".
(region_model_context::warn): Convert param to std::unique_ptr.
(region_model_context::add_note): Likewise.
(noop_region_model_context::warn): Likewise.
(noop_region_model_context::add_note): Likewise.
(region_model_context_decorator::warn): Likewise.
(region_model_context_decorator::add_note): Likewise.
(note_adding_context::warn): Likewise.
(note_adding_context::make_note): Likewise for return type.
(test_region_model_context::warn): Convert param to
std::unique_ptr.
* region.cc: Add define of INCLUDE_MEMORY.
* sm-fd.cc: Likewise. Include "make-unique.h".
(fd_state_machine::check_for_fd_attrs): Use make_unique when
creating pending_diagnostics.
(fd_state_machine::on_open): Likewise.
(fd_state_machine::on_creat): Likewise.
(fd_state_machine::check_for_dup): Likewise.
(fd_state_machine::on_close): Likewise.
(fd_state_machine::check_for_open_fd): Likewise.
(fd_state_machine::on_leak): Likewise, converting return type to
std::unique_ptr.
* sm-file.cc: Add define of INCLUDE_MEMORY. Include
"make-unique.h".
(fileptr_state_machine::on_stmt): Use make_unique when creating
pending_diagnostic.
(fileptr_state_machine::on_leak): Likewise, converting return type
to std::unique_ptr.
* sm-malloc.cc: Add define of INCLUDE_MEMORY. Include
"make-unique.h".
(malloc_state_machine::on_stmt): Use make_unique when creating
pending_diagnostic.
(malloc_state_machine::handle_free_of_non_heap): Likewise.
(malloc_state_machine::on_deallocator_call): Likewise.
(malloc_state_machine::on_realloc_call): Likewise.
(malloc_state_machine::on_leak): Likewise, converting return type
to std::unique_ptr.
* sm-pattern-test.cc: Add define of INCLUDE_MEMORY. Include
"make-unique.h".
(pattern_test_state_machine::on_condition): Use make_unique when
creating pending_diagnostic.
* sm-sensitive.cc: Add define of INCLUDE_MEMORY. Include
"make-unique.h".
(sensitive_state_machine::warn_for_any_exposure): Use make_unique
when creating pending_diagnostic.
* sm-signal.cc: Add define of INCLUDE_MEMORY. Include
"make-unique.h".
(signal_state_machine::on_stmt): Use make_unique when creating
pending_diagnostic.
* sm-taint.cc: Add define of INCLUDE_MEMORY. Include
"make-unique.h".
(taint_state_machine::check_for_tainted_size_arg): Use make_unique
when creating pending_diagnostic.
(taint_state_machine::check_for_tainted_divisor): Likewise.
(region_model::check_region_for_taint): Likewise.
(region_model::check_dynamic_size_for_taint): Likewise.
* sm.cc: Add define of INCLUDE_MEMORY. Include
"analyzer/pending-diagnostic.h".
(state_machine::on_leak): Move here from sm.h, changing return
type to std::unique_ptr.
* sm.h (state_machine::on_leak): Change return type to
std::unique_ptr. Move defn of base impl to sm.cc
(sm_context::warn): Convert param d to std_unique_ptr.
* state-purge.cc: Add define of INCLUDE_MEMORY.
* store.cc: Likewise.
* svalue.cc: Likewise.
* trimmed-graph.cc: Likewise.
* varargs.cc: Likewise. Include "make-unique.h".
(va_list_state_machine::check_for_ended_va_list): Use make_unique
when creating pending_diagnostic.
(va_list_state_machine::on_leak): Likewise, converting return type
to std::unique_ptr.
(region_model::impl_call_va_arg): Use make_unique when creating
pending_diagnostic.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.c: Add define of
INCLUDE_MEMORY. Include "make-unique.h".
(gil_state_machine::check_for_pyobject_in_call): Use make_unique
when creating pending_diagnostic.
(gil_state_machine::on_stmt): Likewise.
(gil_state_machine::check_for_pyobject_usage_without_gil): Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.c: : Add define of
INCLUDE_MEMORY.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Andrew MacLeod [Thu, 3 Nov 2022 01:37:49 +0000 (21:37 -0400)]
Update range query cache when a statement is updated.
Add an update_stmt interface to range query, and hook into it with the
ssa statement update call.
gcc/
* gimple-range.cc (gimple_ranger::update_stmt): New.
* gimple-range.h (gimple_ranger::update_stmt): New prototype.
* tree-ssa-operands.cc (update_stmt_operands): Notify range
query that stmt has changed.
* value-query.h (range_query::update_stmt): New.
gcc/testsuite/
* gcc.dg/tree-ssa/vrp-update.c: New.
David Malcolm [Thu, 3 Nov 2022 14:22:47 +0000 (10:22 -0400)]
Add gcc/make-unique.h
This patch adds gcc/make-unique.h, containing a minimal C++11
implementation of make_unique (std::make_unique is C++14).
gcc/ChangeLog:
* make-unique.h: New file.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 3 Nov 2022 14:21:00 +0000 (10:21 -0400)]
analyzer: fix ICE when pipe's arg isn't a pointer [PR107486]
gcc/analyzer/ChangeLog:
PR analyzer/107486
* analyzer.cc (is_pipe_call_p): New.
* analyzer.h (is_pipe_call_p): New decl.
* region-model.cc (region_model::on_call_pre): Use it.
(region_model::on_call_post): Likewise.
gcc/testsuite/ChangeLog:
PR analyzer/107486
* gcc.dg/analyzer/pipe-pr107486.c: New test.
* gcc.dg/analyzer/pipe-void-return.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>