PR tree-optimization/83044
* tree-vrp.c (vrp_prop::check_array_ref): If eltsize is not
INTEGER_CST or is 0, clear up_bound{,_p1} and later ignore tests
that need the upper bound. Subtract offset from
get_addr_base_and_unit_offset only if positive and subtract it
before division by eltsize rather than after it.
* gcc.dg/pr83044.c: New test.
* c-c++-common/Warray-bounds.c (fb): Fix up MAX value.
From-SVN: r255054
2017-11-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/79072
* trans-stmt.c (trans_associate_var): Weaken the over strong
condition for using the fake result decl.
2017-11-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/79072
* gfortran.dg/class_result_6.f90: New test for comment 10 of
the PR.
From-SVN: r255053
PR debug/83084
* valtrack.c (propagate_for_debug_subst, propagate_for_debug): Reset
debug insns if they would contain UNSPEC_VOLATILE or volatile asm.
(dead_debug_insert_temp): Likewise, but also ignore even non-volatile
asm.
* g++.dg/opt/pr83084.C: New test.
From-SVN: r255051
PR middle-end/82875
* optabs.c (expand_doubleword_mult, expand_binop): Before calling
expand_binop with *mul_widen_optab, make sure at least one of the
operands doesn't have VOIDmode.
* gcc.dg/pr82875.c: New test.
* gcc.c-torture/compile/pr82875.c: New test.
From-SVN: r255050
PR rtl-optimization/82044
PR tree-optimization/82042
* dse.c (record_store): Check for overflow.
(check_mem_read_rtx): Properly check for overflow if width == -1, call
add_wild_read instead of clear_rhs_from_active_local_stores on
overflow and log it into dump_file.
From-SVN: r255048
2017-11-22 Richard Biener <rguenther@suse.de>
* gimple-iterator.c (gimple_find_edge_insert_loc): Ignore
fake edges to exit when looking for a place to insert.
* tree-ssa-pre.c (clear_expression_ids): Inline into callers
and remove.
(insert_into_preds_of_block): Commit edge insertion immediately,
assert that doesn't require new BBs.
(fini_pre): Release expressions.
(pass_pre::execute): Shuffle things around a bit, if the fn
is too large do not compute AVAIL either as this is really the
quadratic bit.
From-SVN: r255047
2017-11-22 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/83070
* intrinsics/eoshift0.c (eoshift0): Fix -Wsign-compare warning by
making a_ex and r_ex index_type instead of size_t.
From-SVN: r255045
2017-11-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/83089
* tree-if-conv.c (pass_if_conversion::execute): If anything
changed reset SCEV and free the number of iteration estimates.
* gcc.dg/pr83089.c: New testcase.
From-SVN: r255044
PR c/83056 reports an issue affecting trunk and gcc-7 in which
the C frontend's implementation of lookup_name_fuzzy uses undeclared
identifiers as suggestions when encountering subsequent undeclared
identifiers.
The fix is to filter out the names bound to error_mark_node
in lookup_name_fuzzy.
The C++ frontend is unaffected, as it already does this.
gcc/c/ChangeLog:
PR c/83056
* c-decl.c (lookup_name_fuzzy): Don't suggest names that came from
earlier failed lookups.
gcc/testsuite/ChangeLog:
PR c/83056
* gcc.dg/spellcheck-pr83056.c: New test case.
From-SVN: r255038
* config/i386/i386-opts.h (enum prefer_vector_width): Added new enum
for the new option -mprefer-vector-width=[none|128|256|512].
* config/i386/i386.c (ix86_target_string): remove old style options
-mprefer-avx256 and make -mprefer-avx128 as alias.
(ix86_option_override_internal): Apply defaults for the
-mprefer-vector-width=[128|256] option.
* config/i386/i386.h (TARGET_PREFER_AVX128, TARGET_PREFER_AVX256):
Implement macros to work with -mprefer-vector-width=.
* config/i386/i386.opt: Implemented option
-mprefer-vector-width=[none|128|256|512].
* doc/invoke.texi: Documentation for
-mprefer-vector-width=[none|128|256|512].
gcc/testsuite/
* g++.dg/ext/pr57362.C (__attribute__): Test
prefer-vector-width=[128|256] target attribute.
* gcc.target/i386/avx512f-constant-float-return.c (dg-optioins):
Use -mprefer-vector-width=256 instead of -mprefer-avx256.
* gcc.target/i386/avx512f-prefer.c: Ditto.
* gcc.target/i386/pr82460-2.c: Ditto.
From-SVN: r255030
2017-11-21 Przemyslaw Wirkus <przemyslaw.wirkus@arm.com>
* doc/xml/manual/using.xml (manual.intro.using.macros): Move
variablelist element at the end of its list.
From-SVN: r255023
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