platform/upstream/gcc.git
2 years agoanalyzer: simplify some includes
David Malcolm [Wed, 5 Oct 2022 17:52:59 +0000 (13:52 -0400)]
analyzer: simplify some includes

gcc/analyzer/ChangeLog:
* analysis-plan.cc: Simplify includes.
* analyzer-pass.cc: Likewise.
* analyzer-selftests.cc: Likewise.
* analyzer.cc: Likewise.
* analyzer.h: Add includes of "json.h" and "tristate.h".
* call-info.cc: Simplify includes.
* call-string.cc: Likewise.
* call-summary.cc: Likewise.
* checker-path.cc: Likewise.
* complexity.cc: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* feasible-graph.cc: Likewise.
* known-function-manager.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* program-point.cc: Likewise.
* program-state.cc: Likewise.
* region-model-asm.cc: Likewise.
* region-model-impl-calls.cc: Likewise.
* region-model-manager.cc: Likewise.
* region-model-reachability.cc: Likewise.
* region-model.cc: Likewise.
* region-model.h: Include "selftest.h".
* region.cc: Simplify includes.
* sm-fd.cc: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-pattern-test.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* sm.cc: Likewise.
* state-purge.cc: Likewise.
* store.cc: Likewise.
* store.h: Likewise.
* supergraph.cc: Likewise.
* svalue.cc: Likewise.
* svalue.h: Likewise.
* trimmed-graph.cc: Likewise.
* varargs.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fix ICEs seen with call summaries on PR 107060
David Malcolm [Wed, 5 Oct 2022 17:52:59 +0000 (13:52 -0400)]
analyzer: fix ICEs seen with call summaries on PR 107060

This doesn't fix the various false positives seen with
-fanalyzer-call-summaries on PR 107060, but stops it crashing at -O2.

gcc/analyzer/ChangeLog:
PR analyzer/107060
* call-summary.cc
(call_summary_replay::convert_svalue_from_summary_1): Handle NULL
results from convert_svalue_from_summary in SK_UNARY_OP and
SK_BIN_OP.
* engine.cc (impl_region_model_context::on_unknown_change): Bail
out on svalues that can't have associated state.
* region-model-impl-calls.cc
(region_model::impl_call_analyzer_get_unknown_ptr): New.
* region-model.cc (region_model::on_stmt_pre): Handle
"__analyzer_get_unknown_ptr".
* region-model.h
(region_model::impl_call_analyzer_get_unknown_ptr): New decl.
* store.cc (store::replay_call_summary_cluster): Avoid trying to
create binding clusters for base regions that shouldn't have them.

gcc/ChangeLog:
PR analyzer/107060
* doc/analyzer.texi (__analyzer_get_unknown_ptr): Document.

gcc/testsuite/ChangeLog:
PR analyzer/107060
* gcc.dg/analyzer/analyzer-decls.h (__analyzer_get_unknown_ptr):
New decl.
* gcc.dg/analyzer/call-summaries-2.c
(test_summarized_writes_param_to_ptr_unknown): New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoFortran: Add OpenMP's assume(s) directives
Tobias Burnus [Wed, 5 Oct 2022 17:25:27 +0000 (19:25 +0200)]
Fortran: Add OpenMP's assume(s) directives

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.1 Impl. Status): Mark 'assume' as 'Y'.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_assumes): New.
(show_omp_clauses, show_namespace): Call it.
(show_omp_node, show_code_node): Handle OpenMP ASSUME.
* gfortran.h (enum gfc_statement): Add ST_OMP_ASSUME,
ST_OMP_END_ASSUME, ST_OMP_ASSUMES and ST_NOTHING.
(gfc_exec_op): Add EXEC_OMP_ASSUME.
(gfc_omp_assumptions): New struct.
(gfc_get_omp_assumptions): New XCNEW #define.
(gfc_omp_clauses, gfc_namespace): Add assume member.
(gfc_resolve_omp_assumptions): New prototype.
* match.h (gfc_match_omp_assume, gfc_match_omp_assumes): New.
* openmp.cc (omp_code_to_statement): Forward declare.
(enum gfc_omp_directive_kind, struct gfc_omp_directive): New.
(gfc_free_omp_clauses): Free assume member and its struct data.
(enum omp_mask2): Add OMP_CLAUSE_ASSUMPTIONS.
(gfc_omp_absent_contains_clause): New.
(gfc_match_omp_clauses): Call it; optionally use passed
omp_clauses argument.
(omp_verify_merge_absent_contains, gfc_match_omp_assume,
 gfc_match_omp_assumes, gfc_resolve_omp_assumptions): New.
(resolve_omp_clauses): Call the latter.
(gfc_resolve_omp_directive, omp_code_to_statement): Handle
EXEC_OMP_ASSUME.
* parse.cc (decode_omp_directive): Parse OpenMP ASSUME(S).
(next_statement, parse_executable, parse_omp_structured_block):
Handle ST_OMP_ASSUME.
(case_omp_decl): Add ST_OMP_ASSUMES.
(gfc_ascii_statement): Handle Assumes, optional return
string without '!$OMP '/'!$ACC ' prefix.
* parse.h (gfc_ascii_statement): Add optional bool arg to prototype.
* resolve.cc (gfc_resolve_blocks, gfc_resolve_code): Add
EXEC_OMP_ASSUME.
(gfc_resolve): Resolve ASSUMES directive.
* symbol.cc (gfc_free_namespace): Free omp_assumes member.
* st.cc (gfc_free_statement): Handle EXEC_OMP_ASSUME.
* trans-openmp.cc (gfc_trans_omp_directive): Likewise.
* trans.cc (trans_code): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/assume-1.f90: New test.
* gfortran.dg/gomp/assume-2.f90: New test.
* gfortran.dg/gomp/assumes-1.f90: New test.
* gfortran.dg/gomp/assumes-2.f90: New test.

2 years agoc++: lvalue_kind tweak
Jason Merrill [Mon, 3 Oct 2022 21:16:38 +0000 (17:16 -0400)]
c++: lvalue_kind tweak

I was wondering how lvalue_kind handles VIEW_CONVERT_EXPR; in cases where
the type actually changes, it should have the same prvalue->xvalue effect as
ARRAY_REF, since we need to materialize a temporary to get an object we can
reinterpret as another type.

Currently this only fires on builtin-shufflevector-3.c, where we use
VIEW_CONVERT_EXPR to reinterpret a vector as an array.

REALPART_EXPR and IMAGPART_EXPR should also be treated like COMPONENT_REF.
PREINCREMENT_EXPR and PREDECREMENT_EXPR should only be applied to glvalues,
but if for some reason they were applied to a prvalue this would be correct.
TRY_CATCH_EXPR around a prvalue is also questionable, but this is the right
handling.

gcc/cp/ChangeLog:

* tree.cc (lvalue_kind) [VIEW_CONVERT_EXPR]: Change prvalue to
xvalue.

2 years agoRISC-V: Introduce RVV header to enable builtin types
Ju-Zhe Zhong [Fri, 30 Sep 2022 06:58:16 +0000 (14:58 +0800)]
RISC-V: Introduce RVV header to enable builtin types

gcc/ChangeLog:

* config.gcc: Add riscv_vector.h.
* config/riscv/riscv-builtins.cc: Add RVV builtin types support.
* config/riscv/riscv-c.cc (riscv_pragma_intrinsic): New function.
(riscv_register_pragmas): Ditto.
* config/riscv/riscv-protos.h (riscv_register_pragmas): Ditto.
(init_builtins): Move declaration from riscv-vector-builtins.h to riscv-protos.h.
(mangle_builtin_type): Ditto.
(verify_type_context): Ditto.
(handle_pragma_vector): New function.
* config/riscv/riscv-vector-builtins.cc (GTY): New variable.
(register_vector_type): New function.
(init_builtins): Add RVV builtin types support.
(handle_pragma_vector): New function.
* config/riscv/riscv-vector-builtins.h (GCC_RISCV_V_BUILTINS_H): Change
name according to file name.
(GCC_RISCV_VECTOR_BUILTINS_H): Ditto.
(init_builtins): Remove declaration in riscv-vector-builtins.h.
(mangle_builtin_type): Ditto.
(verify_type_context): Ditto.
* config/riscv/riscv.cc: Adjust for RVV builtin types support.
* config/riscv/riscv.h (REGISTER_TARGET_PRAGMAS): New macro.
* config/riscv/t-riscv: Remove redundant file including.
* config/riscv/riscv_vector.h: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pragma-1.c: New test.
* gcc.target/riscv/rvv/base/pragma-2.c: New test.
* gcc.target/riscv/rvv/base/pragma-3.c: New test.
* gcc.target/riscv/rvv/base/user-1.c: New test.
* gcc.target/riscv/rvv/base/user-2.c: New test.
* gcc.target/riscv/rvv/base/user-3.c: New test.
* gcc.target/riscv/rvv/base/user-4.c: New test.
* gcc.target/riscv/rvv/base/user-5.c: New test.
* gcc.target/riscv/rvv/base/user-6.c: New test.
* gcc.target/riscv/rvv/base/vread_csr.c: New test.
* gcc.target/riscv/rvv/base/vwrite_csr.c: New test.

2 years agorange-op: Keep nonzero mask up to date with truncating casts.
Aldy Hernandez [Wed, 5 Oct 2022 11:24:49 +0000 (13:24 +0200)]
range-op: Keep nonzero mask up to date with truncating casts.

gcc/ChangeLog:

* range-op.cc (operator_cast::fold_range): Handle truncating casts
for nonzero masks.

2 years agolibtdc++: Regenerate Makefile.in after freestanding header changes
Jonathan Wakely [Wed, 5 Oct 2022 11:58:57 +0000 (12:58 +0100)]
libtdc++: Regenerate Makefile.in after freestanding header changes

libstdc++-v3/ChangeLog:

* include/Makefile.in: Regenerate.

2 years agoc: support the attribute starting with '_'
Martin Liska [Wed, 5 Oct 2022 10:34:30 +0000 (12:34 +0200)]
c: support the attribute starting with '_'

PR c/107156

gcc/ChangeLog:

* attribs.h (lookup_attribute_by_prefix): Support the attribute
starting with underscore (_Noreturn).

2 years agolibstdc++: Guard use of new built-in with __has_builtin
Jonathan Wakely [Thu, 29 Sep 2022 10:30:05 +0000 (11:30 +0100)]
libstdc++: Guard use of new built-in with __has_builtin

Another case where I forgot that non-GCC compilers don't have this
built-in yet.

libstdc++-v3/ChangeLog:

* include/bits/invoke.h (__invoke_r): Check
__has_builtin(__reference_converts_from_temporary) before using
built-in.

2 years ago[PR tree-optimization/107052] range-ops: Take into account nonzero mask in popcount.
Aldy Hernandez [Tue, 4 Oct 2022 15:05:10 +0000 (17:05 +0200)]
[PR tree-optimization/107052] range-ops: Take into account nonzero mask in popcount.

PR tree-optimization/107052

gcc/ChangeLog:

* gimple-range-op.cc (cfn_popcount::fold_range): Take into account
nonzero bit mask.

2 years ago[PR tree-optimization/107052] range-ops: Pass nonzero masks through cast.
Aldy Hernandez [Tue, 4 Oct 2022 15:03:54 +0000 (17:03 +0200)]
[PR tree-optimization/107052] range-ops: Pass nonzero masks through cast.

Track nonzero masks through a cast in range-ops.

PR tree-optimization/107052

gcc/ChangeLog:

* range-op.cc (operator_cast::fold_range): Set nonzero mask.

2 years agoFix bogus -Wstringop-overflow warning in Ada
Eric Botcazou [Wed, 5 Oct 2022 10:21:03 +0000 (12:21 +0200)]
Fix bogus -Wstringop-overflow warning in Ada

It comes from a discrepancy between get_offset_range, which uses a signed
type, and handle_array_ref, which uses an unsigned one, to do computations.

gcc/
PR tree-optimization/106698
* pointer-query.cc (handle_array_ref): Fix handling of low bound.

gcc/testsuite/
* gnat.dg/lto26.adb: New test.
* gnat.dg/lto26_pkg1.ads, gnat.dg/lto26_pkg1.adb: New helper.
* gnat.dg/lto26_pkg2.ads, gnat.dg/lto26_pkg2.adb: Likewise.

2 years agoanalyzer: remove unused variables
Martin Liska [Wed, 5 Oct 2022 11:33:24 +0000 (13:33 +0200)]
analyzer: remove unused variables

Fixes:

gcc/analyzer/call-summary.h:103:13: warning: private field 'm_called_fn' is not used [-Wunused-private-field]
gcc/analyzer/engine.cc:1631:24: warning: unused parameter 'uncertainty' [-Wunused-parameter]

gcc/analyzer/ChangeLog:

* call-summary.cc (call_summary_replay::call_summary_replay):
  Remove unused variable and arguments.
* call-summary.h: Likewise.
* engine.cc (exploded_node::on_stmt): Likewise.
(exploded_node::replay_call_summaries): Likewise.
(exploded_node::replay_call_summary): Likewise.
* exploded-graph.h (class exploded_node): Likewise.

2 years agotestsuite: mark a test with xfail
Martin Liska [Wed, 5 Oct 2022 10:14:40 +0000 (12:14 +0200)]
testsuite: mark a test with xfail

PR tree-optimization/106679

gcc/testsuite/ChangeLog:

* gcc.dg/tree-prof/cmpsf-1.c: Mark as a known limitation.

