Location of "dg-final" directives? (was Re: [PATCH][GCC] Algorithmic optimization in match and simplify)

2015-09-01 Thread David Malcolm
On Fri, 2015-08-28 at 17:56 +0100, Andre Vieira wrote: [..snip..] > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-33.c > b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-33.c > new file mode 100644 > index > ..984d8b37a01defe0e6852070a7dfa7ace5027c51 > --- /d

[PATCH, committed] Trivial typo fix in pretty-print.h

2015-09-08 Thread David Malcolm
"pinter" -> "printer" Committed to trunk as r227562, under the "obvious" rule. gcc/ChangeLog: * pretty-print.h (printer_fn): Fix typo in comment. --- gcc/pretty-print.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h index 6e8a3

Re: [PATCH 00/10] removal of typedefs that hide pointerness episode 1

2015-09-10 Thread David Malcolm
On Thu, 2015-09-03 at 11:48 +0200, Richard Biener wrote: > On Thu, Sep 3, 2015 at 7:26 AM, wrote: > > From: Trevor Saunders > > > > Hi, > > > > Personally I think hiding that variables are pointers is confusing, and I > > believe consensus is we should move away from this style. So this series

[PATCH 00/22] RFC: Overhaul of diagnostics

2015-09-10 Thread David Malcolm
This is a followup to the ideas posted at: https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00837.html I've been experimenting with capturing and printing richer information for our diagnostics, underlining pertinent source ranges when printing them, and potentially providing "fix-it" hints. Attac

[PATCH 03/22] Move diagnostic_show_locus and friends out into a new source file

2015-09-10 Thread David Malcolm
The function "diagnostic_show_locus" gains new functionality in the next patch, so this preliminary patch breaks it out into a new source file, diagnostic-show-locus.c, along with a couple of related functions. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Add diagnostic-show-locus.o.

[PATCH 01/22] Change of location_get_source_line signature

2015-09-10 Thread David Malcolm
location_get_source_line takes an expanded_location, but the column is irrelevant; it just needs a filename and line number. This change is used by, but independent of, the new implementation of diagnostic_show_locus later in the kit, so am breaking this out early. gcc/ChangeLog: * input.

[PATCH 13/22] gcc-rich-location.[ch]: add methods for working with tree ranges

