PR c++/77467
* constexpr.c (enum constexpr_switch_state): New.
(struct constexpr_ctx): Add css_state field.
(label_matches): Add CTX and STMT arguments, remove I and
DEFAULT_LABEL. For CASE_LABEL_EXPR assert ctx->css_state != NULL,
handle default labels according to css_state.
(cxx_eval_statement_list): Remove statement skipping, label_matches
and default_label handling code.
(cxx_eval_loop_expr): Exit after first iteration even if
switches (jump_target).
(cxx_eval_switch_expr): Set up css_state field in ctx, if default
label has been seen in the body, but no cases matched, evaluate
the body second time.
(cxx_eval_constant_expression): Handle stmt skipping and label_matches
here. Handle PREDICT_EXPR. For MODIFY_EXPR or INIT_EXPR, assert
statement is not skipped. For COND_EXPR during skipping, don't
evaluate condition, just the then block and if still skipping at the
end also the else block.
(cxx_eval_outermost_constant_expr): Adjust constexpr_ctx initializer.
(is_sub_constant_expr): Likewise.
* g++.dg/cpp1y/constexpr-77467.C: New test.
From-SVN: r240591
Tweak the makefile rules for the runtime/check test to
insure that the runtime package is compiled with
"-fgo-compiling-runtime". This resolves a test failure
(unsat on runtime.getcallerpc) when in a build directory where the
compiler flags have been configured to disable optimization.
Reviewed-on: https://go-review.googlesource.com/30010
From-SVN: r240588
If strchr can't be folded in gimple-fold, we still need to fall into
the generic code so the folding code in builtins.c is also called.
gcc/
* gimple-fold.c (gimple_fold_builtin): After failing to fold
strchr, also try the generic folding.
From-SVN: r240585
gcc/testsuite/ChangeLog:
PR middle-end/77683
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Add test cases.
gcc/ChangeLog:
PR middle-end/77683
* gimple-ssa-sprintf.c (format_integer): Fail gracefully when
length modifier is not expected.
(format_floating): Ignore l length modifier and fail gracefuly
when it isn't one of the other expected ones.
From-SVN: r240583
2016-09-27 Richard Biener <rguenther@suse.de>
* dwarf2out.c (cu_die_list): New global.
(dwarf2out_finish): Walk cu_die_list instead of limbo DIEs. Add
main_comp_unit_die to cu_die_list if we created it.
Move break_out_includes ...
(dwarf2out_early_finish): ... here. Push created CU DIEs onto
the cu_die_list.
From-SVN: r240579
2016-09-28 Richard Biener <rguenther@suse.de>
* dwarf2out.c (struct die_struct): Add removed flag.
(lookup_type_die): If the DIE is marked as removed, clear
TYPE_SYMTAB_DIE and return NULL.
(lookup_decl_die): If the DIE is marked as removed, remove it
from the hash and return NULL.
(mark_removed): New helper.
(prune_unused_types_prune): Call it for removed DIEs.
(gen_subprogram_die): Move the premark_used_types call to after
DIEs for the functions scopes are generated.
(process_scope_var): Do not re-create pruned types or type decls.
Make sure to also re-parent type decls.
(dwarf2out_finish): Move unused type pruning and debug_types
handling ...
(dwarf2out_early_finish): ... here.
From-SVN: r240578
Optimize strchr (s, 0) to s + strlen (s). strchr (s, 0) appears a common
idiom for finding the end of a string, however it is not a very efficient
way of doing so. Strlen is a much simpler operation which is significantly
faster (eg. on x86 strlen is 50% faster for strings of 8 bytes and about
twice as fast as strchr on strings of 1KB).
gcc/
* gimple-fold.c (gimple_fold_builtin_strchr):
New function to optimize strchr (s, 0) to strlen.
(gimple_fold_builtin): Add BUILT_IN_STRCHR case.
testsuite/
* gcc.dg/strlenopt-20.c: Update test.
* gcc.dg/strlenopt-21.c: Likewise.
* gcc.dg/strlenopt-22.c: Likewise.
* gcc.dg/strlenopt-22g.c: Likewise.
* gcc.dg/strlenopt-26.c: Likewise.
* gcc.dg/strlenopt-5.c: Likewise.
* gcc.dg/strlenopt-7.c: Likewise.
* gcc.dg/strlenopt-9.c: Likewise.
From-SVN: r240568
This is a step toward a version of mksysinfo that generates information
for the runtime package. This will be used to generate the
runtime_sysinfo.go file, which is currently directly generated by a
Makefile target.
Reviewed-on: https://go-review.googlesource.com/29683
From-SVN: r240560
During the compiler's order_evaluations() pass, duplicate
call statements were being created and inserted into block
statement lists in situations where there were calls returning
multiple arguments. These duplicates were benign in that they
were ignored during backend code generation, however they
did cause duplicate calls in AST dumps. Tweak the order
evaluation code to handle this case better and avoid inserting
these duplicates.
Fixesgolang/go#17237
Reviewed-on: https://go-review.googlesource.com/29857
From-SVN: r240559
When emitting AST dumps, tag the end of selected statements with with
source file and line number information where available. Example:
tmp.76832448 = 0 // p.go:6
Requires a corresponding change in gcc/go as well as this change to
gofrontend.
Reviewed-on: https://go-review.googlesource.com/29856
* go-linemap.cc (Gcc_linemap::to_string): New method.
From-SVN: r240558
Implement P0018R3, C++17 lambda capture of *this by value as [=,*this]
* parser.c (cp_parser_lambda_introducer): Formatting fix. Pass
true instead of false as by_reference_p to add_capture for 'this'.
Parse '*this' simple-capture.
* lambda.c (build_capture_proxy): Handle '*this' capture by value.
(add_capture): Adjust function comment. For id == this_identifier,
treat by_reference_p as capturing '*this' by reference, i.e. 'this'
by value, and !by_reference_p as capturing '*this' by value.
(add_default_capture): For implicit 'this' capture, always pass
by_reference_p true rather than false.
* g++.dg/cpp1z/lambda-this1.C: New test.
* g++.dg/cpp1z/lambda-this2.C: New test.
From-SVN: r240556
PR c++/77722
* cp-gimplify.c (cp_ubsan_maybe_instrument_return): Instrument also
functions that have just a STATEMENT_LIST instead of BIND_EXPR, or
BIND_EXPR with some statement rather than STATEMENT_LIST as body.
* g++.dg/ubsan/return-4.C: New test.
* g++.dg/ubsan/return-5.C: New test.
* g++.dg/ubsan/return-6.C: New test.
From-SVN: r240555
gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_arm_v8_2a_fp16_scalar_hw): Delete redundant word
in function comment.
From-SVN: r240551
Revert a part of the `d' constraint documentation update made with
commit 111868 ("Use define_constraint for MIPS"),
<https://gcc.gnu.org/ml/gcc-patches/2006-03/msg00460.html>,
<https://gcc.gnu.org/ml/gcc-patches/2006-03/msg00541.html>, which
inadvertently made the registers covered to be referred to as "address"
rather than "general-purpose" registers, and then further clarify the
set of registers allowed with MIPS16 code.
* config/mips/constraints.md (d): Fix documentation.
* doc/md.texi (Machine Constraints): Update accordingly.
From-SVN: r240546
Fix PR gcov-profile/46266
PR gcov-profile/46266
* lib/gcov.exp: Verify that <built-in>.gcov file is not
considered.
* input.h (RESERVED_LOCATION_P): New macro.
* profile.c (branch_prob): Use RESERVED_LOCATION_P and
instread of comparison with UNKNOWN_LOCATION.
From-SVN: r240536
2016-09-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/77745
* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
When removing redundant stores make sure to check compatibility
of the TBAA state for downstream accesses.
* tree-ssa-sccvn.c (visit_reference_op_store): Likewise for when
value-numbering virtual operands for store matches.
* g++.dg/torture/pr77745.C: New testcase.
From-SVN: r240534
gcc/
PR target/51244
* config/sh/sh.c (sh_rtx_costs): Fix return value of SET of movt and
movrt patterns. Match them before anything else in the SET case.
From-SVN: r240533
PR gcov-profile/7970
PR gcov-profile/16855
PR gcov-profile/44779
* g++.dg/gcov/pr16855.C: New test.
* coverage.c (build_gcov_exit_decl): New function.
(coverage_obj_init): Call the function and generate __gcov_exit
destructor.
* doc/gcov.texi: Document when __gcov_exit function is called.
* libgcov-driver.c (__gcov_init): Do not register a atexit
handler.
(__gcov_exit): Rename from gcov_exit.
* libgcov.h (__gcov_exit): Declare.
From-SVN: r240529
The test has a bunch of hardcoded integer literals that would fit only in a
32 bits+ int, causing overflow warnings for a 16 bit int target like avr.
gcc/testsuite/ChangeLog
2016-09-27 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Require int32plus.
From-SVN: r240528