2 years agotestsuite: 'b' instruction can't do long enough jumps
Torbjörn SVENSSON [Mon, 19 Sep 2022 16:18:58 +0000 (18:18 +0200)]
testsuite: 'b' instruction can't do long enough jumps

After moving the testglue in commit 9d503515cee, the jump to exit and
abort is too far for the 'b' instruction on Cortex-M0. As most of the
C code would generate a 'bl' instruction instead of a 'b'
instruction, lets do the same for the inline assembler.

The error seen without this patch:

/tmp/cccCRiCl.o: in function `main':
stack-protector-1.c:(.text+0x4e): relocation truncated to fit: R_ARM_THM_JUMP11 against symbol `__wrap_exit' defined in .text section in gcc_tg.o
stack-protector-1.c:(.text+0x50): relocation truncated to fit: R_ARM_THM_JUMP11 against symbol `__wrap_abort' defined in .text section in gcc_tg.o
collect2: error: ld returned 1 exit status

gcc/testsuite/ChangeLog:

* gcc.target/arm/stack-protector-1.c: Use 'bl' instead of 'b'
instruction.
* gcc.target/arm/stack-protector-3.c: Likewise.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agotestsuite: Windows reports errors with CreateProcess
Torbjörn SVENSSON [Thu, 29 Sep 2022 18:07:11 +0000 (20:07 +0200)]
testsuite: Windows reports errors with CreateProcess

When the mapper can't be executed, Windows report the error like:
.../bad-mapper-1.C: error: failed CreateProcess mapper 'this-will-not-work'

On Linux, the same error is reported this way:
.../bad-mapper-1.C: error: failed execvp mapper 'this-will-not-work'

This patch allows both output forms to be accepted.

Patch has been verified on Windows and Linux.

gcc/testsuite:

* g++.dg/modules/bad-mapper-1.C: Also accept CreateProcess.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2 years agotestsuite: /dev/null is not accessible on Windows
Torbjörn SVENSSON [Thu, 29 Sep 2022 17:38:10 +0000 (19:38 +0200)]
testsuite: /dev/null is not accessible on Windows

When running the DejaGNU testsuite on a toolchain built for native
Windows, the path /dev/null can't be used to open a stream to void.
On native Windows, the resource is instead named "nul".

The error would look like this:
c:/arm-11.3.rel1/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find @/dev/null: No such file or directory

Patch has been verified on Windows and Linux.

gcc/testsuite:

* gcc.misc-tests/outputs.exp: Use "@nul" for Windows,
"@/dev/null" for other environments.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2 years agoRISC-V: remove deprecate pic code model macro
Vineet Gupta [Fri, 2 Sep 2022 21:05:33 +0000 (14:05 -0700)]
RISC-V: remove deprecate pic code model macro

Came across this deprecated symbol when looking around for
-mexplicit-relocs handling in code

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
gcc/ChangeLog:

* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins):
Remove __riscv_cmodel_pic, that deprecated in last version.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/predef-1.c: Remove __riscv_cmodel_pic check.
* gcc.target/riscv/predef-2.c: Ditto.
* gcc.target/riscv/predef-3.c: Ditto.
* gcc.target/riscv/predef-4.c: Ditto.
* gcc.target/riscv/predef-5.c: Ditto.
* gcc.target/riscv/predef-6.c: Ditto.
* gcc.target/riscv/predef-7.c: Ditto.
* gcc.target/riscv/predef-8.c: Ditto.

2 years agoanalyzer: revamp side-effects of call summaries [PR107072]
David Malcolm [Wed, 5 Oct 2022 00:19:07 +0000 (20:19 -0400)]
analyzer: revamp side-effects of call summaries [PR107072]

With -fanalyzer-call-summaries the analyzer canl attempt to summarize
the effects of some function calls at their call site, rather than
simulate the call directly, which can avoid big slowdowns during
analysis.

Previously, this summarization was extremely simplistic: no attempt
was made to update sm-state, and region_model::update_for_call_summary
would simply set the return value of the function to UNKNOWN, and assume
the function had no side effects.

This patch implements less simplistic summarizations: it tracks each
possible return enode from the called function, and attempts to generate
a successor enode from the callsite for each that have compatible
conditions, mapping state changes in the summary to state changes
at the callsite.  It also implements the beginnings of heuristics for
generating user-facing descriptions of a summary e.g.
  "when 'foo' returns NULL"
versus:
  "when 'foo' returns a heap-allocated buffer"

This still has some bugs, but much more accurately tracks the effects
of a call, and so is an improvement; it should only have an effect
when -fanalyzer-call-summaries is enabled.

As before, -fanalyzer-call-summaries is disabled by default in
analyzer.opt (but enabled by default in the test suite).

gcc/ChangeLog:
PR analyzer/107072
* Makefile.in (ANALYZER_OBJS): Add analyzer/call-summary.o.

gcc/analyzer/ChangeLog:
PR analyzer/107072
* analyzer-logging.h: Include "diagnostic-core.h".
* analyzer.h: Include "function.h".
(class call_summary): New forward decl.
(class call_summary_replay): New forward decl.
(struct per_function_data): New forward decl.
(struct interesting_t): New forward decl.
(custom_edge_info::update_state): New vfunc.
* call-info.cc (custom_edge_info::update_state): New.
* call-summary.cc: New file.
* call-summary.h: New file.
* constraint-manager.cc: Include "analyzer/call-summary.h".
(class replay_fact_visitor): New.
(constraint_manager::replay_call_summary): New.
* constraint-manager.h (constraint_manager::replay_call_summary):
New.
* engine.cc: Include "analyzer/call-summary.h".
(exploded_node::on_stmt): Handle call summaries.
(class call_summary_edge_info): New.
(exploded_node::replay_call_summaries): New.
(exploded_node::replay_call_summary): New.
(per_function_data::~per_function_data): New.
(per_function_data::add_call_summary): Move here from header and
reimplement.
(exploded_graph::process_node): Call update_state rather than
update_model when handling bifurcation
(viz_callgraph_node::dump_dot): Use a regular label rather
than an HTML table; add summaries to dump.
* exploded-graph.h: Include "alloc-pool.h", "fibonacci_heap.h",
"supergraph.h", "sbitmap.h", "shortest-paths.h", "analyzer/sm.h",
"analyzer/program-state.h", and "analyzer/diagnostic-manager.h".
(exploded_node::replay_call_summaries): New decl.
(exploded_node::replay_call_summary): New decl.
(per_function_data::~per_function_data): New decl.
(per_function_data::add_call_summary): Move implemention from
header.
(per_function_data::m_summaries): Update type of element.
* known-function-manager.h: Include "analyzer/analyzer-logging.h".
* program-point.h: Include "pretty-print.h" and
"analyzer/call-string.h".
* program-state.cc: Include "analyzer/call-summary.h".
(sm_state_map::replay_call_summary): New.
(program_state::replay_call_summary): New.
* program-state.h (sm_state_map::replay_call_summary): New decl.
(program_state::replay_call_summary): New decl.
* region-model-manager.cc
(region_model_manager::get_or_create_asm_output_svalue): New
overload.
* region-model-manager.h
(region_model_manager::get_or_create_asm_output_svalue): New
overload decl.
* region-model.cc: Include "analyzer/call-summary.h".
(region_model::maybe_update_for_edge): Remove call to
region_model::update_for_call_summary on
SUPEREDGE_INTRAPROCEDURAL_CALL.
(region_model::update_for_call_summary): Delete.
(region_model::replay_call_summary): New.
* region-model.h (region_model::replay_call_summary): New decl.
(region_model::update_for_call_summary): Delete decl.
* store.cc: Include "analyzer/call-summary.h".
(store::replay_call_summary): New.
(store::replay_call_summary_cluster): New.
* store.h: Include "tristate.h".
(is_a_helper <const ana::concrete_binding *>::test): New.
(store::replay_call_summary): New decl.
(store::replay_call_summary_cluster): New decl.
* supergraph.cc (get_ultimate_function_for_cgraph_edge): Remove
"static" from decl.
(supergraph_call_edge): Make stmt param const.
* supergraph.h: Include "ordered-hash-map.h", "cfg.h",
"basic-block.h", "gimple.h", "gimple-iterator.h", and "digraph.h".
(supergraph_call_edge): Make stmt param const.
(get_ultimate_function_for_cgraph_edge): New decl.
* svalue.cc (compound_svalue::compound_svalue): Assert that we're
not nesting compound_svalues.
* svalue.h: Include "json.h", "analyzer/store.h", and
"analyzer/program-point.h".
(asm_output_svalue::get_num_outputs): New accessor.

gcc/testsuite/ChangeLog:
PR analyzer/107072
* gcc.dg/analyzer/call-summaries-2.c: New test.
* gcc.dg/analyzer/call-summaries-3.c: New test.
* gcc.dg/analyzer/call-summaries-asm-x86.c: New test.
* gcc.dg/analyzer/call-summaries-malloc.c: New test.
* gcc.dg/analyzer/call-summaries-pr107072.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: move region_model_manager decl to its own header
David Malcolm [Wed, 5 Oct 2022 00:19:06 +0000 (20:19 -0400)]
analyzer: move region_model_manager decl to its own header

gcc/analyzer/ChangeLog:
* region-model.h: Include "analyzer/region-model-manager.h"
(class region_model_manager): Move decl to...
* region-model-manager.h: ...this new file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fold -(-(VAL)) to VAL
David Malcolm [Wed, 5 Oct 2022 00:19:06 +0000 (20:19 -0400)]
analyzer: fold -(-(VAL)) to VAL

gcc/analyzer/ChangeLog:
* region-model-manager.cc
(region_model_manager::maybe_fold_unaryop): Fold -(-(VAL)) to VAL.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: widening_svalues take a function_point rather than a program_point
David Malcolm [Wed, 5 Oct 2022 00:19:06 +0000 (20:19 -0400)]
analyzer: widening_svalues take a function_point rather than a program_point

Enabling work towrads better call summarization.

gcc/analyzer/ChangeLog:
* region-model-manager.cc
(region_model_manager::get_or_create_widening_svalue): Use a
function_point rather than a program_point.
* region-model.cc (selftest::test_widening_constraints): Likewise.
* region-model.h
(region_model_manager::get_or_create_widening_svalue): Likewise.
(model_merger::get_function_point): New.
* svalue.cc (svalue::can_merge_p): Use a function_point rather
than a program_point.
(svalue::can_merge_p): Likewise.
* svalue.h (widening_svalue::key_t): Likewise.
(widening_svalue::widening_svalue): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoDaily bump.
GCC Administrator [Wed, 5 Oct 2022 00:17:25 +0000 (00:17 +0000)]
Daily bump.

2 years agoc++: fix debug info for array temporary [PR107154]
Jason Merrill [Tue, 4 Oct 2022 21:06:04 +0000 (17:06 -0400)]
c++: fix debug info for array temporary [PR107154]

In the testcase the elaboration of the array init that happens at genericize
time was getting the location info for the end of the function; fixed by
doing the expansion at the location of the original expression.

PR c++/107154

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_genericize_init_expr): Use iloc_sentinel.
(cp_genericize_target_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/debug/dwarf2/lineno-array1.C: New test.

2 years agoattribs: Add overloads with namespace name
Jakub Jelinek [Tue, 4 Oct 2022 21:13:15 +0000 (23:13 +0200)]
attribs: Add overloads with namespace name

I've discovered a problem with the way we handle scoped attributes.  For
declaration or type attributes for attributes we don't know anything about
we just don't add them to the declarations or types, so later in the FEs and
middle-end it is fine to use lookup_attribute etc.  which just check the
attribute name and not namespace because non-standard non-GNU attributes
just won't show there.  But in the case of attributes on statements, nothing
has filtered out the unknown attributes, so with my earlier assume
attribute patch e.g.  c-c++-common/Wno-attributes-6.c test failed because
it uses:
[[vendor::assume(1 + 1 == 2)]];
with -Wno-attributes=vendor::assume and lookup_attribute ("assume", )
finds such attribute and handled it that way.
So, for those cases, this patch introduces lookup_attribute and
remove_attribute overloads which specify also the namespace.
I think the fallthrough, hot, cold, likely, unlikely attribute handling
will need to use the new APIs too, so that we don't handle
msft::fallthrough attribute as something we'd know.

2022-10-04  Jakub Jelinek  <jakub@redhat.com>

* attribs.h (remove_attribute): Declare overload with additional
attr_ns argument.
(private_lookup_attribute): Declare overload with additional
attr_ns and attr_ns_len arguments.
(lookup_attribute): New overload with additional attr_ns argument.
* attribs.cc (remove_attribute): New overload with additional
attr_ns argument.
(private_lookup_attribute): New overload with additional
attr_ns and attr_ns_len arguments.

2 years agoattribs: Add missing auto_diagnostic_group 3 times
Jakub Jelinek [Tue, 4 Oct 2022 19:05:16 +0000 (21:05 +0200)]
attribs: Add missing auto_diagnostic_group 3 times

In these spots, the error/error_at has some inform afterwards which are
explanation part of the same diagnostics, so should be tied with
auto_diagnostic_group with it.

2022-10-04  Jakub Jelinek  <jakub@redhat.com>

* attribs.cc (handle_ignored_attributes_option, decl_attributes,
common_function_versions): Use auto_diagnostic_group.

2 years agoRemove assert from set_nonzero_bits.
Aldy Hernandez [Tue, 4 Oct 2022 17:50:28 +0000 (19:50 +0200)]
Remove assert from set_nonzero_bits.

The assert removed by this patch was there to keep users from passing
masks of incompatible types.  The self tests are passing host wide
ints down (set_nonzero_bits (-1)), which seem to be 32 bits, whereas
some embedded targets have integer_type_node's of 16-bits.  This is
causing problems in m32c-elf, among others.

I suppose there's no harm in passing a 32-bit mask, because
set_nonzero_bits calls wide_int::from() to convert the mask to the
appropriate type.  So we can remove the assert.

gcc/ChangeLog:

* value-range.cc (irange::set_nonzero_bits): Remove assert.

2 years agolibstdc++: Fix test FAIL for old std::string ABI
Jonathan Wakely [Tue, 4 Oct 2022 16:23:45 +0000 (17:23 +0100)]
libstdc++: Fix test FAIL for old std::string ABI

libstdc++-v3/ChangeLog:

* testsuite/std/ranges/adaptors/join_with/1.cc: Remove unused
<sstream header.
(test04): Remove constexpr for old std::string ABI and test at
runtime.

2 years agolibstdc++: Use new built-ins __remove_cv, __remove_reference etc.
Jonathan Wakely [Tue, 4 Oct 2022 12:00:52 +0000 (13:00 +0100)]
libstdc++: Use new built-ins __remove_cv, __remove_reference etc.

libstdc++-v3/ChangeLog:

* include/std/type_traits (remove_cv): Use __remove_cv built-in.
(remove_reference): Use __remove_reference built-in.
(remove_cvref): Use __remove_cvref built-in. Remove inheritance
for fallback implementation.

2 years agolibstdc++: Refactor seed sequence constraints in <random>
Jonathan Wakely [Tue, 4 Oct 2022 11:57:33 +0000 (12:57 +0100)]
libstdc++: Refactor seed sequence constraints in <random>

Every use of _If_seed_seq in <random> and <ext/random> uses it with
enable_if. We can just move the enable_if into the helper alias instead
of repeating it everywhere.

libstdc++-v3/ChangeLog:

* include/bits/random.h (__is_seed_seq): Replace with ...
(_If_seed_seq_for): ... this.
* include/ext/random: Adjust to use _If_seed_seq_for.

2 years agoc++: install cp-trait.def as part of plugin headers [PR107136]
Patrick Palka [Tue, 4 Oct 2022 16:23:46 +0000 (12:23 -0400)]
c++: install cp-trait.def as part of plugin headers [PR107136]

This is apparently needed since we include cp-trait.def from cp-tree.h
(in order to define the cp_trait_kind enum), as with operators.def.

PR c++/107136

gcc/cp/ChangeLog:

* Make-lang.in (CP_PLUGIN_HEADERS): Add cp-trait.def.

2 years agoaarch64: Define __ARM_FEATURE_RCPC
Richard Sandiford [Tue, 4 Oct 2022 15:39:18 +0000 (16:39 +0100)]
aarch64: Define __ARM_FEATURE_RCPC

https://github.com/ARM-software/acle/pull/199 adds a new feature
macro for RCPC, for use in things like inline assembly.  This patch
adds the associated support to GCC.

Also, RCPC is required for Armv8.3-A and later, but the armv8.3-a
entry didn't include it.  This was probably harmless in practice
since GCC simply ignored the extension until now.  (The GAS
definition is OK.)

gcc/
* config/aarch64/aarch64.h (AARCH64_ISA_RCPC): New macro.
* config/aarch64/aarch64-arches.def (armv8.3-a): Include RCPC.
* config/aarch64/aarch64-cores.def (thunderx3t110, zeus, neoverse-v1)
(neoverse-512tvb, saphira): Remove RCPC from these Armv8.3-A+ cores.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define
__ARM_FEATURE_RCPC when appropriate.

gcc/testsuite/
* gcc.target/aarch64/pragma_cpp_predefs_1.c: Add RCPC tests.

2 years agoOpenMP: Update invoke.texi and fix fortran/parse.cc for -fopenmp-simd
Tobias Burnus [Tue, 4 Oct 2022 15:03:32 +0000 (17:03 +0200)]
OpenMP: Update invoke.texi and fix fortran/parse.cc for -fopenmp-simd

Split off from the 'Fortran: Add OpenMP's assume(s) directives' patch.

gcc/
* doc/invoke.texi (-fopenmp): Mention C++ attribut syntax.
(-fopenmp-simd): Likewise; update permitted directives.

gcc/fortran/
* parse.cc (decode_omp_directive): Handle '(end) loop' and 'scan'
also with -fopenmp-simd.

gcc/testsuite/
* gfortran.dg/gomp/openmp-simd-7.f90: New test.

2 years agolibstdc++: Avoid heavyweight std::visit in ranges::join_with_view
Patrick Palka [Tue, 4 Oct 2022 14:54:36 +0000 (10:54 -0400)]
libstdc++: Avoid heavyweight std::visit in ranges::join_with_view

libstdc++-v3/ChangeLog:

* include/std/ranges (join_with_view::_Iterator::operator*):
Replace use of std::visit with manual visitation.
(join_with_view::_Iterator::operator++): Likewise.
(join_with_view::_Iterator::operator--): Likewise.
(join_with_view::_Iterator::iter_move): Likewise.
(join_with_view::_Iterator::iter_swap): Likewise.

2 years agolibstdc++: Disable test for freestanding
Jonathan Wakely [Tue, 4 Oct 2022 13:18:07 +0000 (14:18 +0100)]
libstdc++: Disable test for freestanding

This test checks the exception-safety of std::stable_sort if copying a
value throws. For freestanding we don't allocate in std::stable_sort
anyway, and the exception thrown via __throw_runtime_error terminates,
so disable the test.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/stable_sort/mem_check.cc: Do nto run
for freestanding.

2 years agolibstdc++: Enable std::hash<coroutine_handle<P>> [PR107139]
Jonathan Wakely [Tue, 4 Oct 2022 08:37:14 +0000 (09:37 +0100)]
libstdc++: Enable std::hash<coroutine_handle<P>> [PR107139]

Everything that <coroutine> depends on is available for freestanding
now.

libstdc++-v3/ChangeLog:

PR libstdc++/107139
* include/std/coroutine: Remove all _GLIBCXXHOSTED preprocessor
conditionals.

2 years agolibstdc++: Make <cstdint> work freestanding [PR107134]
Jonathan Wakely [Mon, 3 Oct 2022 20:49:27 +0000 (21:49 +0100)]
libstdc++: Make <cstdint> work freestanding [PR107134]

When gcc/config.gcc defines use_gcc_stdin=wrap, GCC's <stdint.h> tries
to use libc's <stdint.h> unless -ffreestanding is used.

When libstdc++ is configured --disable-hosted-libstdcxx we want
<cstdint> to work even without -ffreestanding being given. This is a
kluge to make it include GCC's <stdint-gcc.h> directly even without
-ffreestanding.

libstdc++-v3/ChangeLog:

PR libstdc++/107134
* include/c_global/cstdint [!_GLIBCXX_HOSTED]: Include
<stdint-gcc.h> directly.

2 years agolibstdc++: Define <bits/functexcept.h> functions for freestanding [PR107135]
Jonathan Wakely [Mon, 3 Oct 2022 19:53:35 +0000 (20:53 +0100)]
libstdc++: Define <bits/functexcept.h> functions for freestanding [PR107135]

We don't compile src/c++11/functexcept.cc for freestanding, so just
define the functions used by freestanding entities as inline calls to
std::terminate.

libstdc++-v3/ChangeLog:

PR libstdc++/107135
* include/bits/functexcept.h [!_GLIBCXX_HOSTED]
(__throw_invalid_argument, __throw_out_of_range)
(__throw_out_of_range_fmt, __throw_runtime_error)
(__throw_overflow_error): Define inline.
* include/std/bitset (_M_copy_from_ptr) [!_GLIBCXX_HOSTED]:
Replace __builtin_abort with __throw_invalid_argument.

2 years agolibstdc++: Implement ranges::join_with_view from P2441R2
Patrick Palka [Tue, 4 Oct 2022 13:45:15 +0000 (09:45 -0400)]
libstdc++: Implement ranges::join_with_view from P2441R2

libstdc++-v3/ChangeLog:

* include/std/ranges: Include <variant> for C++23.
(__detail::__compatible_joinable_ranges): Define.
(__detail::__bidirectional_common): Define.
(join_with_view): Define.
(join_with_view::_Iterator): Define.
(join_with_view::_Sentinel): Define.
(views::__detail::__can_join_with_view): Define.
(views::_JoinWith, views::join_with): Define.
* testsuite/std/ranges/adaptors/join_with/1.cc: New test.

2 years agoinstall.texi: gcn - update llvm reqirements, gcn/nvptx - newlib use version
Tobias Burnus [Tue, 4 Oct 2022 09:49:18 +0000 (11:49 +0200)]
install.texi: gcn - update llvm reqirements, gcn/nvptx - newlib use version

gcc/
* doc/install.texi (Specific): Add missing items to bullet list.
(amdgcn): Update LLVM requirements, use version not date for newlib.
(nvptx): Use version not git hash for newlib.

2 years agolibstdc++: Use ///< for inline documentation
Arsen Arsenović [Sat, 1 Oct 2022 18:40:05 +0000 (20:40 +0200)]
libstdc++: Use ///< for inline documentation

I noticed that some variables were misdocumented when using trailing
comment for documentation.  I ran a search with a relatively simple
regex[1] to look for any ///s following some code that did not have a <,
and came up with these instances only.

[1]: \s*([^  ]+\s*)+///[^<].*$

libstdc++-v3/ChangeLog:

* include/std/iostream: Use ///< for inline documentation.
* include/std/limits: Likewise.
* include/experimental/internet: Likewise.

2 years agoopenmp: Add begin declare target support
Jakub Jelinek [Tue, 4 Oct 2022 08:37:14 +0000 (10:37 +0200)]
openmp: Add begin declare target support

The following patch adds support for the begin declare target construct,
which is another spelling for declare target construct without clauses
(where it needs paired end declare target), but unlike that one accepts
clauses.

This is an OpenMP 5.1 feature, implemented with 5.2 clarification because
in 5.1 we had a restriction in the declare target chapter shared by
declare target and begin declare target that if there are any clauses
specified at least one of them needs to be to or link.  But that
was of course meant just for declare target and not begin declare target,
because begin declare target doesn't even allow to/link/enter clauses.
In addition to that, the patch also makes device_type clause duplication
an error (as stated in 5.1) and similarly makes declare target with
just device_type clause an error rather than warning.

What this patch doesn't do is:
1) OpenMP 5.1 also added an indirect clause, we don't support that
   neither on declare target nor begin declare target
   and I couldn't find it in our features pages (neither libgomp.texi
   nor web)
2) I think device_type(nohost)/device_type(host) support can't work for
   variables (in 5.0 it only talked about procedures so this could be
   also thought as 5.1 feature that we should just add to the list
   and implement)
3) I don't see any use of the "omp declare target nohost" attribute, so
   I'm not sure if device_type(nohost) works at all

2022-10-04  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
* c-omp.cc (c_omp_directives): Uncomment begin declare target
entry.
gcc/c/
* c-lang.h (struct c_omp_declare_target_attr): New type.
(current_omp_declare_target_attribute): Change type from
int to vec<c_omp_declare_target_attr, va_gc> *.
* c-parser.cc (c_parser_translation_unit): Adjust for that change.
If last pushed directive was begin declare target, use different
wording and simplify format strings for easier translations.
(c_parser_omp_clause_device_type): Uncomment
check_no_duplicate_clause call.
(c_parser_omp_declare_target): Adjust for the
current_omp_declare_target_attribute type change, push { -1 }.
Use error_at rather than warning_at for declare target with
only device_type clauses.
(OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK): Define.
(c_parser_omp_begin): Add begin declare target support.
(c_parser_omp_end): Adjust for the
current_omp_declare_target_attribute type change, adjust
diagnostics wording and simplify format strings for easier
translations.
* c-decl.cc (current_omp_declare_target_attribute): Change type from
int to vec<c_omp_declare_target_attr, va_gc> *.
(c_decl_attributes): Adjust for the
current_omp_declare_target_attribute type change.  If device_type
was present on begin declare target, add "omp declare target host"
and/or "omp declare target nohost" attributes.
gcc/cp/
* cp-tree.h (struct omp_declare_target_attr): Rename to ...
(cp_omp_declare_target_attr): ... this.  Add device_type member.
(omp_begin_assumes_data): Rename to ...
(cp_omp_begin_assumes_data): ... this.
(struct saved_scope): Change types of omp_declare_target_attribute
and omp_begin_assumes.
* parser.cc (cp_parser_omp_clause_device_type): Uncomment
check_no_duplicate_clause call.
(cp_parser_omp_all_clauses): Fix up pasto, c_name for OMP_CLAUSE_LINK
should be "link" rather than "to".
(cp_parser_omp_declare_target): Adjust for omp_declare_target_attr
to cp_omp_declare_target_attr changes, push -1 as device_type.  Use
error_at rather than warning_at for declare target with only
device_type clauses.
(OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK): Define.
(cp_parser_omp_begin): Add begin declare target support.  Adjust
for omp_begin_assumes_data to cp_omp_begin_assumes_data change.
(cp_parser_omp_end): Adjust for the
omp_declare_target_attr to cp_omp_declare_target_attr and
omp_begin_assumes_data to cp_omp_begin_assumes_data type changes,
adjust diagnostics wording and simplify format strings for easier
translations.
* semantics.cc (finish_translation_unit): Likewise.
* decl2.cc (cplus_decl_attributes): If device_type was present on
begin declare target, add "omp declare target host" and/or
"omp declare target nohost" attributes.
gcc/testsuite/
* c-c++-common/gomp/declare-target-4.c: Move tests that are now
rejected into declare-target-7.c.
* c-c++-common/gomp/declare-target-6.c: Adjust expected diagnostics.
* c-c++-common/gomp/declare-target-7.c: New test.
* c-c++-common/gomp/begin-declare-target-1.c: New test.
* c-c++-common/gomp/begin-declare-target-2.c: New test.
* c-c++-common/gomp/begin-declare-target-3.c: New test.
* c-c++-common/gomp/begin-declare-target-4.c: New test.
* g++.dg/gomp/attrs-9.C: Add begin declare target tests.
* g++.dg/gomp/attrs-18.C: New test.
libgomp/
* libgomp.texi (Support begin/end declare target syntax in C/C++):
Mark as implemented.

2 years agoConvert nonzero mask in irange to wide_int.
Aldy Hernandez [Sat, 1 Oct 2022 20:49:32 +0000 (22:49 +0200)]
Convert nonzero mask in irange to wide_int.

The reason the nonzero mask was kept in a tree was basically inertia,
as everything in irange is a tree.  However, there's no need to keep
it in a tree, as the conversions to and from wide ints are very
annoying.  That, plus special casing NULL masks to be -1 is prone
to error.

I have not only rewritten all the uses to assume a wide int, but
have corrected a few places where we weren't propagating the masks, or
rather pessimizing them to -1.  This will become more important in
upcoming patches where we make better use of the masks.

Performance testing shows a trivial improvement in VRP, as things like
irange::contains_p() are tied to a tree.  Ughh, can't wait for trees in
iranges to go away.

gcc/ChangeLog:

* value-range-storage.cc (irange_storage_slot::set_irange): Remove
special case.
* value-range.cc (irange::irange_set): Adjust for nonzero mask
being a wide int.
(irange::irange_set_anti_range): Same.
(irange::set): Same.
(irange::verify_range): Same.
(irange::legacy_equal_p): Same.
(irange::operator==): Same.
(irange::contains_p): Same.
(irange::legacy_intersect): Same.
(irange::legacy_union): Same.
(irange::irange_single_pair_union): Call union_nonzero_bits.
(irange::irange_union): Same.
(irange::irange_intersect): Call intersect_nonzero_bits.
(irange::intersect): Adjust for nonzero mask being a wide int.
(irange::invert): Same.
(irange::set_nonzero_bits): Same.
(irange::get_nonzero_bits_from_range): New.
(irange::set_range_from_nonzero_bits): New.
(irange::get_nonzero_bits): Adjust for nonzero mask being a wide
int.
(irange::intersect_nonzero_bits): Same.
(irange::union_nonzero_bits): Same.
(range_tests_nonzero_bits): Remove test.
* value-range.h (irange::varying_compatible_p): Adjust for nonzero
mask being a wide int.
(gt_ggc_mx): Same.
(gt_pch_nx): Same.
(irange::set_undefined): Same.
(irange::set_varying): Same.
(irange::normalize_kind): Same.

2 years ago[PR107130] range-ops: Separate out ffs and popcount optimizations.
Aldy Hernandez [Mon, 3 Oct 2022 15:31:32 +0000 (17:31 +0200)]
[PR107130] range-ops: Separate out ffs and popcount optimizations.

__builtin_popcount and __builtin_ffs were sharing the same range-ops
entry, but the nonzero mask optimization is not valid for ffs.
Separate them out into two entries.

PR tree-optimization/107130

gcc/ChangeLog:

* gimple-range-op.cc (class cfn_popcount): Call op_cfn_ffs.
(class cfn_ffs): New.
(gimple_range_op_handler::maybe_builtin_call): Separate out
CASE_CFN_FFS into its own case.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr107130.c: New test.

2 years agodiagnostics: Add test for fixed _Pragma location issue [PR91669]
Lewis Hyatt [Sat, 1 Oct 2022 16:05:13 +0000 (12:05 -0400)]
diagnostics: Add test for fixed _Pragma location issue [PR91669]

This PR related to _Pragma locations and diagnostic pragmas was fixed by a
combination of r10-325 and r13-1596. Add missing test coverage.

gcc/testsuite/ChangeLog:

PR c/91669
* c-c++-common/pr91669.c: New test.

2 years agoDaily bump.
GCC Administrator [Tue, 4 Oct 2022 00:17:16 +0000 (00:17 +0000)]
Daily bump.

2 years agolibstdc++: Update status docs for compare_exchange padding bits
Jonathan Wakely [Mon, 3 Oct 2022 17:27:23 +0000 (18:27 +0100)]
libstdc++: Update status docs for compare_exchange padding bits

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2020.xml: Update C++20 status.
* doc/html/manual/status.html: Regenerate.

2 years agogcc/config/t-i386: add build dependencies on i386-builtin-types.inc
Sergei Trofimovich [Fri, 16 Sep 2022 17:33:11 +0000 (18:33 +0100)]
gcc/config/t-i386: add build dependencies on i386-builtin-types.inc

i386-builtin-types.inc is included indirectly via i386-builtins.h
into 4 files: i386.cc i386-builtins.cc i386-expand.cc i386-features.cc

Only i386.cc dependency was present in gcc/config/t-i386 makefile.

As a result parallel builds occasionally fail as:

    g++ ... -o i386-builtins.o ... ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc
    In file included from ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc:92:
    ../../gcc-13-20220911/gcc/config/i386/i386-builtins.h:25:10:
     fatal error: i386-builtin-types.inc: No such file or directory
       25 | #include "i386-builtin-types.inc"
          |          ^~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    make[3]: *** [../../gcc-13-20220911/gcc/config/i386/t-i386:54: i386-builtins.o]
      Error 1 shuffle=1663349189

gcc/
* config/i386/t-i386: Add build-time dependencies against
i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
i386-features.o.

2 years ago[testsuite][arm] Fix cmse-15.c expected output
Torbjörn SVENSSON [Fri, 23 Sep 2022 08:35:15 +0000 (10:35 +0200)]
[testsuite][arm] Fix cmse-15.c expected output

The cmse-15.c testcase fails at -Os because ICF means that we
generate
secure3:
        b       secure1

which is OK, but does not match the currently expected
secure3:
...
        bx      r[0-3]

gcc/testsuite/ChangeLog:

* gcc.target/arm/cmse/cmse-15.c: Align with -Os improvements.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agoc++: Disallow jumps into statement expressions
Jakub Jelinek [Mon, 3 Oct 2022 16:04:37 +0000 (18:04 +0200)]
c++: Disallow jumps into statement expressions

On Fri, Sep 30, 2022 at 04:39:25PM -0400, Jason Merrill wrote:
> > --- gcc/cp/decl.cc.jj       2022-09-22 00:14:55.478599363 +0200
> > +++ gcc/cp/decl.cc  2022-09-22 00:24:01.121178256 +0200
> > @@ -223,6 +223,7 @@ struct GTY((for_user)) named_label_entry
> >     bool in_transaction_scope;
> >     bool in_constexpr_if;
> >     bool in_consteval_if;
> > +  bool in_assume;
>
> I think it would be better to reject jumps into statement-expressions like
> the C front-end.

Ok, here is a self-contained patch that does that.

2022-10-03  Jakub Jelinek  <jakub@redhat.com>

* cp-tree.h (BCS_STMT_EXPR): New enumerator.
* name-lookup.h (enum scope_kind): Add sk_stmt_expr.
* name-lookup.cc (begin_scope): Handle sk_stmt_expr like sk_block.
* semantics.cc (begin_compound_stmt): For BCS_STMT_EXPR use
sk_stmt_expr.
* parser.cc (cp_parser_statement_expr): Use BCS_STMT_EXPR instead of
BCS_NORMAL.
* decl.cc (struct named_label_entry): Add in_stmt_expr.
(poplevel_named_label_1): Handle sk_stmt_expr.
(check_previous_goto_1): Diagnose entering of statement expression.
(check_goto): Likewise.

* g++.dg/ext/stmtexpr24.C: New test.

2 years agoUpdate gcc sv.po
Joseph Myers [Mon, 3 Oct 2022 16:00:10 +0000 (16:00 +0000)]
Update gcc sv.po

* sv.po: Update.

2 years agoc++: rename IS_SAME_AS trait code to IS_SAME
Patrick Palka [Mon, 3 Oct 2022 15:20:32 +0000 (11:20 -0400)]
c++: rename IS_SAME_AS trait code to IS_SAME

... to match the trait's canonical spelling __is_same instead
of its alternative spelling __is_same_as.

gcc/c-family/ChangeLog:

* c-common.cc (c_common_reswords): Use RID_IS_SAME instead of
RID_IS_SAME_AS.

gcc/cp/ChangeLog:

* constraint.cc (diagnose_trait_expr): Use CPTK_IS_SAME instead
of CPTK_IS_SAME_AS.
* cp-trait.def (IS_SAME_AS): Rename to ...
(IS_SAME): ... this.
* pt.cc (alias_ctad_tweaks): Use CPTK_IS_SAME instead of
CPTK_IS_SAME_AS.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

2 years agolibstdc++: Disable hosted-only tests [PR103626]
Arsen Arsenović [Fri, 30 Sep 2022 15:06:49 +0000 (17:06 +0200)]
libstdc++: Disable hosted-only tests [PR103626]

PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding

libstdc++-v3/ChangeLog:

PR libstdc++/103626
* testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc:
Require ET hosted.
* testsuite/18_support/aligned_alloc/aligned_alloc.cc: Likewise.
* testsuite/18_support/new_nothrow.cc: Likewise.
* testsuite/20_util/allocator/105975.cc: Likewise.
* testsuite/20_util/allocator/14176.cc: Likewise.
* testsuite/20_util/allocator/64135.cc: Likewise.
* testsuite/20_util/allocator/89510.cc: Likewise.
* testsuite/20_util/allocator/lwg3190.cc: Likewise.
* testsuite/20_util/allocator/overaligned.cc: Likewise.
* testsuite/20_util/allocator/rebind_c++20.cc: Likewise.
* testsuite/20_util/allocator/requirements/constexpr.cc:
Likewise.
* testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/20_util/allocator/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/allocator/requirements/typedefs_c++20.cc:
Likewise.
* testsuite/20_util/allocator/void.cc: Likewise.
* testsuite/20_util/allocator_traits/header-2.cc: Likewise.
* testsuite/20_util/allocator_traits/header.cc: Likewise.
* testsuite/20_util/allocator_traits/members/92878_92947.cc:
Likewise.
* testsuite/20_util/allocator_traits/members/pointers.cc:
Likewise.
* testsuite/20_util/allocator_traits/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/bad_function_call/cons_virtual_derivation.cc:
Likewise.
* testsuite/20_util/bind/42593.cc: Likewise.
* testsuite/20_util/bitset/access/dr396.cc: Likewise.
* testsuite/20_util/bitset/access/to_string.cc: Likewise.
* testsuite/20_util/bitset/cons/16020.cc: Likewise.
* testsuite/20_util/bitset/cons/dr1325-2.cc: Likewise.
* testsuite/20_util/bitset/cons/dr396.cc: Likewise.
* testsuite/20_util/bitset/debug/invalidation/1.cc: Likewise.
* testsuite/20_util/bitset/ext/15361.cc: Likewise.
* testsuite/20_util/bitset/operations/13838.cc: Likewise.
* testsuite/20_util/bitset/operations/96303.cc: Likewise.
* testsuite/20_util/bitset/version.cc: Likewise.
* testsuite/20_util/enable_shared_from_this/56383.cc: Likewise.
* testsuite/20_util/enable_shared_from_this/89303.cc: Likewise.
* testsuite/20_util/enable_shared_from_this/members/assign.cc:
Likewise.
* testsuite/20_util/enable_shared_from_this/members/const.cc:
Likewise.
* testsuite/20_util/enable_shared_from_this/members/reinit.cc:
Likewise.
* testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc:
Likewise.
* testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
Likewise.
* testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc:
Likewise.
* testsuite/20_util/forward/1.cc: Likewise.
* testsuite/20_util/forward/1_neg.cc: Likewise.
* testsuite/20_util/function/1.cc: Likewise.
* testsuite/20_util/function/10.cc: Likewise.
* testsuite/20_util/function/2.cc: Likewise.
* testsuite/20_util/function/3.cc: Likewise.
* testsuite/20_util/function/4.cc: Likewise.
* testsuite/20_util/function/43397.cc: Likewise.
* testsuite/20_util/function/48541.cc: Likewise.
* testsuite/20_util/function/5.cc: Likewise.
* testsuite/20_util/function/58569.cc: Likewise.
* testsuite/20_util/function/6.cc: Likewise.
* testsuite/20_util/function/60594.cc: Likewise.
* testsuite/20_util/function/65760.cc: Likewise.
* testsuite/20_util/function/69222.cc: Likewise.
* testsuite/20_util/function/7.cc: Likewise.
* testsuite/20_util/function/77322.cc: Likewise.
* testsuite/20_util/function/8.cc: Likewise.
* testsuite/20_util/function/9.cc: Likewise.
* testsuite/20_util/function/91456.cc: Likewise.
* testsuite/20_util/function/assign/move.cc: Likewise.
* testsuite/20_util/function/assign/move_target.cc: Likewise.
* testsuite/20_util/function/cmp/cmp_neg.cc: Likewise.
* testsuite/20_util/function/cons/55320.cc: Likewise.
* testsuite/20_util/function/cons/57465.cc: Likewise.
* testsuite/20_util/function/cons/72820.cc: Likewise.
* testsuite/20_util/function/cons/addressof.cc: Likewise.
* testsuite/20_util/function/cons/callable.cc: Likewise.
* testsuite/20_util/function/cons/deduction.cc: Likewise.
* testsuite/20_util/function/cons/lwg2774.cc: Likewise.
* testsuite/20_util/function/cons/move.cc: Likewise.
* testsuite/20_util/function/cons/move_target.cc: Likewise.
* testsuite/20_util/function/cons/noexcept.cc: Likewise.
* testsuite/20_util/function/cons/non_copyconstructible.cc:
Likewise.
* testsuite/20_util/function/cons/refqual.cc: Likewise.
* testsuite/20_util/function/cons/70692.cc: Likewise.
* testsuite/20_util/function/cons/deduction_c++23.cc: Likewise.
* testsuite/20_util/function/invoke/forwarding.cc: Likewise.
* testsuite/20_util/function/invoke/move_only.cc: Likewise.
* testsuite/20_util/function/null_pointer_comparisons.cc:
Likewise.
* testsuite/20_util/function/requirements/explicit_instantiation.cc:
Likewise.
* testsuite/20_util/function/target_no_rtti.cc: Likewise.
* testsuite/20_util/function_objects/83607.cc: Likewise.
* testsuite/20_util/function_objects/mem_fn/adl.cc: Likewise.
* testsuite/20_util/headers/cstdlib/functions_std.cc: Likewise.
* testsuite/20_util/headers/functional/types_std_c++0x.cc:
Likewise.
* testsuite/20_util/headers/memory/types_std_c++0x.cc: Likewise.
* testsuite/20_util/is_function/35637.cc: Likewise.
* testsuite/20_util/move/1.cc: Likewise.
* testsuite/20_util/move_only_function/call.cc: Likewise.
* testsuite/20_util/move_only_function/cons.cc: Likewise.
* testsuite/20_util/move_only_function/move.cc: Likewise.
* testsuite/20_util/move_only_function/version.cc: Likewise.
* testsuite/20_util/owner_less/cmp.cc: Likewise.
* testsuite/20_util/owner_less/noexcept.cc: Likewise.
* testsuite/20_util/owner_less/void.cc: Likewise.
* testsuite/20_util/pointer_safety/1.cc: Likewise.
* testsuite/20_util/scoped_allocator/65279.cc: Likewise.
* testsuite/20_util/scoped_allocator/69293_neg.cc: Likewise.
* testsuite/20_util/scoped_allocator/construct_pair.cc:
Likewise.
* testsuite/20_util/scoped_allocator/dr2586.cc: Likewise.
* testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc:
Likewise.
* testsuite/20_util/shared_ptr/assign/assign.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/auto_ptr.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc:
Likewise.
* testsuite/20_util/shared_ptr/assign/dr541.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/move.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/sfinae.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/shared_ptr.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc:
Likewise.
* testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc:
Likewise.
* testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc:
Likewise.
* testsuite/20_util/shared_ptr/atomic/1.cc: Likewise.
* testsuite/20_util/shared_ptr/atomic/2.cc: Likewise.
* testsuite/20_util/shared_ptr/casts/1.cc: Likewise.
* testsuite/20_util/shared_ptr/casts/reinterpret.cc: Likewise.
* testsuite/20_util/shared_ptr/casts/rval.cc: Likewise.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/shared_ptr/comparison/86537.cc: Likewise.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Likewise.
* testsuite/20_util/shared_ptr/comparison/cmp_c++20.cc:
Likewise.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/shared_ptr/comparison/less.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/39405.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/46910.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/51365.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/52924.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/55123.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/58659.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/58839.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/61036.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/79467.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/80229.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/alias-rval.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/alias.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/array.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/auto_ptr.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/copy.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/deduction.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/default.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/lwg2802.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/lwg3548.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/move.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/noexcept_move_construct.cc:
Likewise.
* testsuite/20_util/shared_ptr/cons/nullptr.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/pointer.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc:
Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc:
Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc:
Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc:
Likewise.
* testsuite/20_util/shared_ptr/cons/void_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/weak_ptr.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/36949.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc:
Likewise.
* testsuite/20_util/shared_ptr/creation/58594.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/87278.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/92878_92947.cc:
Likewise.
* testsuite/20_util/shared_ptr/creation/99006.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/dr402.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/dr925.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/make.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/no_rtti.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/overwrite.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/private.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/single_allocation.cc:
Likewise.
* testsuite/20_util/shared_ptr/creation/single_allocation_no_rtti.cc:
Likewise.
* testsuite/20_util/shared_ptr/creation/version.cc: Likewise.
* testsuite/20_util/shared_ptr/dest/dest.cc: Likewise.
* testsuite/20_util/shared_ptr/hash/1.cc: Likewise.
* testsuite/20_util/shared_ptr/misc/24595.cc: Likewise.
* testsuite/20_util/shared_ptr/misc/42019.cc: Likewise.
* testsuite/20_util/shared_ptr/misc/get_deleter.cc: Likewise.
* testsuite/20_util/shared_ptr/misc/swap.cc: Likewise.
* testsuite/20_util/shared_ptr/modifiers/reset.cc: Likewise.
* testsuite/20_util/shared_ptr/modifiers/reset_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/modifiers/reset_sfinae.cc:
Likewise.
* testsuite/20_util/shared_ptr/modifiers/swap.cc: Likewise.
* testsuite/20_util/shared_ptr/modifiers/swap_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/observers/array.cc: Likewise.
* testsuite/20_util/shared_ptr/observers/bool_conv.cc: Likewise.
* testsuite/20_util/shared_ptr/observers/get.cc: Likewise.
* testsuite/20_util/shared_ptr/observers/owner_before.cc:
Likewise.
* testsuite/20_util/shared_ptr/observers/unique.cc: Likewise.
* testsuite/20_util/shared_ptr/observers/use_count.cc: Likewise.
* testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/20_util/shared_ptr/requirements/weak_type.cc:
Likewise.
* testsuite/20_util/specialized_algorithms/construct_at/95788.cc:
Likewise.
* testsuite/20_util/temporary_buffer.cc: Likewise.
* testsuite/20_util/tuple/48476.cc: Likewise.
* testsuite/20_util/tuple/cons/90700.cc: Likewise.
* testsuite/20_util/tuple/cons/96803.cc: Likewise.
* testsuite/20_util/tuple/cons/allocator_with_any.cc: Likewise.
* testsuite/20_util/tuple/cons/allocators.cc: Likewise.
* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:
Likewise.
* testsuite/20_util/tuple/cons/explicit_construct.cc: Likewise.
* testsuite/20_util/tuple/p2321r2.cc: Likewise.
* testsuite/20_util/unique_ptr/creation/92878_92947.cc:
Likewise.
* testsuite/20_util/unique_ptr/creation/array.cc: Likewise.
* testsuite/20_util/unique_ptr/creation/array_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/creation/constexpr.cc: Likewise.
* testsuite/20_util/unique_ptr/creation/for_overwrite.cc:
Likewise.
* testsuite/20_util/unique_ptr/creation/for_overwrite__neg.cc:
Likewise.
* testsuite/20_util/unique_ptr/creation/single.cc: Likewise.
* testsuite/20_util/uses_allocator/69293_neg.cc: Likewise.
* testsuite/20_util/uses_allocator/92878_92947.cc: Likewise.
* testsuite/20_util/uses_allocator/uninitialized_construct.cc:
Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.
* testsuite/20_util/weak_ptr/cons/deduction.cc: Likewise.
* testsuite/20_util/weak_ptr/cons/noexcept_move_construct.cc:
Likewise.
* testsuite/20_util/weak_ptr/lock/1.cc: Likewise.
* testsuite/20_util/weak_ptr/observers/owner_before.cc:
Likewise.
* testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/21_strings/basic_string/version.cc: Likewise.
* testsuite/21_strings/basic_string_view/operations/contains/char/2.cc:
Likewise.
* testsuite/21_strings/c_strings/char/69626.cc: Likewise.
* testsuite/21_strings/char_traits/requirements/version.cc:
Likewise.
* testsuite/23_containers/vector/requirements/version.cc:
Likewise.
* testsuite/24_iterators/back_insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/front_insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istream_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/92285.cc: Likewise.
* testsuite/24_iterators/istreambuf_iterator/cons/sentinel.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/requirements/dr445.cc:
Likewise.
* testsuite/24_iterators/ostream_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/ostreambuf_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/25_algorithms/constexpr_macro.cc: Likewise.
* testsuite/25_algorithms/equal/constrained.cc: Likewise.
* testsuite/25_algorithms/headers/cstdlib/functions_std.cc:
Likewise.
* testsuite/25_algorithms/inplace_merge/1.cc: Likewise.
* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
Likewise.
* testsuite/25_algorithms/make_heap/movable.cc: Likewise.
* testsuite/25_algorithms/pstl/feature_test-4.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/1.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/sort/35588.cc: Likewise.
* testsuite/25_algorithms/stable_partition/1.cc: Likewise.
* testsuite/25_algorithms/stable_partition/constrained.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/mem_check.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/moveable.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/stable_sort/1.cc: Likewise.
* testsuite/26_numerics/complex/2.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/13943.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/2190.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/60401.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/dr2192.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/dr2192_neg.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/dr2735.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/functions_std.cc:
Likewise.
* testsuite/26_numerics/headers/cstdlib/macros.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/types_std.cc: Likewise.
* testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc:
Likewise.
* testsuite/26_numerics/lerp/version.cc: Likewise.
* testsuite/26_numerics/midpoint/version.cc: Likewise.
* testsuite/27_io/basic_syncbuf/2.cc: Likewise.
* testsuite/27_io/basic_syncstream/2.cc: Likewise.
* testsuite/27_io/fpos/14320-1.cc: Likewise.
* testsuite/27_io/fpos/14320-2.cc: Likewise.
* testsuite/27_io/fpos/14320-3.cc: Likewise.
* testsuite/27_io/fpos/14320-4.cc: Likewise.
* testsuite/27_io/spanstream/version.cc: Likewise.
* testsuite/29_atomics/atomic/lwg3220.cc: Likewise.
* testsuite/29_atomics/atomic/operators/51811.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/1.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/102994.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/2.cc: Likewise.
* testsuite/29_atomics/headers/stdatomic.h/version.cc: Likewise.
* testsuite/30_threads/barrier/2.cc: Likewise.
* testsuite/30_threads/condition_variable_any/stop_token/2.cc:
Likewise.
* testsuite/30_threads/jthread/version.cc: Likewise.
* testsuite/30_threads/latch/2.cc: Likewise.
* testsuite/30_threads/semaphore/2.cc: Likewise.
* testsuite/30_threads/stop_token/2.cc: Likewise.
* testsuite/abi/pr42230.cc: Likewise.
* testsuite/ext/shared_ptr/1.cc: Likewise.
* testsuite/libstdc++-xmethods/shared_ptr.cc: Likewise.
* testsuite/std/ranges/adaptors/lazy_split_neg.cc: Likewise.
* testsuite/std/ranges/adaptors/p1739.cc: Likewise.
* testsuite/std/ranges/iota/lwg3292_neg.cc: Likewise.
* testsuite/std/ranges/p2325.cc: Likewise.

2 years agolibstdc++: Enable std::bitset<N>::bitset(const char*) for freestanding
Jonathan Wakely [Fri, 30 Sep 2022 12:36:30 +0000 (13:36 +0100)]
libstdc++: Enable std::bitset<N>::bitset(const char*) for freestanding

The std::bitset constructor from a character string is specified in
terms of std::basic_string and std::char_traits, but doesn't need to be.
This makes it available for freestanding.

libstdc++-v3/ChangeLog:

* include/std/bitset (bitset(const C*, size_type n, C, C))
[!_GLIBCXX_HOSTED]: Remove std::basic_string dependency.
(_M_copy_from_ptr) [!_GLIBCXX_HOSTED]: Abort instead of
throwing.

2 years agolibstdc++: Re-enable std::hash<std::bitset> in freestanding [PR103626]
Arsen Arsenović [Wed, 28 Sep 2022 19:30:11 +0000 (21:30 +0200)]
libstdc++: Re-enable std::hash<std::bitset> in freestanding [PR103626]

PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding

libstdc++-v3/ChangeLog:

PR libstdc++/103626
* include/std/bitset [!_GLIBCXX_HOSTED]: Re-enable std::hash.
* testsuite/20_util/bitset/cons/constexpr_c++23.cc: Require ET
hosted.
* testsuite/20_util/bitset/ext/constexpr.cc: Likewise.

2 years agolibstdc++: Add effective-target 'hosted' for testsuite [PR103626]
Jonathan Wakely [Fri, 30 Sep 2022 14:58:31 +0000 (16:58 +0200)]
libstdc++: Add effective-target 'hosted' for testsuite [PR103626]

PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding

libstdc++-v3/ChangeLog:

PR libstdc++/103626
* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
Also require hosted.
(check_effective_target_hosted): New proc.

2 years agolibstdc++: Make some tests work on freestanding [PR103626]
Arsen Arsenović [Fri, 30 Sep 2022 14:53:18 +0000 (16:53 +0200)]
libstdc++: Make some tests work on freestanding [PR103626]

PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/103626
* testsuite/17_intro/headers/c++1998/stdc++.cc [!__STDC_HOSTED__]:
Do not include C headers that aren't valid for freestanding.
* testsuite/17_intro/tag_type_explicit_ctor.cc [!__STDC_HOSTED__]:
Do not test tag types that aren't defined for freestanding.
* testsuite/18_support/headers/cstdlib/functions_std.cc: Do not
check for std::getenv and std::system for freestanding.
* testsuite/17_intro/using_namespace_std_exp_neg.cc [!__STDC_HOSTED__]:
Do not test hosted parts of the standard library.
* testsuite/17_intro/using_namespace_std_tr1_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/members/rebind_alloc.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc [!HOSTED]:
Likewise.
* testsuite/20_util/headers/bitset/synopsis.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/pointer_traits/requirements/typedefs.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/tuple/cons/deduction.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/25_algorithms/move/93872.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/std/ranges/adaptors/100577.cc [!__STDC_HOSTED__]: Likewise.

2 years agolibstdc++: Rework how freestanding install works [PR106953]
Arsen Arsenović [Fri, 16 Sep 2022 08:38:41 +0000 (10:38 +0200)]
libstdc++: Rework how freestanding install works [PR106953]

In light of there being far more freestanding headers now, ad-hoc
maintenance of a subset of the install implementation has become
unsustainable. Instead, we gate off a part of the normal install routine
so that it works without HOSTED enabled, as well as subdivide lists of
headers into freestanding and hosted components, according to the HOSTED
flag.

libstdc++-v3/ChangeLog:

PR libstdc++/106953
* include/Makefile.am [!_GLIBCXX_HOSTED]: Remove
install-freestanding-headers, unifying it with the usual
install-headers
* include/Makefile.in: Regenerate.

2 years agolibstdc++: Mark headers that must be hosted as such [PR103626]
Arsen Arsenović [Mon, 19 Sep 2022 19:54:49 +0000 (21:54 +0200)]
libstdc++: Mark headers that must be hosted as such [PR103626]

PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/103626
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/requires_hosted.h: New header.
* include/experimental/algorithm: Include
<bits/requires_hosted.h>.
* include/experimental/any: Likewise.
* include/experimental/array: Likewise.
* include/experimental/buffer: Likewise.
* include/experimental/chrono: Likewise.
* include/experimental/deque: Likewise.
* include/experimental/executor: Likewise.
* include/experimental/filesystem: Likewise.
* include/experimental/forward_list: Likewise.
* include/experimental/functional: Likewise.
* include/experimental/internet: Likewise.
* include/experimental/io_context: Likewise.
* include/experimental/iterator: Likewise.
* include/experimental/list: Likewise.
* include/experimental/map: Likewise.
* include/experimental/memory: Likewise.
* include/experimental/memory_resource: Likewise.
* include/experimental/net: Likewise.
* include/experimental/netfwd: Likewise.
* include/experimental/numeric: Likewise.
* include/experimental/optional: Likewise.
* include/experimental/propagate_const: Likewise.
* include/experimental/random: Likewise.
* include/experimental/ratio: Likewise.
* include/experimental/regex: Likewise.
* include/experimental/scope: Likewise.
* include/experimental/set: Likewise.
* include/experimental/simd: Likewise.
* include/experimental/socket: Likewise.
* include/experimental/source_location: Likewise.
* include/experimental/string: Likewise.
* include/experimental/string_view: Likewise.
* include/experimental/system_error: Likewise.
* include/experimental/timer: Likewise.
* include/experimental/tuple: Likewise.
* include/experimental/unordered_map: Likewise.
* include/experimental/unordered_set: Likewise.
* include/experimental/utility: Likewise.
* include/experimental/vector: Likewise.
* include/std/barrier: Likewise.
* include/std/chrono: Likewise.
* include/std/condition_variable: Likewise.
* include/std/deque: Likewise.
* include/std/execution: Likewise.
* include/std/filesystem: Likewise.
* include/std/forward_list: Likewise.
* include/std/fstream: Likewise.
* include/std/future: Likewise.
* include/std/iomanip: Likewise.
* include/std/ios: Likewise.
* include/std/iosfwd: Likewise.
* include/std/iostream: Likewise.
* include/std/istream: Likewise.
* include/std/latch: Likewise.
* include/std/list: Likewise.
* include/std/locale: Likewise.
* include/std/map: Likewise.
* include/std/memory_resource: Likewise.
* include/std/mutex: Likewise.
* include/std/ostream: Likewise.
* include/std/queue: Likewise.
* include/std/random: Likewise.
* include/std/regex: Likewise.
* include/std/semaphore: Likewise.
* include/std/set: Likewise.
* include/std/shared_mutex: Likewise.
* include/std/spanstream: Likewise.
* include/std/sstream: Likewise.
* include/std/stack: Likewise.
* include/std/stacktrace: Likewise.
* include/std/stop_token: Likewise.
* include/std/streambuf: Likewise.
* include/std/string: Likewise.
* include/std/syncstream: Likewise.
* include/std/system_error: Likewise.
* include/std/thread: Likewise.
* include/std/unordered_map: Likewise.
* include/std/unordered_set: Likewise.
* include/std/valarray: Likewise.
* include/std/vector: Likewise.
* include/tr1/array: Likewise.
* include/tr1/ccomplex: Likewise.
* include/tr1/cctype: Likewise.
* include/tr1/cfenv: Likewise.
* include/tr1/cfloat: Likewise.
* include/tr1/cinttypes: Likewise.
* include/tr1/climits: Likewise.
* include/tr1/cmath: Likewise.
* include/tr1/complex: Likewise.
* include/tr1/complex.h: Likewise.
* include/tr1/cstdarg: Likewise.
* include/tr1/cstdbool: Likewise.
* include/tr1/cstdint: Likewise.
* include/tr1/cstdio: Likewise.
* include/tr1/cstdlib: Likewise.
* include/tr1/ctgmath: Likewise.
* include/tr1/ctime: Likewise.
* include/tr1/ctype.h: Likewise.
* include/tr1/cwchar: Likewise.
* include/tr1/cwctype: Likewise.
* include/tr1/fenv.h: Likewise.
* include/tr1/float.h: Likewise.
* include/tr1/functional: Likewise.
* include/tr1/inttypes.h: Likewise.
* include/tr1/limits.h: Likewise.
* include/tr1/math.h: Likewise.
* include/tr1/memory: Likewise.
* include/tr1/random: Likewise.
* include/tr1/regex: Likewise.
* include/tr1/stdarg.h: Likewise.
* include/tr1/stdbool.h: Likewise.
* include/tr1/stdint.h: Likewise.
* include/tr1/stdio.h: Likewise.
* include/tr1/stdlib.h: Likewise.
* include/tr1/tgmath.h: Likewise.
* include/tr1/tuple: Likewise.
* include/tr1/type_traits: Likewise.
* include/tr1/unordered_map: Likewise.
* include/tr1/unordered_set: Likewise.
* include/tr1/utility: Likewise.
* include/tr1/wchar.h: Likewise.
* include/tr1/wctype.h: Likewise.
* include/c_global/cmath: Likewise.
* include/ext/algorithm: Include <bits/requires_hosted.h>.
* include/ext/bitmap_allocator.h: Likewise.
* include/ext/cmath: Likewise.
* include/ext/codecvt_specializations.h: Likewise.
* include/ext/debug_allocator.h: Likewise.
* include/ext/enc_filebuf.h: Likewise.
* include/ext/extptr_allocator.h: Likewise.
* include/ext/functional: Likewise.
* include/ext/malloc_allocator.h: Likewise.
* include/ext/memory: Likewise.
* include/ext/mt_allocator.h: Likewise.
* include/ext/new_allocator.h: Likewise.
* include/ext/numeric: Likewise.
* include/ext/pod_char_traits.h: Likewise.
* include/ext/pool_allocator.h: Likewise.
* include/ext/random: Likewise.
* include/ext/random.tcc: Likewise.
* include/ext/rb_tree: Likewise.
* include/ext/rc_string_base.h: Likewise.
* include/ext/rope: Likewise.
* include/ext/ropeimpl.h: Likewise.
* include/ext/slist: Likewise.
* include/ext/sso_string_base.h: Likewise.
* include/ext/stdio_filebuf.h: Likewise.
* include/ext/stdio_sync_filebuf.h: Likewise.
* include/ext/string_conversions.h: Likewise.
* include/ext/throw_allocator.h: Likewise.
* include/ext/vstring.h: Likewise.
* include/ext/vstring.tcc: Likewise.
* include/ext/vstring_fwd.h: Likewise.
* include/ext/vstring_util.h: Likewise.
* include/std/charconv: Likewise.
(__cpp_lib_to_chars): Do not define for freestanding.
* include/std/version: Adjust which macros get defined in
freestanding.
* include/ext/pointer.h [!_GLIBCXX_HOSTED]: Omit iostream
functionality from freestanding.
* include/std/algorithm [!_GLIBCXX_HOSTED]: Omit PSTL algos.
* include/std/memory [!_GLIBCXX_HOSTED]: Omit
<bits/stl_tempbuf.h> in freestanding
* include/bits/algorithmfwd.h [!_GLIBCXX_HOSTED]: Omit leftover
random_shuffle and stable_partition definition.
* include/bits/stl_algo.h [!_GLIBCXX_HOSTED]: Omit
random_shuffle and stable_partition from freestanding.
* include/bits/ranges_algo.h [!_GLIBCXX_HOSTED]: Omit
stable_partition from freestanding.
* include/bits/concept_check.h: Remove needless HOSTED check.
* include/std/iterator: Include <bits/ranges_base.h>.
* include/std/numeric (__cpp_lib_parallel_algorithms): Do not
define for freestanding.
* include/std/functional (__cpp_lib_boyer_moore_searcher):
Likewise.
* testsuite/lib/prune.exp: Match error for hosted-only libstdc++
tests.

2 years agolibstdc++: Adjust precompiled headers for freestanding
Jonathan Wakely [Tue, 20 Sep 2022 12:30:43 +0000 (13:30 +0100)]
libstdc++: Adjust precompiled headers for freestanding

Co-authored-by: Arsen Arsenović <arsen@aarsen.me>
libstdc++-v3/ChangeLog:

* include/precompiled/extc++.h [!_GLIBCXX_HOSTED]: Do not
include headers that aren't valid for freestanding.
* include/precompiled/stdc++.h [!_GLIBCXX_HOSTED]: Likewise.

2 years agolibstdc++: Filter out unconditional <stdio.h> default include
Arsen Arsenović [Tue, 27 Sep 2022 10:20:33 +0000 (12:20 +0200)]
libstdc++: Filter out unconditional <stdio.h> default include

_AC_INCLUDES_DEFAULT_REQUIREMENTS including <stdio.h> when checking for
stdint.h has prevented proper detection of whether stdint.h is present,
since it'd poison the cache variables with test results failing due to
<stdio.h> failing to include. As a solution, for autoconf versions under
2.70, we filter out that bit of code from ac_includes_default.

This issue was fixed in autoconf-2.70.
This also applies to various other headers, but was noticed when looking
into why HAVE_STDINT_H was misdefined.

libstdc++-v3/ChangeLog:

* configure.ac: Remove any lines that unconditionally include
<stdio.h> from ac_includes_default, when running Autoconf <2.70.
* configure: Regenerate.

2 years agolibstdc++: Make _GLIBCXX_HOSTED respect -ffreestanding [PR103626]
Jonathan Wakely [Tue, 20 Sep 2022 10:57:28 +0000 (11:57 +0100)]
libstdc++: Make _GLIBCXX_HOSTED respect -ffreestanding [PR103626]

This allows the library to switch to freestanding mode when compiling
with the -ffreestanding flag. This means you don't need a separate
libstdc++ build configured with --disable-hosted-libstdcxx in order to
compile for a freestanding environment.

The testsuite support files cannot be compiled for freestanding, so add
-fno-freestanding to override any -ffreestanding in the test flags.

libstdc++-v3/ChangeLog:

PR libstdc++/103626
* acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Define _GLIBCXX_HOSTED
to __STDC_HOSTED__ for non-freestanding installations.
* configure: Regenerate.
* include/Makefile.am (${host_builddir}/c++config.h): Adjust
grep pattern.
* include/Makefile.in: Regenerate.
* testsuite/lib/libstdc++.exp (v3-build_support): Use
-fno-freestanding.
* testsuite/libstdc++-abi/abi.exp: Likewise.

2 years agolibsanitizer: Fix Solaris 11.3 compilation of sanitizer_procmaps_solaris.cpp [PR105531]
Rainer Orth [Mon, 3 Oct 2022 14:28:46 +0000 (16:28 +0200)]
libsanitizer: Fix Solaris 11.3 compilation of sanitizer_procmaps_solaris.cpp [PR105531]

The latest libsanitizer import broke Solaris 11.3 bootstrap again, due
to an oversight of mine.  A fix has been committed upstream

https://reviews.llvm.org/D133556

This patch cherry-picks it.  Tested on Solaris 11.3 and 11.4, SPARC and
x86.

2022-09-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libsanitizer:
PR sanitizer/105531
* sanitizer_common/sanitizer_procmaps_solaris.cpp: Cherry-pick
llvm-project revision 1cd4d63fb9ab0f04c7151911dde0d58b673823de.

2 years agovect: while_ult for integer masks
Andrew Stubbs [Fri, 2 Oct 2020 14:12:50 +0000 (15:12 +0100)]
vect: while_ult for integer masks

Add a vector length parameter needed by amdgcn without breaking aarch64.

All amdgcn vector masks are DImode, regardless of vector length, so we can't
tell what length is implied simply from the operator mode.  (Even if we used
different integer modes there's no mode small enough to differenciate a 2 or
4 lane mask).  Without knowing the intended length we end up using a mask with
too many lanes enabled, which leads to undefined behaviour..

The extra operand is not added for vector mask types so AArch64 does not need
to be adjusted.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (while_ultsidi): Limit mask length using
operand 3.
* doc/md.texi (while_ult): Document new operand 3 usage.
* internal-fn.cc (expand_while_optab_fn): Set operand 3 when lhs_type
maps to a non-vector mode.

2 years agoDon't process undefined range.
Andrew MacLeod [Sun, 2 Oct 2022 22:43:35 +0000 (18:43 -0400)]
Don't process undefined range.

No need to continue processing an undefined range.

gcc/
PR tree-optimization/107109
* range-op.cc (adjust_op1_for_overflow): Don't process undefined.
gcc/testsuite/
* gcc.dg/pr107109.c: New.

2 years agoarm: Add missing early clobber to MVE vrev64q_m patterns
Christophe Lyon [Mon, 3 Oct 2022 10:26:03 +0000 (12:26 +0200)]
arm: Add missing early clobber to MVE vrev64q_m patterns

Like the non-predicated vrev64q patterns, mve_vrev64q_m_<supf><mode>
and mve_vrev64q_m_f<mode> need an early clobber constraint, otherwise
we can generate an unpredictable instruction:

Warning: 64-bit element size and same destination and source operands makes instruction UNPREDICTABLE
when calling vrevq64_m* with the same first and second arguments.

OK for trunk?

Thanks,

Christophe

gcc/ChangeLog:

* config/arm/mve.md (mve_vrev64q_m_<supf><mode>): Add early
clobber.
(mve_vrev64q_m_f<mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/intrinsics/vrev64q_m_s16-clobber.c: New test.

2 years agoc: Adjust LDBL_EPSILON for C2x for IBM long double
Joseph Myers [Mon, 3 Oct 2022 13:10:42 +0000 (13:10 +0000)]
c: Adjust LDBL_EPSILON for C2x for IBM long double

C2x changes the <float.h> definition of *_EPSILON to apply only to
normalized numbers.  The effect is that LDBL_EPSILON for IBM long
double becomes 0x1p-105L instead of 0x1p-1074L.

There is a reasonable case for considering this a defect fix - it
originated from the issue reporting process (DR#467), though it ended
up being resolved by a paper (N2326) for C2x rather than through the
issue process, and code using *_EPSILON often needs to override the
pre-C2x value of LDBL_EPSILON and use something on the order of
magnitude of the C2x value instead.  However, I've followed the
conservative approach of only making the change for C2x and not for
previous standard versions (and not for C++, which doesn't have the
C2x changes in this area).

The testcases added are intended to be valid for all long double
formats.  The C11 one is based on
gcc.target/powerpc/rs6000-ldouble-2.c (and when we move to a C2x
default, gcc.target/powerpc/rs6000-ldouble-2.c will need an
appropriate option added to keep using an older language version).

Tested with no regressions for cross to powerpc-linux-gnu.

gcc/c-family/
* c-cppbuiltin.cc (builtin_define_float_constants): Do not
special-case __*_EPSILON__ setting for IBM long double for C2x.

gcc/testsuite/
* gcc.dg/c11-float-7.c, gcc.dg/c2x-float-12.c: New tests.

2 years agolibstdc++: Fix tests broken by C++23 P2266R3 "Simpler implicit move"
Jonathan Wakely [Mon, 3 Oct 2022 11:10:07 +0000 (12:10 +0100)]
libstdc++: Fix tests broken by C++23 P2266R3 "Simpler implicit move"

In C++23 mode these tests started to FAIL because an rvalue reference
parameter can no longer be bound to an lvalue reference return type. As
confirmed by Ville (who added these tests) the problem overloads are not
intended to be called, and only exist to verify that they don't
interfere with the intended behaviour. This changes the function bodies
to just throw, so that the tests will fail if the function is called.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_ostream/inserters_other/char/6.cc:
Change body of unused operator<< overload to throw if called.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc:
Likewise.

2 years agoDo not pessimize range in set_nonzero_bits.
Aldy Hernandez [Sun, 2 Oct 2022 08:46:47 +0000 (10:46 +0200)]
Do not pessimize range in set_nonzero_bits.

Currently if we have a range of [0,0] and we set the nonzero bits to
1, the current code pessimizes the range to [0,1] because it assumes
the range is [1,1] plus the possibility of 0.  This fixes the
oversight.

gcc/ChangeLog:

* value-range.cc (irange::set_nonzero_bits): Do not pessimize range.
(range_tests_nonzero_bits): New test.

2 years agoAvoid comparing ranges when sub-ranges is 0.
Aldy Hernandez [Sat, 1 Oct 2022 20:31:34 +0000 (22:31 +0200)]
Avoid comparing ranges when sub-ranges is 0.

There is nothing else to compare when the number of sub-ranges is 0.

gcc/ChangeLog:

* value-range.cc (irange::operator==): Early bail on m_num_ranges
equal to 0.

2 years agoDo not compare nonzero masks for varying.
Aldy Hernandez [Sat, 1 Oct 2022 20:25:52 +0000 (22:25 +0200)]
Do not compare nonzero masks for varying.

There is no need to compare nonzero masks when comparing two VARYING
ranges, as they are always the same when range types are the same.

gcc/ChangeLog:

* value-range.cc (irange::legacy_equal_p): Remove nonozero mask
check when comparing VR_VARYING ranges.

2 years agoDo not compare incompatible ranges in ipa-prop.
Aldy Hernandez [Sat, 1 Oct 2022 20:20:49 +0000 (22:20 +0200)]
Do not compare incompatible ranges in ipa-prop.

gcc/ChangeLog:

* ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Do not compare
incompatible ranges in ipa-prop.

2 years agoFortran: fix testcases
Francois-Xavier Coudert [Mon, 3 Oct 2022 07:24:10 +0000 (09:24 +0200)]
Fortran: fix testcases

Remove unreliable test for IEEE_FMA(), which fails on powerpc.
Adjust stop codes for modes_1.f90.

2022-10-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

gcc/testsuite/

PR fortran/107062
* gfortran.dg/ieee/fma_1.f90: Fix test.
* gfortran.dg/ieee/modes_1.f90: Fix test.

2 years agolibstdc++: Fix gdb pretty printers when dealing with std::string
François Dumont [Mon, 26 Sep 2022 17:14:54 +0000 (19:14 +0200)]
libstdc++: Fix gdb pretty printers when dealing with std::string

Since revision 33b43b0d8cd2de722d177ef823930500948a7487 std::string and other
similar typedef are ambiguous from a gdb point of view because it matches both
std::basic_string<char> and std::__cxx11::basic_string<char> symbols. For those
typedef add a workaround to accept the substitution as long as the same regardless
of __cxx11 namespace.

Also avoid to register printers for types in std::__cxx11::__8:: namespace, there is
no such symbols.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (Printer.add_version): Do not add version
namespace for __cxx11 symbols.
(add_one_template_type_printer): Likewise.
(add_one_type_printer): Likewise.
(FilteringTypePrinter._recognizer.recognize): Add a workaround for std::string & al
ambiguous typedef matching both std:: and std::__cxx11:: symbols.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Remove obsolete
\#define _GLIBCXX_USE_CXX11_ABI 0.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise. Adapt test to accept
std::__cxx11::list.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/libstdc++-prettyprinters/80276.cc: Likewise and remove xfail for c++20
and debug mode.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.

2 years agoDaily bump.
GCC Administrator [Mon, 3 Oct 2022 00:17:44 +0000 (00:17 +0000)]
Daily bump.

2 years agotree-cfg: Fix a verification diagnostic typo [PR107121]
Jakub Jelinek [Sun, 2 Oct 2022 14:42:32 +0000 (16:42 +0200)]
tree-cfg: Fix a verification diagnostic typo [PR107121]

Obvious typo in diagnostics.

2022-10-02  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/107121
* tree-cfg.cc (verify_gimple_call): Fix a typo in diagnostics,
DEFFERED_INIT -> DEFERRED_INIT.

2 years agoAdjust LIBGCC2_INCLUDES for VxWorks and augment comment
Olivier Hainque [Mon, 7 Mar 2022 10:55:29 +0000 (10:55 +0000)]
Adjust LIBGCC2_INCLUDES for VxWorks and augment comment

Investigating the reasons for libgcc build failures in a canadian
context, orthogonally to the recent update of vxcrtstuff, exposed
interesting differences in the way include search paths are managed
between a regular Linux->VxWorks cross build and a canadian setup
building a Windows->VxWorks toolchain in a Linux environment.

This change augments the comment attached to LIBGCC2_INCLUDE in
libgcc/config/t-vxworks to better describe the parameters at play.

It also adjusts the addition of options for gcc/include and
gcc/include-fixed to minimize the actual differences for libgcc
in the two kinds of configurations.

2022-03-06  Olivier Hainque  <hainque@adacore.com>

libgcc/
* config/t-vxworks (LIBGCC2_INCLUDE): Augment comment.  Move
-I options for gcc/include and gcc/include-fixed at the end
and make them -isystem.

2 years agoDefine GCC_DRIVER_HOST_INITIALIZATION for VxWorks targets
Marc Poulhiès [Tue, 4 Jan 2022 14:56:27 +0000 (14:56 +0000)]
Define GCC_DRIVER_HOST_INITIALIZATION for VxWorks targets

We need to perform static links by default on VxWorks, where the use
of shared libraries involves unusual steps compared to standard native
systems.

This has to be conveyed before the lang_specific_driver code gets
invoked (in particular for g++), so specs aren't available.

This change defines the GCC_DRIVER_HOST_INITIALIZATION macro for
VxWorks, to insert a -static option in case the user hasn't provided any
explicit indication on the command line of the kind of link desired.

While a HOST macro doesn't seem appropriate to control a target OS
driven behavior, this matches other uses and won't conflict as VxWorks
is not supported on any of the other configurations using this macro.

gcc/
* config/vxworks-driver.cc: New.
* config.gcc (*vxworks*): Add vxworks-driver.o in extra_gcc_objs.
* config/t-vxworks: Add vxworks-driver.o.
* config/vxworks.h (GCC_DRIVER_HOST_INITIALIZATION): New.

2 years agoPrevent secondary warning from diagnostic tweak in gthr-vxworks.h
Olivier Hainque [Thu, 3 Feb 2022 15:57:32 +0000 (15:57 +0000)]
Prevent secondary warning from diagnostic tweak in gthr-vxworks.h

Within gthr-vxworks.h, we prevent C++ errors from missing
declarations in some system headers by prepending their inclusion
with a

    #pragma GCC diagnostic ignored "-Wstrict-prototypes"

But Wstrict-prototypes is internally registered as valid for
C/ObjC only, not C++, and this trick in turn triggers a Wpragma
warning with -Wsystem-headers.

This change just arranges to ignore the secondary warning locally.

2021-02-03  Olivier Hainque  <hainque@adacore.com>

* config/gthr-vxworks.h: Prevent Wpragma warning for the
pragma diagnostics on Wstrict-prototypes.

2 years agoRefine guard for vxworks crtstuff spec
Olivier Hainque [Thu, 10 Mar 2022 11:02:11 +0000 (11:02 +0000)]
Refine guard for vxworks crtstuff spec

Working on the reintroduction of shared libraries support
(and of modules depending on shared libraries) exposed a few
test failures of simple c++ constructor tests on arm-vxworks7r2.

Investigation revealed that we were not linking the
crtstuff objects as needed from a compiler configured not to
have shared libs support, because of the ENABLE_SHARED_LIBGCC
guard in this piece of vxworks.h:

  /* Setup the crtstuff begin/end we might need for dwarf EH registration
     and/or INITFINI_ARRAY support for shared libs.  */

  #if (HAVE_INITFINI_ARRAY_SUPPORT && defined(ENABLE_SHARED_LIBGCC)) \
      || (DWARF2_UNWIND_INFO && !defined(CONFIG_SJLJ_EXCEPTIONS))
  #define VX_CRTBEGIN_SPEC "%{!shared:vx_crtbegin.o%s;:vx_crtbeginS.o%s}"

crtstuff initfini array support is meant to be leveraged for
constructors regardless of whether the compiler also happens to be
configured with shared library support, so the guard on ENABLE_SHARED_LIBGCC
here is inappropriate.

This change just removes it,

2022-09-30  Olivier Hainque <hainque@adacore.com>

gcc/
* config/vxworks.h (VX_CRTBEGIN_SPEC, VX_CRTEND_SPEC): If
HAVE_INITFINI_ARRAY_SUPPORT, pick crtstuff objects regardless
of ENABLE_SHARED_LIBGCC.

2 years agoDaily bump.
GCC Administrator [Sun, 2 Oct 2022 00:18:17 +0000 (00:18 +0000)]
Daily bump.

2 years agoFortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]
José Rui Faustino de Sousa [Sun, 25 Sep 2022 20:48:55 +0000 (22:48 +0200)]
Fortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]

gcc/fortran/ChangeLog:

PR fortran/100040
PR fortran/100029
* trans-expr.cc (gfc_conv_class_to_class): Add code to have
assumed-rank arrays recognized as full arrays and fix the type
of the array assignment.
(gfc_conv_procedure_call): Change order of code blocks such that
the free of ALLOCATABLE dummy arguments with INTENT(OUT) occurs
first.

gcc/testsuite/ChangeLog:

PR fortran/100029
* gfortran.dg/PR100029.f90: New test.

PR fortran/100040
* gfortran.dg/PR100040.f90: New test.

2 years agoc++: make some cp_trait_kind switch statements exhaustive
Patrick Palka [Sat, 1 Oct 2022 16:21:36 +0000 (12:21 -0400)]
c++: make some cp_trait_kind switch statements exhaustive

This replaces the unreachable default case in some cp_trait_kind
switches with an exhaustive listing of the trait codes that we don't
expect to see, so that when adding a new trait we'll get a helpful
-Wswitch warning if we forget to handle the new trait in a relevant
switch.

gcc/cp/ChangeLog:

* semantics.cc (trait_expr_value): Make cp_trait_kind switch
statement exhaustive.
(finish_trait_expr): Likewise.
(finish_trait_type): Likewise.

2 years agoor1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS
Stafford Horne [Thu, 29 Sep 2022 14:32:39 +0000 (15:32 +0100)]
or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS

This was found when testing buildroot with linuxthreads enabled.  In
this case, the build passes --disable-tls to the toolchain during
configuration.  After building the OpenRISC toolchain it was still
generating TLS code sequences and causing linker failures such as:

 ..../or1k-buildroot-linux-uclibc-gcc -o gpsd-3.24/gpsctl .... -lusb-1.0 -lm -lrt -lnsl
 ..../ld: ..../sysroot/usr/lib/libusb-1.0.so: undefined reference to `__tls_get_addr'

