Fix for PR preprocessor/78680
PR preprocessor/78680 identifies a crash when attempting to issue
a -Wformat warning, where the format string includes a string token
split across multiple physical source lines via backslash-continued
lines.
The issue is that libcpp is generating bogus range information for
such tokens.
For example, in:
void fn1() {
__builtin_printf("\
%ld.\n\
2\n"); };
the range of the string token is printed as:
__builtin_printf("\
^~
whereas the range ought to be:
__builtin_printf("\
^~
%ld.\n\
~~~~~~~
2\n"); };
~~~~
The root cause is that the line notes expressing the update
of the buffer in lex.c aren't yet updated when the end-point of
the token is computed
3095 tok_range.m_finish
3096 = linemap_position_for_column (pfile->line_table,
3097 CPP_BUF_COLUMN (buffer, buffer->cur));
so that the physical line is still regarded as that of the start
of the token, and, where CPP_BUF_COLUMN uses (BUF)->line_base,
line_base is still the location of the first physical line in the
and hence the column information is too large (as if it were the
offset in the *logical* line).
(the printed range is somewhat misleading; the actual buggy range
extends beyond the "\ in the line, but within diagnostic-show-locus.c
layout::print_annotation_line only prints up to the xbound set by
layout::print_source_line and so truncates most of the buggy range).
The fix is to ensure that line notes are handled before calculating
the end-point of the token range.
This leads to the range for the string token being correctly
computed, as:
__builtin_printf("\
^~
%ld.\n\
~~~~~~~
2\n"); };
~~~~
and this leads to get_substring_ranges_for_loc failing gracefully,
rather than crashing.
gcc/testsuite/ChangeLog:
PR preprocessor/78680
* gcc.dg/format/pr78680.c: New test case.
* gcc.dg/plugin/diagnostic-test-expressions-1.c
(test_multiline_token): New function.
* gcc.dg/plugin/diagnostic-test-string-literals-1.c
(test_backslash_continued_logical_lines): New function.
libcpp/ChangeLog:
PR preprocessor/78680
* lex.c (_cpp_lex_direct): Ensure line notes are processed before
computing the end-point of the token.
From-SVN: r243567
PR rtl-optimization/78669
* ira.c (combine_and_move_insns): When deleting an insn, clear the
replace flag for all used regs in that insn.
PR rtl-optimization/78669
* gcc.target/i386/pr78669.c: New test.
From-SVN: r243551
libgcc/
2016-12-12 George Spelvin <linux@sciencehorizons.net>
* config/avr/lib1funcs.S (__ashldi3): Use __tmp_reg__ to restore
R16 instead of push + pop.
(__ashrdi3, __lshrdi3): Same. And use __zero_reg__ for signs.
From-SVN: r243545
Earlier Darwin (esp. Darwin8 and Darwin9) had FAT libraries and suitable header
installations in /usr/include such that one could build a cross-toolchain
(including cross-arch) using a common sysroot (including / for “current” version).
However this is no longer true on a number of levels. A vanilla Darwin system has
no headers installed in /usr and it's certainly not appropriate to try and find
headers/libs for (say) x86-64-darwinNN X powerpc-darwin in /usr on any Darwin NN > 10
(even Darwin10 is incomplete in that it omits the ppc64 multilib). In the latter
example, the catch-all in the current configury to mean that
"foo-darwin" == “foo-version-on-this-system” breaks the cross case
—target=powerpc-apple-darwin —host=some-system-later-than-darwin10.
gcc/
2016-12-11 Iain Sandoe <iain@codesourcery.com>
* configure.ac (CROSS directory tests): Remove the assumption that
Darwin hosts contain suitable target sysroots in "/".
* configure: Regenerate.
From-SVN: r243533
The Darwin pic base loads (and reloads for non-local-gotos) are not
validly copied (since the pic base label would be duplicated). Thus,
mark the pic base {re-}loads as non-copyable.
gcc/
2016-12-11 Iain Sandoe <iain@codesourcery.com>
PR rtl-optimization/71496
* config/rs6000/darwin.md (load_macho_picbase_si): Mark as non-
copyable. (load_macho_picbase_di, reload_macho_picbase_si,
reload_macho_picbase_di): Likewise.
From-SVN: r243532
PR target/70118
* config/i386/mmintrin.h (__m64_u): New type
* config/i386/emmintrin.h (_mm_loadl_epi64, _mm_storel_epi64):
Make the allowed unaligned memory access explicit.
From-SVN: r243527
2016-12-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/78226
* error.c (gfc_warning_internal): New function.
* frontend-passes.c (gfc_run_passes): Call check_locus if
CHECKING_P is defined.
(check_locus_code): New function.
(check_locus_expr): New function.
(check_locus): New function.
* gfortran.h: Add prototype for gfc_warning_internal.
From-SVN: r243520
2016-12-10 Krister Walfridsson <krister.walfridsson@gmail.com>
* config.gcc (i386-*-netbsd*): Make i486 the default arch on NetBSD.
Generally use cpu generic.
From-SVN: r243519
2016-12-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/78350
* resolve.c (resolve_structure_cons): Remove the block that
tried to remove a charlen and rely on namespace cleanup.
From-SVN: r243517
PR tree-optimization/78720
* match.pd (A < 0 ? C : 0): Only optimize for signed A. If shift
is negative, sign extend to @1's type and than AND with C.
* gcc.c-torture/execute/pr78720.c: New test.
Co-Authored-By: Marc Glisse <marc.glisse@inria.fr>
From-SVN: r243516
PR sanitizer/78708
* lto-streamer-in.c (input_function): In addition to debug stmts
without -g, remove IFN_*SAN_* calls if corresponding flag_sanitize
bit is not enabled.
From-SVN: r243514
2016-12-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/77903
* decl.c (get_proc_name): Use the symbol tlink field instead of
the typespec interface field.
(gfc_match_function_decl, gfc_match_submod_proc): Ditto.
* gfortran.h : Since the symbol tlink field is no longer used
by the frontend for change management, change the comment to
reflect its current uses.
* parse.c (get_modproc_result): Same as decl.c changes.
* resolve.c (resolve_fl_procedure): Ditto.
2016-12-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/77903
* gfortran.dg/submodule_20.f08: New test.
From-SVN: r243507
2016-12-09 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gcc.target/powerpc/fold-vec-add-7.c: Require effective target to
support __int128.
From-SVN: r243503
On CPUs that implement popcnt[wd] but not cnttz[wd] we can do better for
the ctz sequences than we do today.
CL[TZ]_DEFINED_VALUE_AT_ZERO can return 2, since we always return the
same fixed value (only dependent on TARGET_* options).
PR target/78683
* config/rs6000/rs6000.h (CLZ_DEFINED_VALUE_AT_ZERO): Use
GET_MODE_BITSIZE. Return 2.
(CTZ_DEFINED_VALUE_AT_ZERO): Use GET_MODE_BITSIZE. Return 2. Handle
TARGET_POPCNTD the same as TARGET_CTZ.
* config/rs6000/rs6000.md (ctz<mode>2): Reimplement.
(ffs<mode>2): Reimplement.
From-SVN: r243499
gcc/ChangeLog:
2016-12-09 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR rtl-optimization/78255
* gcc/postreload.c (reload_cse_simplify): Do not CSE a function if
NO_FUNCTION_CSE is true.
gcc/testsuite/ChangeLog:
2016-12-09 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR rtl-optimization/78255
* gcc.target/aarch64/pr78255.c: New.
* gcc.target/arm/pr78255-1.c: New.
* gcc.target/arm/pr78255-2.c: New.
From-SVN: r243494
PR ipa/78027
gcc/
* ipa-icf.c (sem_function::parse): Don't process functions with
oacc decl attributes, as they may be OpenACC routines.
gcc/testsuite/
* c-c++-common/goacc/acc-icf.c: New test.
* gfortran.dg/goacc/pr78027.f90: New test.
From-SVN: r243488