PR tree-optimization/83086
* gimple-ssa-store-merging.c
(imm_store_chain_info::try_coalesce_bswap): Test this_n.base_addr
rather than n.base_addr.
From-SVN: r255002
PR tree-optimization/83047
* gimple-ssa-store-merging.c
(imm_store_chain_info::output_merged_store): If the loads with the
same vuse are in different basic blocks, for load_gsi pick a load
location that is dominated by the other loads.
* gcc.dg/pr83047.c: New test.
From-SVN: r254992
P0428R2 - familiar template syntax for generic lambdas
* parser.c (cp_parser_lambda_declarator_opt): Don't pedwarn
for cxx2a and above, reword pedwarn for C++14/C++17.
* g++.dg/cpp1y/lambda-generic-x.C: Adjust warnings and limit
to c++17_down target.
* g++.dg/cpp1y/lambda-generic-dep.C: Likewise.
* g++.dg/cpp1y/lambda-generic-77914.C: Adjust error and limit
to c++17_down target.
* g++.dg/cpp2a/lambda-generic1.C: New test.
* g++.dg/cpp2a/lambda-generic2.C: New test.
* g++.dg/cpp2a/lambda-generic3.C: New test.
* g++.dg/cpp2a/lambda-generic4.C: New test.
* g++.dg/cpp2a/lambda-generic5.C: New test.
From-SVN: r254991
PR debug/82718
* dwarf2out.c (dw_loc_list): If crtl->has_bb_partition, temporarily
set in_cold_section_p to the partition containing loc_list->first.
When seeing loc_list->last_before_switch node, update secname and
perform range_across_switch second partition handling only after that.
* gcc.dg/debug/dwarf2/pr82718-1.c: New test.
* gcc.dg/debug/dwarf2/pr82718-2.c: New test.
From-SVN: r254989
Fix a small bug in the libgo Makefile recipe that constructs the
directory from which to pick up libgcc_s.so ; the gccgo invocation
with -print-libgcc-file-name was missing the flags, which meant that
for -m32 builds we'd see the 64-bit libgcc dir.
Reviewed-on: https://go-review.googlesource.com/78836
From-SVN: r254984
libcpp/ChangeLog:
2017-03-24 Eric Gallager <egall@gwmail.gwu.edu>
PR preprocessor/81794
* macro.c (check_trad_stringification): Have warning be controlled
by -Wtraditional.
gcc/testsuite/ChangeLog:
2017-09-17 Eric Gallager <egall@gwmail.gwu.edu>
PR preprocessor/81794
* gcc.dg/pragma-diag-7.c: Update to include check for
stringification.
From-SVN: r254981
This patch extends the C frontend's "knowledge" of the C stdlib within
get_c_name_hint to cover some more macros and functions, covering
a case reported in PR c/81404 ("INT_MAX"), so that rather than printing:
t.c:5:12: error: 'INT_MAX' undeclared here (not in a function); did you mean '__INT_MAX__'?
int test = INT_MAX;
^~~~~~~
__INT_MAX__
we instead print:
t.c:5:12: error: 'INT_MAX' undeclared here (not in a function)
int test = INT_MAX;
^~~~~~~
t.c:5:12: note: 'INT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?
t.c:1:1:
+#include <limits.h>
t.c:5:12:
int test = INT_MAX;
^~~~~~~
It also adds generalizes some of the code for this (and for the "std::"
namespace hints in the C++ frontend), moving it to a new
c-family/known-headers.cc and .h, and introducing a class known_headers.
This currently just works by scanning a hardcoded array of known
name/header associations, but perhaps in the future could be turned
into some kind of symbol database so that the compiler could record API
uses and use that to offer suggestions e.g.
foo.cc: error: 'myapi::foo' was not declared in this scope
foo.cc: note: 'myapi::foo" was declared in header 'myapi/private.h'
(included via 'myapi/public.h') when compiling 'bar.cc'; did you forget to
'#include "myapi/public.h"'?
or somesuch.
In any case, moving this to a class gives an easier way to locate the
hardcoded knowledge about the stdlib.
The patch also adds similar code to the C++ frontend covering
unqualified names in the standard library, so that rather than just
e.g.:
t.cc:19:13: error: 'NULL' was not declared in this scope
void *ptr = NULL;
^~~~
we can emit:
t.cc:19:13: error: 'NULL' was not declared in this scope
void *ptr = NULL;
^~~~
t.cc:19:13: note: 'NULL' is defined in header '<cstddef>'; did you forget
to '#include <cstddef>'?
t.cc:1:1:
+#include <cstddef>
t.cc:19:13:
void *ptr = NULL;
^~~~
(Also XFAIL for PR c++/80567 added for the C++ testcase; this is a
separate pre-existing bug exposed by the testcase for PR 81404).
gcc/ChangeLog:
PR c/81404
* Makefile.in (C_COMMON_OBJS): Add c-family/known-headers.o.
gcc/c-family/ChangeLog:
PR c/81404
* known-headers.cc: New file, based on material from c/c-decl.c.
(suggest_missing_header): Copied as-is.
(get_stdlib_header_for_name): New, based on get_c_name_hint but
heavily edited to add C++ support. Add some knowledge about
<limits.h>, <stdint.h>, and <wchar.h>.
* known-headers.h: Likewise.
gcc/c/ChangeLog:
PR c/81404
* c-decl.c: Include "c-family/known-headers.h".
(get_c_name_hint): Rename to get_stdlib_header_for_name and move
to known-headers.cc.
(class suggest_missing_header): Move to known-header.h.
(lookup_name_fuzzy): Call get_c_stdlib_header_for_name rather
than get_c_name_hint.
gcc/cp/ChangeLog:
PR c/81404
* name-lookup.c: Include "c-family/known-headers.h"
(lookup_name_fuzzy): Call get_cp_stdlib_header_for_name and
potentially return a new suggest_missing_header hint.
gcc/testsuite/ChangeLog:
PR c/81404
* g++.dg/spellcheck-stdlib.C: New.
* gcc.dg/spellcheck-stdlib.c (test_INT_MAX): New.
From-SVN: r254980
The C frontend already "knows" about many common functions in
the C standard library:
test.c: In function 'test':
test.c:3:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
printf ("hello world\n");
^~~~~~
test.c:3:3: warning: incompatible implicit declaration of built-in function 'printf'
test.c:3:3: note: include '<stdio.h>' or provide a declaration of 'printf'
and which header file they are in.
However it doesn't know about various types and macros:
test.c:1:13: error: 'NULL' undeclared here (not in a function)
void *ptr = NULL;
^~~~
This patch uses the name_hint/deferred_diagnostic machinery to
add hints for missing C standard library headers for some of the
most common type and macro names.
For example, the above becomes:
test.c:1:13: error: 'NULL' undeclared here (not in a function)
void *ptr = NULL;
^~~~
test.c:1:13: note: 'NULL' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
gcc/c/ChangeLog:
* c-decl.c (get_c_name_hint): New function.
(class suggest_missing_header): New class.
(lookup_name_fuzzy): Call get_c_name_hint and use it to
suggest missing headers to the user.
gcc/testsuite/ChangeLog:
* gcc.dg/spellcheck-stdlib.c: New test case.
From-SVN: r254979
This patch uses the name_hint/deferred_diagnostic to provide
a message in the C++ frontend if a macro is used before it is defined
e.g.:
test.c:6:24: error: expected ';' at end of member declaration
virtual void clone() const OVERRIDE { }
^~~~~
;
test.c:6:30: error: 'OVERRIDE' does not name a type
virtual void clone() const OVERRIDE { }
^~~~~~~~
test.c:6:30: note: the macro 'OVERRIDE' had not yet been defined
test.c:15:0: note: it was later defined here
#define OVERRIDE override
It's possible to do it from the C++ frontend as tokenization happens
up-front (and hence the macro already exists when the above is parsed);
I attempted to do it from the C frontend, but because the C frontend only
tokenizes on-demand during parsing, the macro isn't known about until
later.
gcc/cp/ChangeLog:
PR c++/72786
* name-lookup.c (class macro_use_before_def): New class.
(lookup_name_fuzzy): Detect macro that were used before being
defined, and report them as such.
gcc/ChangeLog:
PR c++/72786
* spellcheck.h (best_match::blithely_get_best_candidate): New
accessor.
gcc/testsuite/ChangeLog:
PR c++/72786
* g++.dg/spellcheck-macro-ordering-2.C: New test case.
* g++.dg/spellcheck-macro-ordering.C: Add dg-message directives
for macro used-before-defined.
libcpp/ChangeLog:
PR c++/72786
* include/cpplib.h (cpp_macro_definition_location): New decl.
* macro.c (cpp_macro_definition): New function.
From-SVN: r254978
2017-11-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/79072
* trans-expr.c (trans_class_vptr_len_assignment): Set from_len
if the temporary is unlimited polymorphic.
* trans-stmt.c (trans_associate_var): Use the fake result decl
to obtain the 'len' field from an explicit function result when
in that function scope.
2017-11-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/79072
* gfortran.dg/class_result_5.f90: New test.
From-SVN: r254966
P0329R4: Designated Initialization
* parser.c (cp_parser_initializer_clause): List in comment grammar
designated-initializer-list.
(cp_parser_initializer_list): Allow .identifier = without pedwarn for
C++2A, parse .identifier { ... }. Improve location_t argument to
pedwarn. Add pedwarn for [cst] = designators. Diagnose ... in
designated initializer list. Diagnose mixing designated and
non-designated initializer clauses for C++2A. Diagnose duplicated
identifiers in designators.
* name-lookup.h (search_anon_aggr): New declaration.
* name-lookup.c (fields_linear_search): Use search_anon_aggr.
(search_anon_aggr): New function.
* typeck2.c (process_init_constructor_record): Allow designator
to skip over some non-static data members. Handle anonymous
aggregates. Add diagnostics for designator order not matching
member declaration order.
* g++.dg/ext/desig2.C: Adjust comment, no sorry about designator
refering to second member.
(b): New variable and associated expected diagnostic.
* g++.dg/ext/desig4.C: For C++2A expect diagnostics.
* g++.dg/ext/desig5.C: Add dg-do dg-compile and empty dg-options.
* g++.dg/ext/desig8.C: Likewise.
* g++.dg/ext/desig9.C: New test.
* g++.dg/ext/pr27019.C: Don't expect any diagnostics.
* g++.dg/init/error2.C: Adjust expected diagnostics.
* g++.dg/cpp0x/desig1.C: Add dg-options with -pedantic, expect
warning on C99 designators.
* g++.dg/cpp2a/desig1.C: New test.
* g++.dg/cpp2a/desig2.C: New test.
* g++.dg/cpp2a/desig3.C: New test.
* g++.dg/cpp2a/desig4.C: New test.
* g++.dg/cpp2a/desig5.C: New test.
* g++.dg/cpp2a/desig6.C: New test.
From-SVN: r254964
In various places we use lookup_name_fuzzy to provide a hint,
and can report messages of the form:
error: unknown foo named 'bar'
or:
error: unknown foo named 'bar'; did you mean 'SUGGESTION?
This patch provides a way for lookup_name_fuzzy to provide
both the suggestion above, and (optionally) additional hints
that can be printed e.g.
note: did you forget to include <SOME_HEADER.h>?
This patch provides the mechanism and ports existing users
of lookup_name_fuzzy to the new return type.
There are no uses of such hints in this patch, but followup
patches provide various front-end specific uses of this.
gcc/c-family/ChangeLog:
* c-common.h (enum lookup_name_fuzzy_kind): Move to name-hint.h.
(lookup_name_fuzzy): Likewise. Convert return type from
const char * to name_hint. Add location_t param.
* name-hint.h: New header.
gcc/c/ChangeLog:
* c-decl.c: Define INCLUDE_UNIQUE_PTR before including system.h.
Include "c-family/name-hint.h"
(implicit_decl_warning): Convert "hint" from
const char * to name_hint. Pass location to
lookup_name_fuzzy. Suppress any deferred diagnostic if the
warning was not printed.
(undeclared_variable): Likewise for "guessed_id".
(lookup_name_fuzzy): Convert return type from const char *
to name_hint. Add location_t param.
* c-parser.c: Define INCLUDE_UNIQUE_PTR before including system.h.
Include "c-family/name-hint.h"
(c_parser_declaration_or_fndef): Convert "hint" from
const char * to name_hint. Pass location to lookup_name_fuzzy.
(c_parser_parameter_declaration): Likewise.
gcc/cp/ChangeLog:
* name-lookup.c: Define INCLUDE_UNIQUE_PTR before including system.h.
Include "c-family/name-hint.h"
(suggest_alternatives_for): Convert "fuzzy_name" from const char *
to name_hint, and rename to "hint". Pass location to
lookup_name_fuzzy.
(lookup_name_fuzzy): Convert return type from const char *
to name_hint. Add location_t param.
* parser.c: Define INCLUDE_UNIQUE_PTR before including system.h.
Include "c-family/name-hint.h"
(cp_parser_diagnose_invalid_type_name): Convert
"suggestion" from const char * to name_hint, and rename to "hint".
Pass location to lookup_name_fuzzy.
From-SVN: r254963
* Makefile.in (OBJS): Add gimple-ssa-evrp-analyze.o.
* gimple-ssa-evrp-analyze.c: New file pulled from gimple-ssa-evrp.c.
* gimple-ssa-evrp-analyze.h: New file pulled from gimple-ssa-evrp.c.
* gimple-ssa-evrp.c: Remove bits moved into new files. Include
gimple-ssa-evrp-analyze.h.
From-SVN: r254961
* gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Do not
set BB_VISITED here.
(evrp_range_analyzer::enter): Set BB_VISITED here instead.
From-SVN: r254960
* tree-predcom.c: Add general comment on Store-Store chains.
(split_data_refs_to_components): Postpone clearing eliminate_store_p
flag in component.
(get_chain_last_ref_at): Rename into...
(get_chain_last_write_at): ...this.
(get_chain_last_write_before_load): New function.
(add_ref_to_chain): Promote type of chain from CT_STORE_LOAD to
CT_STORE_STORE when write reference is added.
(determine_roots_comp): Support load ref in CT_STORE_STORE chains.
(is_inv_store_elimination_chain): Update get_chain_last_write_at call.
(initialize_root_vars_store_elim_1): Ditto.
(initialize_root_vars_store_elim_2): Ditto. Replace rhs once default
definition is created.
(execute_pred_commoning_chain): Support load ref in CT_STORE_STORE
chain by replacing it with dominant stored value.
gcc/testsuite
* gcc.dg/tree-ssa/predcom-dse-12.c: New test.
From-SVN: r254956
2017-11-20 Marc Glisse <marc.glisse@inria.fr>
gcc/
* vr-values.c (extract_range_from_binary_expr): Use a full range
for VR_VARYING.
gcc/testsuite/
PR testsuite/82951
* gcc.c-torture/execute/20040409-1.c: Move invalid tests...
* gcc.c-torture/execute/20040409-1w.c: ... here with -fwrapv.
* gcc.c-torture/execute/20040409-2.c: Move invalid tests...
* gcc.c-torture/execute/20040409-2w.c: ... here with -fwrapv.
* gcc.c-torture/execute/20040409-3.c: Move invalid tests...
* gcc.c-torture/execute/20040409-3w.c: ... here with -fwrapv.
* gcc.dg/tree-ssa/cmpmul-1.c: Tweak condition.
* gcc.dg/tree-ssa/vrp118.c: New file.
From-SVN: r254954
PR c++/82781
* constexpr.c (cxx_eval_vector_conditional_expression): New function.
(cxx_eval_constant_expression) <case VEC_COND_EXPR>: Use it instead
of cxx_eval_conditional_expression.
* g++.dg/ext/constexpr-pr82781.C: New test.
From-SVN: r254952
Expanders for Armv8-M nonsecure call unnecessarily clobber r4 despite
the libcall they perform not writing to r4. Furthermore, the
requirement for the branch target address to be in r4 as expected by
the libcall is modeled in a convoluted way in the define_insn patterns:
the address is a register match_operand constrained by the match_dup
for the clobber which is guaranteed to be r4 due to the expander.
This patch simplifies all this by simply requiring the address to be in
r4 and removing the clobbers. Expanders are left alone because
cmse_nonsecure_call_clear_caller_saved relies on branch target memory
attributes which would be lost if expanding to reg:SI R4_REGNUM.
2017-11-20 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* config/arm/arm.md (R4_REGNUM): Define constant.
(nonsecure_call_internal): Remove r4 clobber.
(nonsecure_call_value_internal): Likewise.
* config/arm/thumb1.md (nonsecure_call_reg_thumb1_v5): Remove second
clobber and resequence match_operands.
(nonsecure_call_value_reg_thumb1_v5): Likewise.
* config/arm/thumb2.md (nonsecure_call_reg_thumb2): Likewise.
(nonsecure_call_value_reg_thumb2): Likewise.
From-SVN: r254950
2017-11-20 Christophe Lyon <christophe.lyon@linaro.org>
gcc/testsuite/
* gcc.target/arm/pr69180.c: Use -: for no column in expected
warnings.
From-SVN: r254949
PR tree-optimization/78821
* gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up
if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr
to the address of the base rather than the base itself.
(find_bswap_or_nop_1): Just use pointer comparison for vuse check.
(find_bswap_or_nop_finalize): New function.
(find_bswap_or_nop): Use it.
(bswap_replace): Return a tree rather than bool, change first
argument from gimple * to gimple_stmt_iterator, allow inserting
into an empty sequence, allow ins_stmt to be NULL - then emit
all stmts into gsi. Fix up MEM_REF address gimplification.
(pass_optimize_bswap::execute): Adjust bswap_replace caller.
(struct store_immediate_info): Add N and INS_STMT non-static
data members.
(store_immediate_info::store_immediate_info): Initialize them
from newly added ctor args.
(merged_store_group::apply_stores): Formatting fixes. Sort by
bitpos at the end.
(stmts_may_clobber_ref_p): For stores call also
refs_anti_dependent_p.
(gather_bswap_load_refs): New function.
(imm_store_chain_info::try_coalesce_bswap): New method.
(imm_store_chain_info::coalesce_immediate_stores): Use it.
(split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially.
(imm_store_chain_info::output_merged_store): Fail if number of
new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR
and NOP_EXPR rhs_code.
(pass_store_merging::process_store): Compute n and ins_stmt, if
ins_stmt is non-NULL and the store rhs is otherwise invalid, use
LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info
ctor.
(pass_store_merging::execute): Calculate dominators.
* gcc.dg/store_merging_16.c: New test.
From-SVN: r254948