This patch fixes this by disabling tls for the OpenRISC target when requested
via --disable-tls.

gcc/ChangeLog:

* config/or1k/or1k.cc (TARGET_HAVE_TLS): Only define if
HAVE_AS_TLS is defined.

Tested-by: Yann E. MORIN <yann.morin@orange.com>
2 years agoOpenACC: Fix struct-component-kind-1.c test
Julian Brown [Fri, 30 Sep 2022 17:30:58 +0000 (17:30 +0000)]
OpenACC: Fix struct-component-kind-1.c test

This patch is a minimal fix for the recently-added
struct-component-kind-1.c test (which is currently failing to emit one
of the errors it expects in scan output). This fragment was erroneously
omitted from the second version of the patch posted previously:

  https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602504.html

2022-10-01  Julian Brown  <julian@codesourcery.com>

gcc/
* gimplify.cc (omp_group_base): Fix IF_PRESENT (no_create)
handling.

2 years agoImprove Z flag handling on H8
Jeff Law [Sat, 1 Oct 2022 04:42:15 +0000 (00:42 -0400)]
Improve Z flag handling on H8

This patch improves handling of the Z bit in the status register in a
variety of ways to improve either the code size or code speed on various
H8 subtargets.

For example, we can test the zero/nonzero status of the upper byte of a
16 bit register using mov.b, we can move the Z or an inverted Z into a
QImode register profitably on some subtargets.  We can move Z or an
inverted Z into the sign bit on the H8/SX profitably, etc.