2015-09-10 Thread David Malcolm
gcc/ChangeLog: * gcc-rich-location.c (get_range_for_expr): New function. (gcc_rich_location::add_expr): New method. (gcc_rich_location::maybe_add_expr): New method. (gcc_rich_location::add_expr_with_caption_va): New method. (gcc_rich_location::add_expr_with_c

[PATCH 11/22] Objective C: c/c-parser.c: use token ranges in two places

2015-09-10 Thread David Malcolm
I don't yet have an explicit test case for these. gcc/c/ChangeLog: * c-parser.c (c_parser_declaration_or_fndef): Use token range rather than location for a couple of warnings. --- gcc/c/c-parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/c/c-pars

[PATCH 02/22] Testsuite: add dg-{begin|end}-multiline-output commands

2015-09-10 Thread David Malcolm
This patch adds an easy way to write tests for expected multiline output. For example we can test carets and underlines for a particular diagnostic with: /* { dg-begin-multiline-output "" } typedef struct _GMutex GMutex; ^~~ { dg-end-multiline-output "" } */ It is used ex

[PATCH 07/22] Implement token range tracking within libcpp and C/C++ FEs

2015-09-10 Thread David Malcolm
This patch adds source *range* information to libcpp's cpp_token, and to c_token and cp_token in the C and C++ frontends respectively. To minimize churn, I kept the existing location_t fields, though in theory these are always just equal to the start of the source range. cpplib.h's struct cpp_tok

[PATCH 08/22] C frontend: use token ranges in various diagnostics

2015-09-10 Thread David Malcolm
This patch makes use of token ranges in the C frontend to add underlines to various diagnostics. Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-09/diagnostic-token-ranges.html gcc/c/ChangeLog: * c-decl.c (undeclared_variable): Convert param "loc" from a location_t to a

[PATCH 09/22] C frontend: store and use token ranges in c_declspecs

2015-09-10 Thread David Malcolm
This patch replaces the source_location in c_declspecs with a source_range, and uses it for various diagnostics to gain underlines. Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-09/bad-c-decls.html gcc/c/ChangeLog: * c-decl.c (declspecs_add_addrspace): Convert param 1 from

[PATCH 10/22] C++ FE: Use token ranges for various diagnostics

2015-09-10 Thread David Malcolm
Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-09/c++-token-ranges.html gcc/cp/ChangeLog: * parser.c (cp_parser_string_literal): Show ranges of both string literals in the "unsupported concatenation" error. (cp_parser_primary_expression): Use token range rather

[PATCH 06/22] PR/62314: add ability to add fixit-hints

2015-09-10 Thread David Malcolm
This patch adds the ability to add "fix-it hints" to a rich_location, which will be displayed when the corresponding diagnostic is printed. It does not actually add any fix-it hints (that comes in a later patch), but it adds test coverage of the machinery and printing, by using the existing diagno

[PATCH 20/22] Use rich locations in c-family/c-format.c

2015-09-10 Thread David Malcolm
This is a proof-of-concept of (a) using the string-literal location info to show locations of errors in format strings, and (b) underlining the corresponding argument where applicable (no more having to guess what the compiler means by "argument 2") In particular, this can handle format strings

[PATCH 05/22] Add overloads of inform, warning_at, etc that take a source_range

2015-09-10 Thread David Malcolm
Various followup patches convert variables from "location_t" to "source_range". For the places where we issue diagnostics using these variables, it's useful to have overloaded variants of "warning_at" etc that take a source_range, allowing these diagnostics to display underlines without needing to

[PATCH 04/22] Reimplement diagnostic_show_locus, introducing rich_location classes

2015-09-10 Thread David Malcolm
This patch rewrites diagnostic_show_locus so that it can display underlined source ranges in addition to the main caret. It does this by introducing a new "rich_location" class, containing a location and (potentially) some source ranges. These are to be allocated on the stack when generating diag

[PATCH 12/22] Add source-ranges for trees

2015-09-10 Thread David Malcolm
This patch adds a way to associate source range information with tree expressions and decls, for later use by diagnostics. It's a poor implementation which is unacceptable on multiple grounds: for starters, it adds a source_range (8 bytes) to struct tree_exp and to struct tree_decl_minimal. (It a

[PATCH 14/22] C: capture tree ranges for various expressions

2015-09-10 Thread David Malcolm
This patch updates the C frontend to capture source_range information for various kinds of tree expression. It adds a unit test via a plugin, to verify the source ranges are correct for many kinds of expression. Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-09/tree-range-unit-test.ht

[PATCH 15/22] Add plugin to recursively dump the source-ranges in a tree

2015-09-10 Thread David Malcolm
This patch adds a test plugin that recurses down an expression tree, printing diagnostics showing the ranges of each node in the tree. Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-09/show-trees.html This needs a linker hack, since it's the only user of gcc_rich_location::add_expr

[PATCH 19/22] gcc-rich-location.[ch]: add debug methods for cpp_string_location

2015-09-10 Thread David Malcolm
gcc/ChangeLog: * gcc-rich-location.c (cpp_string_fragment_location::debug): New. (cpp_string_location::debug): New. --- gcc/gcc-rich-location.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/gcc/gcc-rich-location.c b/gcc/gcc-rich-location.c index 00

[PATCH 18/22] Track locations within string literals in tree_string

2015-09-10 Thread David Malcolm
This patch uses the string-literal location generated in libcpp in the previous patch, and stores it in tree_string (adding a new field there). This hasn't been optimized. Perhaps the case of a single unbroken run of 1-column per-char is the most common case, so we could only bother to store the

[PATCH 17/22] libcpp: add location tracking within string literals

2015-09-10 Thread David Malcolm
This has not been optimized yet. gcc/c-family/ChangeLog: * c-common.c (fname_as_string): Initialize loc field of "cstr", and call init_raw on strname.loc. * c-lex.c (cb_ident): Initialize loc field of "cstr". libcpp/ChangeLog: * charset.c (struct _cpp_strbuf): Add

[PATCH 16/22] C/C++ frontend: use tree ranges in various diagnostics

2015-09-10 Thread David Malcolm
Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-09/tree-ranges.html This mostly affects the C frontend, but it touches c-common.h so the C++ frontend needs a slight adjustment. gcc/c-family/ChangeLog: * c-common.c: Include gcc-rich-location.h. (binary_op_error): Add par

[PATCH 21/22] Use Levenshtein distance for various misspellings in C frontend

2015-09-10 Thread David Malcolm
Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-10/spellcheck.html There are a couple of FIXMEs here: * where to call levenshtein_distance_unit_tests * should we attempt error-recovery in c-typeck.c:build_component_ref gcc/ChangeLog: * Makefile.in (OBJS): Add spellcheck.o.

[PATCH 22/22] Add fixit hints to spellchecker suggestions

2015-09-10 Thread David Malcolm
Screenshot: https://dmalcolm.fedorapeople.org/gcc/2015-09-10/spellcheck-with-fixits.html gcc/c/ChangeLog: * c-parser.c (c_parser_declaration_or_fndef): Add fix-it hint to "did you mean" suggestion. * c-typeck.c (build_component_ref): Likewise. gcc/testsuite/ChangeLog:

Re: [PATCH 04/22] Reimplement diagnostic_show_locus, introducing rich_location classes

2015-09-11 Thread David Malcolm
On Fri, 2015-09-11 at 16:07 +0200, Michael Matz wrote: > Hi, > > On Thu, 10 Sep 2015, David Malcolm wrote: > > > +/* A range of source locations. > > + > > + Ranges are half-open: > > + m_start is the first location within the range, whereas > > +

Re: [PATCH 00/22] RFC: Overhaul of diagnostics

2015-09-14 Thread David Malcolm
On Mon, 2015-09-14 at 13:42 -0600, Jeff Law wrote: > On 09/14/2015 11:43 AM, Bernd Schmidt wrote: > > It's hard to provide meaningful review under these conditions. My advice > > would be to resubmit the things that are ready now and can stand on > > their own so that we can get them out of the way

Re: [PATCH 07/22] Implement token range tracking within libcpp and C/C++ FEs

2015-09-15 Thread David Malcolm
On Tue, 2015-09-15 at 12:20 +0200, Jakub Jelinek wrote: > On Tue, Sep 15, 2015 at 12:14:22PM +0200, Richard Biener wrote: > > > diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h > > > index 760467c..c7558a0 100644 > > > --- a/gcc/cp/parser.h > > > +++ b/gcc/cp/parser.h > > > @@ -61,6 +61,8 @@ struct G

[PATCH WIP] Use Levenshtein distance for various misspellings in C frontend v2

2015-09-15 Thread David Malcolm
Updated patch attached, which is now independent of the rest of the patch kit; see below. Various other comments inline. On Fri, 2015-09-11 at 17:30 +0200, Manuel López-Ibáñez wrote: On 10/09/15 22:28, David Malcolm wrote: > > There are a couple of FIXMEs here: > > * w

Re: [PATCH] Print repeated rtl vector elements in a nicer way

2016-11-03 Thread David Malcolm
On Thu, 2016-11-03 at 17:43 +0100, Bernd Schmidt wrote: > On 11/03/2016 05:35 PM, Martin Jambor wrote: > > > > * print-rtl.c (print_rtx_operand_codes_E_and_V): Print how many > > times > > an element is repeated istead of printing each repeated > > element. > > "instead" > > > --- > > g

[Ping] Re: [PATCH] Start adding target-specific selftests

2016-11-04 Thread David Malcolm
(ping) https://gcc.gnu.org/ml/gcc-patches/2016-10/msg01785.html On Fri, 2016-10-21 at 13:45 -0400, David Malcolm wrote: > On Fri, 2016-10-21 at 12:04 +0200, Bernd Schmidt wrote: > > On 10/21/2016 02:36 AM, David Malcolm wrote: > > > + /* Test dumping of hard regs. This is

[PATCH] rtx_writer: avoid printing trailing nils

2016-11-04 Thread David Malcolm
On Fri, 2016-10-21 at 12:04 +0200, Bernd Schmidt wrote: > On 10/21/2016 02:36 AM, David Malcolm wrote: > > + ASSERT_RTL_DUMP_EQ ("(cjump_insn (set (pc)\n" > > + "(label_ref 0))\n" > > +

[PATCH] rtx_writer: avoid printing trailing default values

2016-11-04 Thread David Malcolm
On Fri, 2016-11-04 at 18:51 +0100, Bernd Schmidt wrote: > Here's something simpler. Only very lightly tested, but isn't > something > like this all that's needed? Could decide whether to apply it to > expr_list etc. as well. > > Index: print-rtl.c >

Re: [PATCH] rtx_writer: avoid printing trailing default values

2016-11-04 Thread David Malcolm
On Fri, 2016-11-04 at 19:53 +0100, Bernd Schmidt wrote: > On 11/04/2016 08:14 PM, David Malcolm wrote: > > > > With this, compact dumps omit the trailing (nil) for both regular > > insns > > and for JUMP_INSNs, and omits the surplus newline seen in my > > earlie

Re: [PATCH] rtx_writer: avoid printing trailing default values

2016-11-07 Thread David Malcolm
On Fri, 2016-11-04 at 20:40 +0100, Bernd Schmidt wrote: > On 11/04/2016 08:25 PM, David Malcolm wrote: > > > return m_compact; > > Ok with this one plus a comment. > Thanks. Using m_compact required turning the static function into a (private) member function.

Fix build of jit (was Re: [PATCH, RFC] Introduce -fsanitize=use-after-scope (v3))

2016-11-07 Thread David Malcolm
MODE, 0) Is the attached patch OK as a fix? (assuming testing passes) Or should these builtins have other attrs? (sorry, am not very familiar with the sanitizer code). Dave From 6db5f9e50dc95f504d33970ee553172bbf400ae7 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 7 Nov 2016

[PATCH] print_rtx: implement support for reuse IDs (v2)

2016-11-07 Thread David Malcolm
On Tue, 2016-10-25 at 14:47 +0200, Bernd Schmidt wrote: > On 10/21/2016 10:27 PM, David Malcolm wrote: > > Thanks. I attemped to use those fields of recog_data, but it > > doesn't > > seem to be exactly what's needed here. > > Yeah, I may have been confus

[PATCH] DECL_RTL and DECL_RTL_INCOMING in RTL dumps

2016-11-08 Thread David Malcolm
Whilst working on the RTL frontend, I ran into various crashes relating to missing RTL information for params, for DECL_RTL, and DECL_RTL_INCOMING. These are normally set up for a PARM_DECL by "expand", but are currently NULL when reading dumps from print_rtx_function. Attempting to access DECL_R

Re: [PATCH] use-after-scope fallout

2016-11-08 Thread David Malcolm
On Tue, 2016-11-08 at 13:00 +0100, Martin Liška wrote: > Hello. > > This is fallout fix where I changed: > > 1) Fix ICE for lambda functions (added test-case: use-after-scope > -4.C) > 2) Fix ICE in gimplify_switch_expr, at gimplify.c:2269 (fixed by not > adding > artificial variables) > 3) PR te

[PATCH] (v2) print-rtl-function.c: add (param) directive to dump

2016-11-09 Thread David Malcolm
On Wed, 2016-11-09 at 12:59 +0100, Bernd Schmidt wrote: > On 11/08/2016 07:03 PM, David Malcolm wrote: > > int __RTL("rtl-combine") f1 (int n) > > { > > (function "f1" > > (param "n" > > (DECL_RTL > > (reg/v:SI %

Re: [PATCH] (v2) print-rtl-function.c: add (param) directive to dump

2016-11-09 Thread David Malcolm
On Wed, 2016-11-09 at 17:46 +0100, Bernd Schmidt wrote: > On 11/09/2016 05:46 PM, David Malcolm wrote: > > > OK for trunk if it passes bootstrap and regrtest? > > > > gcc/ChangeLog: > > * print-rtl-function.c (print_any_param_name): New function. >

[PATCH 0/9] RTL frontend v4

2016-11-11 Thread David Malcolm
* More test cases. Use "dg-do run" in various places. * Lots of bugfixing I've successfully bootstrapped®rtested the kit as whole on x86_64-pc-linux-gnu. Stage 1 builds and passes selftesting and check-gcc with RUNTESTFLAGS="rtl.exp=*" for target aarch64-linux-gnu. OK for tru

[PATCH 3/9] Introduce emit_status::ensure_regno_capacity

2016-11-11 Thread David Malcolm
Link to earlier version of the patch: https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00278.html gcc/ChangeLog: * emit-rtl.c (gen_reg_rtx): Move regno_pointer_align and regno_reg_rtx resizing logic to... (emit_status::ensure_regno_capacity): ...this new method. (ini

[PATCH 2/9] (approved) Introduce rtl_data::init_stack_alignment

2016-11-11 Thread David Malcolm
(approved by Bernd) Move this part of "expand"'s initialization of crtl into its own method so that it can used by the RTL frontend when postprocessing RTL dumps. gcc/ChangeLog: * cfgexpand.c (pass_expand::execute): Move stack initializations to rtl_data::init_stack_alignment and

[PATCH 6/9] Split class rtx_reader into md_reader vs rtx_reader

2016-11-11 Thread David Malcolm
Link to earlier discussion: https://gcc.gnu.org/ml/gcc-patches/2016-10/msg01690.html This moves read_rtx and friends into rtx_reader, and splits rtx_reader into two classes: class md_reader: has responsibility for reading chars, managing include files, top-level directives etc. It is the read-

[PATCH 1/9] print_rtx: implement support for reuse IDs (v2)

2016-11-11 Thread David Malcolm
Posted earlier here: https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00651.html Link to earlier discussion: https://gcc.gnu.org/ml/gcc-patches/2016-10/msg01801.html This version: - eliminates the rtx_reuse_manager singleton - eliminates print-rtl-reuse.h, moving class rtx_reuse_manager into prin

[PATCH 5/9] Introduce selftest::locate_file (v4)

2016-11-11 Thread David Malcolm
Link to discussion of earlier version of patch: https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00260.html On Wed, 2016-10-05 at 18:10 +0200, Bernd Schmidt wrote: > On 10/05/2016 06:15 PM, David Malcolm wrote: > > selftest: s-selftest > > s-selftest: $(GCC_PASSES) cc1$(exeext

[PATCH 4/9] (approved) Add some functions for use by the RTL frontend.

2016-11-11 Thread David Malcolm
An earlier version of this was approved by Bernd as: https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00280.html and the changes since then probably fall under the "obvious" rule. gcc/ChangeLog: * read-md.c (rtx_reader::require_char): New method. (require_char_ws): Convert from func

[PATCH 9/9] Add "__RTL" to cc1 (v4)

2016-11-11 Thread David Malcolm
Changed in this version: * Rather than running just one pass, run *all* passes, but start at the given pass; support for "dg-do run" tests that execute the resulting code. * Updated test cases to new "compact" dump format; more test cases; use "dg-do run" in various places. * Lots of bugfixi

[PATCH 7/9] Add RTL-error-handling to host

2016-11-11 Thread David Malcolm
Link to previous discussion: https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00648.html On Mon, 2016-10-10 at 19:53 +0100, Richard Sandiford wrote: > David Malcolm writes: > > On Wed, 2016-10-05 at 18:00 +0200, Bernd Schmidt wrote: > > > On 10/05/2016 06:15 PM, D

[PATCH 8/9] Introduce class function_reader (v4)

2016-11-11 Thread David Malcolm
Changed in v4: - error-handling changes split out into a separate patch - rewritten the loader to use the new "compact" dump format - support for reuse_rtx in loader - handling of params, DECL_RTL and DECL_RTL_INCOMING - moved target-dependent selftests to target-specific code (aarch64.c and i386.c

[PATCH] C FE: implement fix-it hint for -Wmissing-braces

2016-11-11 Thread David Malcolm
This patch implements fix-it hints to -Wmissing-braces, showing where to add braces. For example: $ cat test.c int arr_2_3_2[2][3][2] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; $ ./xgcc -B. -c test.c -Wall -fdiagnostics-generate-patch test.c:2:3: warning: missing braces around

Re: [PATCH 3/9] Introduce emit_status::ensure_regno_capacity

2016-11-14 Thread David Malcolm
On Mon, 2016-11-14 at 15:17 +0100, Bernd Schmidt wrote: > On 11/11/2016 10:15 PM, David Malcolm wrote: > > Link to earlier version of the patch: > > https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00278.html > > Isn't this the same one? > It is; sorry. The rest

Re: [PATCH 9/9] Add "__RTL" to cc1 (v4)

2016-11-15 Thread David Malcolm
On Mon, 2016-11-14 at 16:14 +0100, Richard Biener wrote: > On Fri, Nov 11, 2016 at 10:15 PM, David Malcolm > wrote: > > Changed in this version: > > > > * Rather than running just one pass, run *all* passes, but start at > > the given pass; support for &quo

[PATCH] spellcheck bugfixes: don't offer the goal string as a suggestion

2016-11-15 Thread David Malcolm
This patch addresses various bugs in the spellcheck code in which the goal string somehow makes it into the candidate list. The goal string will always have an edit distance of 0 to itself, and thus is the "closest" string to the goal, but offering it as a suggestion will always be nonsensical e.g.

[committed] Fix locations within raw strings

2016-11-17 Thread David Malcolm
Whilst investigating PR preprocessor/78324 I noticed that the substring location code currently doesn't handle raw strings correctly, by not skipping the 'R', opening quote, delimiter and opening parenthesis. For example, an attempt to underline chars 4-7 with caret at 6 of this raw string yields

[PATCH] substring_loc info needs default track-macro-expansion (PR preprocessor/78324)

2016-11-18 Thread David Malcolm
gcc.dg/tree-ssa/builtin-sprintf-2.c is showing intermittent failures, which valgrind shows to be a read past the end of a buffer. The root cause is that the on-demand substring loc code isn't set up to cope with -ftrack-macro-expansion != 2 (the default). In the failing case, it attempts to use t

[PATCH] Introduce emit_status::ensure_regno_capacity (v5)

2016-11-18 Thread David Malcolm
On Wed, 2016-10-05 at 17:55 +0200, Bernd Schmidt wrote: > On 10/05/2016 06:15 PM, David Malcolm wrote: > > - /* Make sure regno_pointer_align, and regno_reg_rtx are large > > - enough to have an element for this pseudo reg number. */ > > +

[PATCH] Add "__RTL" to cc1 (v5)

2016-11-18 Thread David Malcolm
On Wed, 2016-11-16 at 14:24 +0100, Richard Biener wrote: > On Tue, Nov 15, 2016 at 10:07 PM, David Malcolm > wrote: > > On Mon, 2016-11-14 at 16:14 +0100, Richard Biener wrote: > > > On Fri, Nov 11, 2016 at 10:15 PM, David Malcolm < > > > dmalc...@redhat.com>

Re: [PATCH] substring_loc info needs default track-macro-expansion (PR preprocessor/78324)

2016-11-18 Thread David Malcolm
On Fri, 2016-11-18 at 09:51 -0700, Martin Sebor wrote: > > Martin: are the changes to your test cases OK by you, or is there > > a better way to rewrite them? > > Thanks for looking into it! > > Since the purpose of the test_sprintf_note function in the test is > to verify the location of the car

[PATCH] Handle EOF in c_parser_parse_rtl_body

2016-11-18 Thread David Malcolm
On Fri, 2016-11-18 at 22:13 +, Joseph Myers wrote: > On Fri, 18 Nov 2016, David Malcolm wrote: > > > + /* Consume all tokens, up to the closing brace, handling > > + matching pairs of braces in the rtl dump. */ > > + int num_open_braces = 1; > > + while (1

[committed] substring_loc info needs default track-macro-expansion (PR preprocessor/78324)

2016-11-21 Thread David Malcolm
On Fri, 2016-11-18 at 15:47 -0700, Martin Sebor wrote: > On 11/18/2016 03:57 PM, David Malcolm wrote: > > On Fri, 2016-11-18 at 09:51 -0700, Martin Sebor wrote: > > > > Martin: are the changes to your test cases OK by you, or is > > > > there >

Re: [PATCH] (v2) Add a "compact" mode to print_rtx_function

2016-11-22 Thread David Malcolm
On Tue, 2016-11-22 at 14:37 +0100, Jakub Jelinek wrote: > On Tue, Nov 22, 2016 at 02:32:39PM +0100, Bernd Schmidt wrote: > > On 11/22/2016 02:18 PM, Dominik Vogt wrote: > > > > > > @@ -284,7 +292,7 @@ print_rtx_operand_code_i (const_rtx in_rtx, > > > > int idx) > > > > if (INSN_HAS_LOCATION

Re: [PATCH] (v2) Add a "compact" mode to print_rtx_function

2016-11-22 Thread David Malcolm
Does this fix the failing tests? From 642d511fdba3a33fb18ce46c549f7c972ed6b14e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 22 Nov 2016 11:06:41 -0500 Subject: [PATCH] print-rtl.c: conditionalize quotes for filenames gcc/ChangeLog: * print-rtl.c (rtx_writer::print_rtx_operand_code_i):

Re: [PATCH 8/9] Introduce class function_reader (v4)

2016-11-23 Thread David Malcolm
On Wed, 2016-11-23 at 21:15 +0100, Bernd Schmidt wrote: > On 11/11/2016 10:15 PM, David Malcolm wrote: > > > +static void > > +aarch64_test_loading_full_dump () > > +{ > > + rtl_dump_test t (SELFTEST_LOCATION, locate_file ("aarch64/times > > -two.rtl&

[PATCH 2/3] Fix range/location terminology

2015-12-11 Thread David Malcolm
The terminology within rich_location has become muddled, and with the simplifications of the previous patch, I'd like to rename things to better reflect what's going on. A rich_location can contain one more more nested locations, each of which can have a start, a finish, and optionally a caret. Th

[PATCH 1/3] Delay location expansion within rich_location until printing

2015-12-11 Thread David Malcolm
Previously, source_location/location_t values passed to rich_location were immediately expanded (to expanded_location instances stored inside the rich_location). This patch updates the insides of class rich_location to delay this expansion until the insides of diagnostic_show_locus. This simplifi

[PATCH 3/3] PR c/68473: sanitize source range-printing within certain macro expansions (v2)

2015-12-11 Thread David Malcolm
Changes in v2: - add two more testcases, based on additional reproducers reported (one to the PR, another to a dup); now adds 17 PASS results to gcc.sum. - update for delayed expansion of locations within rich_location and the terminology fixes from the other patches in this kit. A

[PATCH 0/3] Re: [PATCH] PR c/68473: sanitize source range-printing within certain macro expansions

2015-12-11 Thread David Malcolm
On Tue, 2015-11-24 at 13:43 +0100, Bernd Schmidt wrote: > On 11/23/2015 07:26 PM, David Malcolm wrote: > > > > In theory we could attempt to try to handle this kind of thing by > > looking at the macro expansions, and to print something like: > > >

[PATCH] C FE: use correct location range for static assertions

2015-12-15 Thread David Malcolm
When issuing diagnostics for _Static_assert, we currently ignore the location/range of the asserted expression, and instead use the location/range of the first token within it, which can be incorrect for compound expressions: error: expression in static assertion is not constant _Static_assert

[PATCH] C++ FE: Show both locations in string literal concatenation error

2015-12-15 Thread David Malcolm
We can use rich_location and the new diagnostic_show_locus to print *both* locations when complaining about a bogus string concatenation in the C++ FE, giving e.g.: test.C:3:24: error: unsupported non-standard concatenation of string literals const void *s = u8"a" u"b"; ~ ^

[PATCH] Better error recovery for merge-conflict markers (v5)

2015-12-15 Thread David Malcolm
On Wed, 2015-12-09 at 18:44 +0100, Bernd Schmidt wrote: > On 12/09/2015 05:58 PM, David Malcolm wrote: > > On Wed, 2015-11-04 at 14:56 +0100, Bernd Schmidt wrote: > >> > >> This seems like fairly low impact but also low cost, so I'm fine with it > >> in

[PATCH] C FE: fix range of primary-expression in c_parser_postfix_expression

2015-12-15 Thread David Malcolm
In the C frontend, c_parser_postfix_expression after parsing a primary expression passes "loc", the location of the *first token* in that expression to c_parser_postfix_expression_after_primary, which thus discards any range information we had for primary expressions containing more than one to

Re: C PATCH for c/64637 (better location for -Wunused-value)

2015-12-16 Thread David Malcolm
On Wed, 2015-12-16 at 15:58 +0100, Marek Polacek wrote: > The following improves the location for "statement with no effect" warning by > using the location of the expression if available. Can't use EXPR_LOCATION as > *_DECLs still don't carry a location. Out of interest, does it emit sane underl

Re: C PATCH for c/64637 (better location for -Wunused-value)

2015-12-16 Thread David Malcolm
On Wed, 2015-12-16 at 16:09 +0100, Marek Polacek wrote: > On Wed, Dec 16, 2015 at 10:04:05AM -0500, David Malcolm wrote: > > On Wed, 2015-12-16 at 15:58 +0100, Marek Polacek wrote: > > > The following improves the location for "statement with no effect" > > >

[PATCH] C and C++ FE: better source ranges for binary ops

2015-12-16 Thread David Malcolm
Currently trunk emits range information for most bad binary operations in the C++ frontend; but not in the C frontend. The helper function binary_op_error shared by C and C++ takes a location_t. In the C++ frontend, a location_t containing the range has already been built, so we get the underline

Re: [PATCH] Better error recovery for merge-conflict markers (v4)

2015-12-16 Thread David Malcolm
On Wed, 2015-12-09 at 18:44 +0100, Bernd Schmidt wrote: > On 12/09/2015 05:58 PM, David Malcolm wrote: > > On Wed, 2015-11-04 at 14:56 +0100, Bernd Schmidt wrote: > >> > >> This seems like fairly low impact but also low cost, so I'm fine with it > >> in

Re: [PATCH] Better error recovery for merge-conflict markers (v5)

2015-12-16 Thread David Malcolm
On Wed, 2015-12-16 at 00:52 +0100, Bernd Schmidt wrote: > On 12/15/2015 08:30 PM, David Malcolm wrote: > > > I got thinking about what we'd have to do to support Perforce-style > > markers, and began to find my token-matching approach to be a little > > clunky

[PATCH] C FE: improvements to ranges of bad return values

2015-12-16 Thread David Malcolm
In the C FE, c_parser_statement_after_labels passes "xloc" to c_finish_return, which is the location of the first token within the returned expression. Hence we don't get a full underline for the following: diagnostic-range-bad-return.c:34:10: warning: function returns address of local variable

[PATCH] PR c++/68795: fix uninitialized close_paren_loc in cp_parser_postfix_expression

2015-12-17 Thread David Malcolm
cp_parser_parenthesized_expression_list can leave *close_paren_loc untouched if an error occurs; specifically when following this goto: 7402 if (expr == error_mark_node) 7403goto skip_comma; which can lead to cp_parser_postfix_expression attempting to use uninitialize

[PATCH] PR c++/68795: fix uninitialized close_paren_loc in cp_parser_postfix_expression (v2)

2015-12-18 Thread David Malcolm
On Thu, 2015-12-17 at 19:21 +0100, Bernd Schmidt wrote: > On 12/17/2015 07:32 PM, David Malcolm wrote: > > + if (close_paren_loc) > > close_paren_loc != UNKNOWN_LOCATION - it's very confusing otherwise. > > > Bernd Here's an updated ve

[PATCH 1/2] libcpp: Avoid unnecessary ad-hoc uses for large source files

2015-12-18 Thread David Malcolm
When debugging PR c++/68819 I noticed an inefficiency during the handling of locations > LINE_MAP_MAX_LOCATION_WITH_COLS. When combining ranges for locations with start == caret == finish (with a NULL data ptr) get_combined_adhoc_loc was always building an ad-hoc entry rather than simply returnin

[PATCH 2/2] PR c++/68819: libcpp fallbacks and -Wmisleading-indentation

2015-12-18 Thread David Malcolm
libcpp has a degraded fallback mode for large source files where if a location_t > LINE_MAP_MAX_LOCATION_WITH_COLS we fall back to just tracking lines, not columns&ranges (currently 0x6000), and every location_t expands to having a column == 0. Sadly we're more likely to see this case in gcc 6

[PATCH 2/4] PR c++/62314: add fixit hint for "expected ';' after class definition"

2015-12-18 Thread David Malcolm
Looking over the discussion of missing semicolons in "Quality of Implementation and Attention to Detail" within http://clang.llvm.org/diagnostics.html and comparing with https://gcc.gnu.org/wiki/ClangDiagnosticsComparison I noticed that of the cases we do handle [1], there's room for improvem

[PATCH 1/4] PR c++/62314: add fixit hint for missing "template <> " in explicit specialization

2015-12-18 Thread David Malcolm
The following patch adds a fix-it insertion hint for missing "template <> " in explicit specializations. This is more of an enhancement than a bug fix (PR 62314 is more of a catch-all for adding fix-its), but it's low-risk and a user-visible improvement, and this specific example is called out as

[PATCH 3/4] PR c++/62314: C++: add fixit hint to misspelled member names

2015-12-18 Thread David Malcolm
When we emit a hint about a misspelled member name, it will slightly aid readability if we use a fixit-hint to show the proposed name in context within the source code (and in the future this might support some kind of auto-apply in an IDE). This patch adds such a hint to the C++ frontend, taking

[PATCH 4/4] C: add fixit hint to misspelled field names

2015-12-18 Thread David Malcolm
Similar to the C++ case in the previous patch, but more involved as the location of the pertinent token isn't readily available; the patch adds it as a param to build_component_ref. All callers are updated to provide the info, apart from objc_build_component_ref; fixing the latter would lead to a

[PATCH] C: fix reported range of invalid unary dereference.

2015-12-22 Thread David Malcolm
Currently, trunk emits this for a bad unary * in C: bad-dereference.c:10:10: error: invalid type argument of unary ‘*’ (have ‘int’) return *some_f.x; ^ The following patch fixes the reported location to highlight the expression that was attempted to be dereferenced: bad-dereference.

[PATCH] Fix PR c/69122 (-Wmisleading-indentation false positive with empty macros)

2016-01-05 Thread David Malcolm
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. OK for trunk? gcc/c-family/ChangeLog: PR c/69122 * c-indentation.c (get_visual_column): Remove default argument. (should_warn_for_misleading_indentation): For the multiline case, update call to get_visual_col

Re: [C++ PATCH] Fix #pragma implementation diagnostics (PR c++/69145)

2016-01-05 Thread David Malcolm
On Tue, 2016-01-05 at 19:23 +0100, Jakub Jelinek wrote: > Hi! > > Now that input_location can be adhoc location (if it represents a location > range rather than a single loc and it is long enough), we need to avoid > passing it to cpp_included_before which compares locations as numbers. > This can

Re: [PATCH] Fix -Wmisleading indentation false-positive for do-while statement

2016-01-05 Thread David Malcolm
On Tue, 2015-12-22 at 12:33 -0500, Patrick Palka wrote: > We are emitting a bogus warning for the code > > do foo (0); while (flagA); > ^--- NEXT > ^ BODY > ^--- GUARD > > In general I don't think we can get any useful indentation warning out > of a

[wwwdocs] gcc-6/changes.html: diagnostics, Levenshtein, -Wmisleading-indentation, jit

2016-01-06 Thread David Malcolm
The attached patch adds information on various things to the gcc-6/changes.html page: * source-range-tracking (the patch merges the description of the string location work into this, and updates the colorization of the example to reflect gcc-6's behavior) * fix-it hints * hints for misspelled memb

Re: [PATCH] v3 of diagnostic_show_locus and rich_location (was Re: [PATCH 2/5] Reimplement diagnostic_show_locus, introducing rich_location classes (v2))

2016-01-06 Thread David Malcolm
On Tue, 2015-12-29 at 12:53 -0800, Mike Stump wrote: > On Sep 25, 2015, at 1:11 PM, David Malcolm > wrote: > > +layout::layout (diagnostic_context * context, > >> + const diagnostic_info *diagnostic) > >> > >> [...] > >> > >

[ping] pending patches

2016-01-06 Thread David Malcolm
PR c++/68795: fix uninitialized close_paren_loc in cp_parser_postfix_expression (v2): https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01915.html [PATCH 1/4] PR c++/62314: add fixit hint for missing "template <> " in explicit specialization: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01933.ht

Re: [PATCH 2/2] PR c++/68819: libcpp fallbacks and -Wmisleading-indentation

2016-01-06 Thread David Malcolm
On Mon, 2015-12-21 at 14:10 -0700, Jeff Law wrote: > On 12/18/2015 01:21 PM, David Malcolm wrote: > > > I don't think there's a way to fix -Wmisleading-indentation if we're > > in this state, so the first part of the following patch detects if > > this

Re: [PATCH 2/2] PR c++/68819: libcpp fallbacks and -Wmisleading-indentation

2016-01-06 Thread David Malcolm
On Mon, 2015-12-21 at 22:20 +0100, Jakub Jelinek wrote: > On Mon, Dec 21, 2015 at 02:10:17PM -0700, Jeff Law wrote: > > On 12/18/2015 01:21 PM, David Malcolm wrote: > > > > >I don't think there's a way to fix -Wmisleading-indentation if we're > > >i

[PATCH] PR preprocessor/69177 and PR c++/68819: libcpp fallbacks and -Wmisleading-indentation (v2)

2016-01-08 Thread David Malcolm
On Mon, 2015-12-21 at 14:10 -0700, Jeff Law wrote: > On 12/18/2015 01:21 PM, David Malcolm wrote: > > > I don't think there's a way to fix -Wmisleading-indentation if we're > > in this state, so the first part of the following patch detects if > > this

[PATCH] PR testsuite/69181: ensure expected multiline outputs is cleared per-test

2016-01-08 Thread David Malcolm
The root cause here is that the logic to reset the list of expected multiline outputs was being run from: handle-multiline-outputs, called by prune.exp's prune_gcc_output and none of that happens if the test is skipped by a target exclusion in dg-do. This patch moves the clearing of the rele

Re: [PATCH] PR c++/68795: fix uninitialized close_paren_loc in cp_parser_postfix_expression (v2)

2016-01-11 Thread David Malcolm
On Mon, 2016-01-11 at 16:51 +0100, Bernd Schmidt wrote: > On 12/18/2015 08:05 PM, David Malcolm wrote: > > On Thu, 2015-12-17 at 19:21 +0100, Bernd Schmidt wrote: > >> On 12/17/2015 07:32 PM, David Malcolm wrote: > >>> + if (close_paren_

<    29   30   31   32   33   34   35   36   37   38   >