Age | Commit message (Collapse) | Author | Files | Lines |
|
gcc/analyzer/ChangeLog:
* engine.cc (class plugin_analyzer_init_impl): Convert
"m_checkers" to use std::vector of std::unique_ptr. Convert
"m_known_fn_mgr" to a reference.
(impl_run_checkers): Convert "checkers" to use std::vector of
std::unique_ptr and move it into the extrinsic_state.
* program-state.cc (extrinsic_state::dump_to_pp): Update for
changes to m_checkers.
(extrinsic_state::to_json): Likewise.
(extrinsic_state::get_sm_idx_by_name): Likewise.
(selftest::test_sm_state_map): Update to use std::unique_ptr
for state machines.
(selftest::test_program_state_1): Likewise.
(selftest::test_program_state_2): Likewise.
(selftest::test_program_state_merging): Likewise.
(selftest::test_program_state_merging_2): Likewise.
* program-state.h (class extrinsic_state): Convert "m_checkers" to
use std::vector of std::unique_ptr and to be owned by this object,
rather than a reference. Add ctor for use in selftests.
* sm-fd.cc (make_fd_state_machine): Update to use std::unique_ptr.
* sm-file.cc (make_fileptr_state_machine): Likewise.
* sm-malloc.cc (make_malloc_state_machine): Likewise.
* sm-pattern-test.cc (make_pattern_test_state_machine): Likewise.
* sm-sensitive.cc (make_sensitive_state_machine): Likewise.
* sm-signal.cc (make_signal_state_machine): Likewise.
* sm-taint.cc (make_taint_state_machine): Likewise.
* sm.cc: Define INCLUDE_LIST.
(make_checkers): Return the vector directly, rather than pass it
in by reference. Update to use std::unique_ptr throughout. Use
an intermediate list, and use that to filter with
flag_analyzer_checker, fixing memory leak for this case.
* sm.h: (make_checkers): Return the vector directly, rather than
pass it in by reference, and use std::vector of std::unique_ptr.
(make_malloc_state_machine): Convert return type to use std::unique_ptr.
(make_fileptr_state_machine): Likewise.
(make_taint_state_machine): Likewise.
(make_sensitive_state_machine): Likewise.
(make_signal_state_machine): Likewise.
(make_pattern_test_state_machine): Likewise.
(make_va_list_state_machine): Likewise.
(make_fd_state_machine): Likewise.
* varargs.cc (make_va_list_state_machine): Update to use
std::unique_ptr.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* call-summary.cc (call_summary_replay::call_summary_replay):
Convert "summary" from call_summary * to call_summary &.
(call_summary_replay::dump_to_pp): Likewise for m_summary.
* call-summary.h (call_summary_replay::call_summary_replay):
Likewise for "summary".
(call_summary_replay::m_summary): Likewise.
* engine.cc (call_summary_edge_info::call_summary_edge_info):
Likewise.
(call_summary_edge_info::update_state): Likewise.
(call_summary_edge_info::update_model): Likewise.
(call_summary_edge_info::print_desc): Likewise for m_summary.
(call_summary_edge_info::m_summary): Likewise.
(exploded_node::replay_call_summaries): Update for change to
replay_call_summary.
(exploded_node::replay_call_summary): Convert "summary" from
call_summary * to call_summary &.
* exploded-graph.h (exploded_node::replay_call_summary): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
* analyzer.cc: Convert gcall * to gcall & where we know the
pointer must be non-null.
* call-details.cc: Likewise.
* call-details.h: Likewise.
* call-info.cc: Likewise.
* call-info.h: Likewise.
* call-summary.h: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Likewise.
* common.h: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* kf-analyzer.cc: Likewise.
* kf-lang-cp.cc: Likewise.
* kf.cc: Likewise.
* known-function-manager.cc: Likewise.
* program-state.cc: Likewise.
* program-state.h: Likewise.
* region-model.cc: Likewise.
* region-model.h: Likewise.
* sm-fd.cc: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* sm.h: Likewise.
* store.cc: Likewise.
* store.h: Likewise.
* supergraph.cc: Likewise.
* supergraph.h: Likewise.
* svalue.h: Likewise.
* varargs.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc: Convert gcall * to gcall &
where we know the pointer must be non-null.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Modernization; no functional change intended.
gcc/analyzer/ChangeLog:
* access-diagram.cc: Convert enum access_direction to
"enum class".
* bounds-checking.cc: Likewise.
* checker-event.cc: Convert enum event_kind to "enum class".
* checker-event.h: Likewise.
* checker-path.cc: Likewise.
* common.h: Convert enum access_direction to "enum class".
* constraint-manager.cc: Convert enum bound_kind to "enum class".
* constraint-manager.h: Likewise.
* diagnostic-manager.cc: Convert enum event_kind to "enum class".
* engine.cc: Convert enum status to "enum class".
* exploded-graph.h: Likewise.
* infinite-loop.cc: Likewise.
* kf-lang-cp.cc: Convert enum poison_kind to "enum class".
* kf.cc: Likewise.
* region-model-manager.cc: Likewise.
* region-model.cc: Likewise; also for enum access_direction.
* svalue.cc: Likewise.
* svalue.h: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Convert
enum poison_kind to "enum class".
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Our headers are a major pain to work with: many require certain other
headers to be included in a particular (undocumented) order in order
to be includable.
Simplify includes in the analyzer by renaming analyzer/analyzer.h to
analyzer/common.h and have it include all the common headers needed
throughout the analyzer, thus encapsulating the rules about e.g. being
able to include "gimple.h" in one place in the analyzer subdirectory.
Doing so also makes it easier to e.g. define INCLUDE_SET in one place,
rather than in many source files.
gcc/analyzer/ChangeLog:
* analyzer.h: Rename to...
* common.h: ...this. Add define of INCLUDE_VECTOR, includes of
"config.h", "system.h", "coretypes.h", "make-unique.h", "tree.h",
"function.h", "basic-block.h", "gimple.h", "options.h",
"bitmap.h", "diagnostic-core.h", and "diagnostic-path.h".
* access-diagram.h: Don't include "analyzer/analyzer.h".
* access-diagram.cc: Reorganize includes to #include
"analyzer/common.h" first, then group by subsystem, dropping
redundant headers.
* analysis-plan.cc: Likewise.
* analyzer-language.cc: Likewise.
* analyzer-pass.cc: Likewise.
* analyzer-selftests.cc: Likewise.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* call-info.cc: Likewise.
* call-string.cc: Likewise.
* call-summary.cc: Likewise.
* checker-event.cc: Likewise.
* checker-path.cc: Likewise.
* complexity.cc: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* feasible-graph.cc: Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* kf-analyzer.cc: Likewise.
* kf-lang-cp.cc: Likewise.
* kf.cc: Likewise.
* known-function-manager.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* program-point.cc: Likewise.
* program-state.cc: Likewise.
* ranges.cc: Likewise.
* record-layout.cc: Likewise.
* region-model-asm.cc: Likewise.
* region-model-manager.cc: Likewise.
* region-model-reachability.cc: Likewise.
* region-model.cc: Likewise.
* region.cc: Likewise.
* 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.
* supergraph.cc: Likewise.
* svalue.cc: Likewise.
* symbol.cc: Likewise.
* trimmed-graph.cc: Likewise.
* varargs.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Update for renaming
of analyzer/analyzer.h to analyzer/common.h.
* gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
gcc/analyzer/ChangeLog:
* region-model.cc (region_model::on_stmt_pre): Use internal_error
if we see an unexpected gimple stmt code.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Add a new function to help debugging -fanalyzer.
No functional change intended.
gcc/analyzer/ChangeLog:
* call-details.cc (call_details::dump): New overload.
(call_details::make_dump_widget): New.
* call-details.h (call_details::dump): Declare new overload.
(call_details::make_dump_widget): New decl.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Make it clearer when we're accessing member data of pass_manager by
adding an "m"_ prefix to the fields handled via passes.def macros.
No functional change intended.
gcc/ChangeLog:
* pass_manager.h (class pass_manager): Add "m_" prefix to all pass
fields.
* passes.cc (pass_manager::execute_early_local_passes): Update
for added "m_" prefix.
(pass_manager::execute_pass_mode_switching): Likewise.
(pass_manager::finish_optimization_passes): Likewise.
(pass_manager::pass_manager): Likewise.
(pass_manager::dump_profile_report): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
gcc/c-family/ChangeLog:
* name-hint.h (name_hint::name_hint): Use std::unique_ptr for
param.
gcc/c/ChangeLog:
* c-decl.cc: Include "make-unique.h".
(lookup_name_fuzzy): Use ::make_unique rather than "new" when
making suggest_missing_header and suggest_missing_option.
* c-parser.cc: Include "make-unique.h"
(c_parser_error_richloc): Use ::make_unique rather than "new" when
making suggest_missing_header.
gcc/cp/ChangeLog:
* name-lookup.cc: Include "make-unique.h".
(namespace_hints::convert_candidates_to_name_hint): Use
::make_unique rather than "new" when making
show_candidate_location and suggest_alternatives.
(namespace_hints::maybe_decorate_with_limit): Likewise when making
namespace_limit_reached.
(suggest_alternatives_for_1): Likewise when making
suggest_missing_option.
(maybe_suggest_missing_std_header): Likewise when making
missing_std_header.
(macro_use_before_def::maybe_make): Use std::unique_ptr.
(macro_use_before_def::macro_use_before_def): Make public.
(lookup_name_fuzzy): Use ::make_unique rather than "new" when
making suggest_missing_header.
* parser.cc: Include "make-unique.h".
(cp_parser_error_1): Use ::make_unique rather than "new" when
making suggest_missing_header.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
gcc/ChangeLog:
* diagnostic.h (diagnostic_context::m_opt_permissive): Convert
from int to diagnostic_option_id. Update comment.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
No functional change intended.
gcc/ChangeLog:
* diagnostic.h (diagnostic_context::set_abort_on_error): New.
(diagnostic_context::m_abort_on_error): Make private.
(diagnostic_abort_on_error): Delete.
* opts.cc (setup_core_dumping): Update for above changes.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_builder::get_opts): New
accessor.
(sarif_builder::get_version): Update for...
(sarif_builder::m_version): Replace this field...
(sarif_builder::m_m_sarif_gen_opts): ...with this.
(sarif_builder::sarif_builder): Replace version with
sarif_gen_opts throughout.
(sarif_builder::make_top_level_object): Use get_version.
(sarif_output_format::sarif_output_format): Replace version with
sarif_gen_opts throughout.
(sarif_stream_output_format::sarif_stream_output_format):
Likewise.
(sarif_file_output_format::sarif_file_output_format): Likewise.
(diagnostic_output_format_init_sarif_stderr): Drop version param
and use default for sarif_generation_options instead.
(diagnostic_output_format_init_sarif_file): Likewise.
(diagnostic_output_format_init_sarif_stream): Likewise.
(make_sarif_sink): Replace version with sarif_gen_opts throughout.
(sarif_generation_options::sarif_generation_options): New.
(selftest::test_sarif_diagnostic_context::test_sarif_diagnostic_context):
Replace version with sarif_gen_opts throughout.
(selftest::test_make_location_object): Likewise.
(selftest::test_simple_log): Likewise.
(selftest::test_simple_log_2): Likewise.
(selftest::test_message_with_embedded_link): Likewise.
(selftest::test_message_with_braces): Likewise.
(selftest::test_buffering): Likewise.
(selftest::run_tests_per_version): Replace with...
(selftest::for_each_sarif_gen_option): ...this...
(selftest::run_line_table_case_tests_per_version): ...and this.
(selftest::diagnostic_format_sarif_cc_tests): Update to use
for_each_sarif_gen_option and
run_line_table_case_tests_per_version.
* diagnostic-format-sarif.h (enum class sarif_version): Move lower
down.
(diagnostic_output_format_init_sarif_stderr): Drop "version"
param.
(diagnostic_output_format_init_sarif_file): Likewise.
(diagnostic_output_format_init_sarif_stream): Likewise.
(struct sarif_generation_options): New.
(make_sarif_sink): Add "formatted" param. Replace version param
with sarif_gen_opts.
* diagnostic.cc (diagnostic_output_format_init): Drop hardcoded
sarif_version::v2_1_0 arguments from calls, which instead use
the default ctor for sarif_generation_options internally.
* libgdiagnostics.cc (sarif_sink::sarif_sink): Replace version
param with sarif_gen_opts, and update for changes to
make_sarif_sink.
(diagnostic_manager_add_sarif_sink): Use sarif_gen_opts rather
than version.
* opts-diagnostic.cc (sarif_scheme_handler::make_sink): Likewise.
Pass "true" for "formatted" param.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
This patch adds a relation iterator to query the oracle to list either
all the relations on exit to a block, or just ones involving a specified
SSA_NAME. The oracle then uses this iterator internally as well.
* value-relation.cc (value_relation::swap): New.
(value_relation::negate): Remove.
(dom_oracle::next_relation): New.
(block_relation_iterator::block_relation_iterator): New.
(block_relation_iterator::get_next_relation): New.
(dom_oracle::dump): Use iterator.
* value-relation.h (relation_oracle::next_relation): New.
(dom_oracle::next_relation): New prototype.
(class block_relation_iterator): New.
(FOR_EACH_RELATION_BB): New.
(FOR_EACH_RELATION_NAME): New.
|
|
When prange was split from irange, the functionality of lhs_op1_relation
did not get ported. This patch adds that functionality back, and is
also good example of how to add new dispatch patterns to range-ops
as lhs_op1_relation had no prange/prange/irange combination.
* range-op-ptr.cc (range_operator::lhs_op1_relation): Add
prange/prange/irange (PPI) default.
(pointer_plus_operator::lhs_op1_relation): New.
* range-op.cc (range_op_handler::lhs_op1_relation): Add RO_PPI case.
* range-op.h (range_op_handler::lhs_op1_relation): Add prototype.
|
|
when registering reltions between the lhs and op1/op2, the relation
between op1 and op2 is being overwritten by the result. This could
result in either an incorrect relation being registered between lhs and op2,
or a correct relation not being recognized.
* gimple-range-fold.cc (fold_using_range::range_of_range_op): Use a
new local variable for intermediate relation results.
|
|
Infer range processing was adjusted to allow a query to be specified,
but during VRP folding, ranger was not providing a query. This results
in contextual ranges being missed. Pass the cache in as the query
which provide a read-only query of the current state.
* gimple-range-cache.cc (ranger_cache::apply_inferred_ranges): Pass
'this' as the range-query to the inferred range constructor.
|
|
Adding op2_range for operator_div allows ranger to notice the divisor
is non-zero after execution.
PR tree-optimization/95801
gcc/
* range-op.cc (operator_div::op2_range): New.
gcc/testsuite/
* gcc.dg/tree-ssa/pr95801.c: New.
|
|
During intersection, we expand the subranges to exclude the lower values
from a bitmask with trailing zeros. This leads to inconsistant evaluations
and in this case of this PR, that lead to an infinite cycle.
Always expand the lower subranges in set_range_from_bitmask instead.
PR tree-optimization/119712
gcc/
* value-range.cc (range_bitmask::adjust_range): Delete.
(irange::set_range_from_bitmask): Integrate adjust_range.
(irange::update_bitmask): Do nothing if bitmask doesnt change.
(irange:intersect_bitmask): Do not call adjust_range. Exit if there
is no second bitmask.
* value-range.h (adjust_range): Remove prototype.
gcc/testsuite/
* gcc.dg/pr119712.c: New.
* gcc.dg/pr83072-2.c: Adjust.
* gcc.dg/tree-ssa/phi-opt-value-5.c: Adjust.
* gcc.dg/tree-ssa/vrp122.c: Adjust
|
|
r15-6943-g9c4397cafc5ded added support to undo IPA-VRP return value optimization for tail calls,
using the same code ERF_RETURNS_ARG can be supported for functions which return one of their arguments.
This allows for tail calling of memset/memcpy in some cases which were not handled before.
Note this is very similar to https://gcc.gnu.org/legacy-ml/gcc-patches/2016-11/msg02485.html except
it has a few more checks. Also on the question of expand vs tail call here is that this path is also
used by the IPA-VRP return value path and yes we get a tail call.
Note in the review in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83142#c2 mentions about
re-instantiate a LHS on the call & propagate to dominating uses. Even though that can be done
for the ERF_RETURNS_ARG case, it is not done for the IPA-VRP return value case already so I don't think
there is anything to be done there.
Changes since v1:
* v2: Add an useless_type_conversion_p check as suggested by Jakub
and add a testcase for that.
* v3: Fix the order of arguments to useless_type_conversion_p.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/67797
gcc/ChangeLog:
* tree-tailcall.cc (find_tail_calls): Add support for ERF_RETURNS_ARG.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/tailcall-14.c: New test.
* gcc.dg/tree-ssa/tailcall-15.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
ChangeLog:
* MAINTAINERS (kcy): Add gcc.gnu.org username.
|
|
While working on PR 119903, I noticed that there is code in replace_stmt_with_simplification
which makes sure that the comparison of a GIMPLE_COND does not throw
(non-call exceptions and trapping math) but the gimple verifier does not
verify this. So let's add it.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-cfg.cc (verify_gimple_cond): Error out if the comparison
throws.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
This adds support for rotate left/right to the GIMPLE front-end
via __ROTATE_LEFT/__ROTATE_RIGHT oeprators.
PR c/119432
gcc/c/ChangeLog:
* gimple-parser.cc (gimple_binary_identifier_code): Add
__ROTATE_LEFT and __ROTATE_RIGHT.
gcc/ChangeLog:
* tree-pretty-print.cc (op_symbol_code): For LROTATE_EXPR,
output __ROTATE_LEFT for gimple.
For RROTATE_EXPR output __ROTATE_RIGHT for gimple.
gcc/testsuite/ChangeLog:
* gcc.dg/gimplefe-57.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
While looking into adding __ROTATE_LEFT and __ROTATE_RIGHT, I noticed
this code is just a bunch of if statments repeated. Instead we could just
use a simple lookup array to do the same thinga and it would be easier to
add to the array instead of duplicating the if sequence again.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/c/ChangeLog:
* gimple-parser.cc (gimple_binary_identifier_code): New variable.
(c_parser_gimple_binary_expression): Use gimple_binary_identifier_code
instead of doing if statements on the strings.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
__builtin_unreachable [PR100038]
After EVRP was switched to the ranger (r12-2305-g398572c1544d8b), we are better handling the case
where __builtin_unreachable comes after a loop. Instead of removing __builtin_unreachable and having
the loop become an infinite one; it is kept around longer and allows GCC to unroll the loop 2 times instead
of 3 times. When GCC unrolled the loop 3 times, GCC would produce a bogus Warray-bounds warning for the 3rd
iteration.
This adds the testcase to make sure we don't regress on this case. It is originally extracted from LLVM source
code too.
PR tree-optimization/100038
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/pr100038.C: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
Fixes PR#119641
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-place.h
(IndexVec::size_type): Add.
(IndexVec::MAX_INDEX): Add.
(IndexVec::size): Change the return type to the type of the
internal value used by the index type.
(PlaceDB::lookup_or_add_variable): Use the return value from the
PlaceDB::add_place call.
* checks/errors/borrowck/rust-bir.h
(struct BasicBlockId): Move this definition before the
definition of the struct Function.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Default visitor should visit all it's children.
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit visibility.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Visit the loop labels of
WhileLetLoopExpr instances before visiting their scrutinee
expressions.
* resolve/rust-early-name-resolver-2.0.cc
(Early::resolve_glob_import): Pass the glob import's path
directly to NameResolutionContext::resolve_path.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Remove unnecessary call to
Identifier::as_string.
(flatten_glob): Improve handling of cases where a glob use tree
has no path.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Both nodes had the same id, this led to a resolution conflict.
gcc/rust/ChangeLog:
* expand/rust-derive-clone.cc (DeriveClone::clone_enum_struct): Clone
path to avoid using the same nodeid.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove now passing test from exclusion
list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
This commit introduce a new public function to visit function parameters
in the default visitor. It allows visitors derived from DefaultVisitor
to override only a small part of the default visitor.
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit_function_params):
Add specialized function to visit function parameters.
(DefaultASTVisitor::visit): Remove parameter visit and call specialized
function instead.
* ast/rust-ast-visitor.h: Add function prototye.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove
function.
(Late::visit_function_params): Override specialized visit function.
* resolve/rust-late-name-resolver-2.0.h: Add overriden function
prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove passing test from exclusion list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Binding context may be stacked when a new binding group is introduced
within a const expression.
gcc/rust/ChangeLog:
* resolve/rust-name-resolution-context.h: Use BindingLayer instead.
* resolve/rust-name-resolution-context.cc (BindingLayer::BindingLayer):
Add new constructor for binding layer.
(BindingLayer::bind_test): Add a function to test a binding constraint.
(BindingLayer::push): Push a new binding group.
(BindingLayer::and_binded): Add function to test and-binding
constraint.
(BindingLayer::or_binded): Add function to test or-binding constraints.
(BindingLayer::insert_ident): Insert a new identifier in the current
binding group.
(BindingLayer::merge): Merge current binding group with it's parent.
(BindingLayer::get_source): Get the source of the current binding
group.
* resolve/rust-late-name-resolver-2.0.cc: Use stacked context for
binding group.
* util/rust-stacked-contexts.h: Add mutable peek function.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add binding
creation in visitor.
* resolve/rust-late-name-resolver-2.0.h: Add function prototypes.
* resolve/rust-name-resolution-context.h: Add binding context.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
We need to differentiate bindings types, so the same binding cannot be
reused multiple time in a product binding.
gcc/rust/ChangeLog:
* resolve/rust-name-resolution-context.h (struct Binding): Add Binding
struct to differentiate Or and Product bindings in patterns.
(enum class): Add Binding kind.
(class BindingContext): Add binding context with Binding stack.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add hash function.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add equality operator.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/multiple_bindings1.rs: Add missing lang items.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Name resolution 2.0 message describes the context around the unresolved
items and should therefore be kept.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove test from exclusion list.
* rust/compile/use_1.rs: Change expected output and remove test from
nr1.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/generics9.rs: Change expected error message.
* rust/compile/nr2/exclude: Remove test from exclusion list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Add visit
function for TypeParam.
* resolve/rust-default-resolver.h: Add function prototype.
* resolve/rust-forever-stack.h: Add function to check for forward
declaration ban.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Check forward
declarations.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Remove error kind
and change function call.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change call name.
* ast/rust-path.cc (ConstGenericParam::as_string): Likewise.
* ast/rust-path.h: Remove error kind.
* hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Change call
name.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Use optional
on parsing failure.
(Parser::parse_generic_arg): Likewise.
(Parser::parse_path_generic_args): Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-type.h: Change call name.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Change error
message.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove passing test from exclusion list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc
(Early::build_import_mapping): Avoid outputting an "unresolved
import" error if other errors are outputted during resolution.
* resolve/rust-early-name-resolver-2.0.h
(Early::resolve_path_in_all_ns): Collect path resolution errors
while avoiding duplicate errors for resolutions in each
namespace.
* resolve/rust-forever-stack.h
(ForeverStack::resolve_path): Add parameter for collecting
errors.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
* resolve/rust-forever-stack.hxx
(check_leading_kw_at_start): Likewise.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Add optional parameter
for collecting errors.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entry.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/derive-debug1.rs: Adjust a path.
* rust/compile/nr2/exclude: Remove derive-debug1.rs.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
There are two cases when initilizing an array, this is the
const context which means we need to build the array ctor,
which means using lots of memory, its super inefficient
because we are using a big wrapper over the GCC internals here
but preallocating the vectors here causes a:
terminate called after throwing an instance of 'std::bad_alloc'
So this is a handy error condition to rely on for this senario.
Fixes Rust-GCC#3713
Fixes Rust-GCC#3727
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): prealloc the vector
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We have an assertion when accessing generic args if there are any which
is really useful so this adds the missing guards for the case where
they are specified but empty.
Fixes Rust-GCC#3649
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): add guard
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): add guard
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 is missing error for this
* rust/compile/issue-3649.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-path.cc
(ResolvePath::resolve_path): Adjust error messages.
* resolve/rust-ast-resolve-type.cc
(ResolveRelativeTypePath::go): Likewise.
* resolve/rust-forever-stack.hxx
(check_leading_kw_at_start): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/issue-3568.rs: Adjust expected errors.
* rust/compile/name_resolution9.rs: Likewise.
* rust/compile/self-path2.rs: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
We were wrongly adding the assertion that this must not be an enum but
this is a pointless assertion we only care that there are variant in the
ADT and if the field exists in the first variant.
Fixes Rust-GCC#3581
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): fix bad assertion
gcc/testsuite/ChangeLog:
* rust/compile/nonexistent-field.rs: fix bad error message
* rust/compile/issue-3581-1.rs: New test.
* rust/compile/issue-3581-2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Fixes Rust-GCC#3652
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 does not error on the T it should require Self::T
* rust/compile/issue-3652.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.hxx
(ForeverStack::resolve_path): Pass instance of Node to lambda by
reference instead of by value.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
The error handling here was done long ago when we didnt know how to do
any error handling very well. This removed bad fatal_errors and adds in
some nice rich_location error diagnostics instead.
Fixes Rust-GCC#3628
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-struct-field.h: keep reference to parent expression
* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::TypeCheckStructExpr):
update ctor
(TypeCheckStructExpr::resolve): remove bad rust_fatal_errors
(TypeCheckStructExpr::visit): cleanup errors
gcc/testsuite/ChangeLog:
* rust/compile/macros/mbe/macro-issue2983_2984.rs: cleanup error diagnotics
* rust/compile/struct_init1.rs: likewise
* rust/compile/issue-3628.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|