gcc/

* config/h8300/h8300.md (HSI2): New iterator.
(eqne_invert): Similarly.
* config/h8300/testcompare.md (testhi_upper_z): New pattern.
(cmpqi_z, cmphi_z, cmpsi_z): Likewise.
(store_z_qi, store_z_i_qi, store_z_hi, store_z_hi_sb): New
define_insn_and_splits and/or define_insns.
(store_z_hi_neg, store_z_hi_and, store_z_<mode>): Likewise.
(store_z_<mode>_neg, store_z_<mode>_and, store_z): Likewise.

2 years agoc++: loop through array CONSTRUCTOR
Jason Merrill [Tue, 20 Sep 2022 20:06:26 +0000 (16:06 -0400)]
c++: loop through array CONSTRUCTOR

I noticed that we were ignoring all the special rules for when to use a
simple INIT_EXPR for array initialization from a CONSTRUCTOR, because
split_nonconstant_init_1 was also passing 1 to the from_array parameter.
Arguably that's the real bug, but I think we can be flexible.

The test that I noticed this with no longer fails without it.

gcc/cp/ChangeLog:

* init.cc (build_vec_init): Clear from_array for CONSTRUCTOR
initializer.

2 years agoc++: cast split_nonconstant_init return val to void
Jason Merrill [Mon, 19 Sep 2022 17:17:41 +0000 (19:17 +0200)]
c++: cast split_nonconstant_init return val to void

We were already converting the result of expand_vec_init_expr to void; we
need to do the same for split_nonconstant_init.

The test that I noticed this with no longer fails without it.

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_genericize_init): Also convert the result of
split_nonconstant_init to void.

2 years agoInstall correct patch version.
Jeff Law [Sat, 1 Oct 2022 00:46:04 +0000 (20:46 -0400)]
Install correct patch version.

gcc/
* tree-ssa-dom.cc (record_edge_info): Install correct version of
patch.

2 years agoEmit discriminators for inlined call sites.
Eugene Rozenfeld [Thu, 21 Apr 2022 23:17:52 +0000 (16:17 -0700)]
Emit discriminators for inlined call sites.

This change is based on commit 9fa26998a63d4b22b637ed8702520819e408a694
by Dehao Chen in vendors/google/heads/gcc-4_8.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:

* dwarf2out.cc (add_call_src_coords_attributes): Emit discriminators for inlined call sites.

2 years agoDaily bump.
GCC Administrator [Sat, 1 Oct 2022 00:18:00 +0000 (00:18 +0000)]
Daily bump.

2 years agoMore gimple const/copy propagation opportunities
Jeff Law [Fri, 30 Sep 2022 23:26:31 +0000 (19:26 -0400)]
More gimple const/copy propagation opportunities

While investigating a benchmark for optimization opportunities I came across single block loop which either iterates precisely once or forever.    This is an interesting scenario as we can ignore the infinite looping path and treat any PHI nodes as degenerates.  So more concretely let's consider this trivial testcase:

volatile void abort (void);

void
foo(int a)
{
 int b = 0;

 while (1)
   {
     if (!a)
       break;
     b = 1;
   }

 if (b != 0)
   abort ();
}

Quick analysis shows that b's initial value is 0 and its value only changes if we enter an infinite loop.  So if we get to the test b != 0, the only possible value b could have would be 0 and the test and its true arm can be eliminated.

The DOM3 dump looks something like this:

;;   basic block 2, loop depth 0, count 118111600 (estimated locally), maybe hot
;;    prev block 0, next block 3, flags: (NEW, VISITED)
;;    pred:       ENTRY [always]  count:118111600 (estimated locally) (FALLTHRU,EXECUTABLE)
;;    succ:       3 [always]  count:118111600 (estimated locally) (FALLTHRU,EXECUTABLE)

;;   basic block 3, loop depth 1, count 1073741824 (estimated locally), maybe hot
;;    prev block 2, next block 4, flags: (NEW, VISITED)
;;    pred:       2 [always]  count:118111600 (estimated locally) (FALLTHRU,EXECUTABLE)
;;                3 [89.0% (guessed)]  count:955630224 (estimated locally) (FALSE_VALUE,EXECUTABLE)
  # b_1 = PHI <0(2), 1(3)>
  if (a_3(D) == 0)
    goto <bb 4>; [11.00%]
  else
    goto <bb 3>; [89.00%]
;;    succ:       4 [11.0% (guessed)]  count:118111600 (estimated locally) (TRUE_VALUE,EXECUTABLE)
;;                3 [89.0% (guessed)]  count:955630224 (estimated locally) (FALSE_VALUE,EXECUTABLE)

;;   basic block 4, loop depth 0, count 118111600 (estimated locally), maybe hot
;;    prev block 3, next block 5, flags: (NEW, VISITED)
;;    pred:       3 [11.0% (guessed)]  count:118111600 (estimated locally) (TRUE_VALUE,EXECUTABLE)
  if (b_1 != 0)
    goto <bb 5>; [0.00%]
  else
    goto <bb 6>; [100.00%]
;;    succ:       5 [never]  count:0 (precise) (TRUE_VALUE,EXECUTABLE)
;;                6 [always]  count:118111600 (estimated locally) (FALSE_VALUE,EXECUTABLE)

This is a good representative of what the benchmark code looks like.

The primary effect we want to capture is to realize that the test if (b_1 != 0) is always false and optimize it accordingly.

In the benchmark, this opportunity is well hidden until after the loop optimizers have completed, so the first chance to capture this case is in DOM3.  Furthermore, DOM wants loops normalized with latch blocks/edges.  So instead of bb3 looping back to itself, there's an intermediate empty block during DOM.

I originally thought this was likely to only affect the benchmark.  But when I instrumented the optimization and bootstrapped GCC, much to my surprise there were several hundred similar cases identified in GCC itself.  So it's not as benchmark specific as I'd initially feared.

Anyway, detecting this in DOM is pretty simple.   We detect the infinite loop, including the latch block.  Once we've done that, we walk the PHI nodes and attach equivalences to the appropriate outgoing edge.   That's all we need to do as the rest of DOM is already prepared to handle equivalences on edges.

gcc/
* tree-ssa-dom.cc (single_block_loop_p): New function.
(record_edge_info): Also record equivalences for the outgoing
edge of a single block loop where the condition is an invariant.

gcc/testsuite/
* gcc.dg/infinite-loop.c: New test.

2 years agoMinor cleanup/prep in DOM
Jeff Law [Fri, 30 Sep 2022 22:59:24 +0000 (18:59 -0400)]
Minor cleanup/prep in DOM

It's a bit weird that free_dom_edge_info leaves a dangling pointer in e->aux.
Not sure what I was thinking.

There's two callers.  One wipes e->aux immediately after the call, the other
attaches a newly created object immediately after the call.  So we can wipe
e->aux within the call and simplify one of the two call sites.

This is preparatory work for a minor optimization where we want to detect
another class of edge equivalences in DOM (until something better is available)
and either attach them an existing edge_info structure or create a new one if
one doesn't currently exist for a given edge.

gcc/
* tree-ssa-dom.cc (free_dom_edge_info): Clear e->aux too.
(free_all_edge_infos): Do not clear e->aux here.

2 years agoDocument -fexcess-precision=16 in target.def
H.J. Lu [Fri, 30 Sep 2022 22:51:18 +0000 (15:51 -0700)]
Document -fexcess-precision=16 in target.def

* target.def (TARGET_C_EXCESS_PRECISION): Document
-fexcess-precision=16.

2 years agoDocument -fexcess-precision=16 in tm.texi
Palmer Dabbelt [Fri, 9 Sep 2022 09:46:40 +0000 (02:46 -0700)]
Document -fexcess-precision=16 in tm.texi

I just happened to stuble on this one while trying to sort out the
RISC-V bits.

gcc/ChangeLog

* doc/tm.texi (TARGET_C_EXCESS_PRECISION): Add 16.

2 years agoRISC-V: Support -fexcess-precision=16
Palmer Dabbelt [Fri, 9 Sep 2022 09:43:26 +0000 (02:43 -0700)]
RISC-V: Support -fexcess-precision=16

This fixes f19a327077e ("Support -fexcess-precision=16 which will enable
FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 when backend supports _Float16.") on
RISC-V targets.

gcc/ChangeLog

PR target/106815
* config/riscv/riscv.cc (riscv_excess_precision): Add support
for EXCESS_PRECISION_TYPE_FLOAT16.

2 years agolibstdc++: Remove <sstream> dependency from std::bitset::to_ulong() test
Jonathan Wakely [Fri, 30 Sep 2022 14:54:19 +0000 (15:54 +0100)]
libstdc++: Remove <sstream> dependency from std::bitset::to_ulong() test

There's no need to use a stringstream to test the to_ulong() member.
This will allow the test to be used in freestanding mode.

libstdc++-v3/ChangeLog:

* testsuite/20_util/bitset/access/to_ulong.cc: Construct bitset
from binary literal instead of using stringstream.

2 years agolibstdc++: Optimize operator>> for std::bitset
Jonathan Wakely [Fri, 30 Sep 2022 16:06:15 +0000 (17:06 +0100)]
libstdc++: Optimize operator>> for std::bitset

We can improve performance by using a char buffer instead of
basic_string. The loop bound already means we can't overflow the buffer,
and we don't need to keep writing a null character after every character
written to the buffer.

We could just use basic_string::resize(N) to zero-init the whole string,
then overwrite those chars. But that zero-init of all N chars would be
wasted in the case where we are writing to a bitset<N> with large N, but
only end up extracting one or two chars from the stream.

With this change we just use buffer of uninitialized chars.  For a
small-ish bitset (currently <= 256) we can improve performance further
by using alloca instead of the heap.

libstdc++-v3/ChangeLog:

* include/std/bitset (operator>>): Use a simple buffer instead
of std::basic_string.

2 years agolibstdc++: Remove non-standard public members in std::bitset
Jonathan Wakely [Fri, 30 Sep 2022 13:57:24 +0000 (14:57 +0100)]
libstdc++: Remove non-standard public members in std::bitset

This makes _M_copy_from_ptr, _M_copy_from_string and _M_copy_to_string
private, and declares operator<< and operator>> as friends.

Also remove the historical _M_copy_from_string and _M_copy_to_string
overloads. Those were used before DR 396 was implemented but are
not needed now. There are no tests or docs describing them, so I don't
think we intend to support them as extensions.

libstdc++-v3/ChangeLog:

* include/std/bitset (_M_copy_from_ptr, _M_copy_from_string)
(_M_copy_to_string): Change access to private.
(_M_copy_from_string(const basic_string&, size_t, size_t)):
Remove.
(_M_copy_to_string(const basic_string&)): Remove.

2 years agolibstdc++: Fix broken dg-prune-output
Jonathan Wakely [Fri, 30 Sep 2022 18:10:29 +0000 (19:10 +0100)]
libstdc++: Fix broken dg-prune-output

The new pattern in the dg-prune-output directive doesn't work. Instead
of a messy regex full of leaning toothpicks, just match on the
diagnostic text instead of the header paths.

libstdc++-v3/ChangeLog:

* testsuite/20_util/bind/ref_neg.cc: Fix dg-prune-output
directive.