[PATCH 10/17] C++: provide fix-it hints in -Wsuggest-override

2017-07-24 Thread David Malcolm
This patch to the C++ frontend extends -Wsuggest-override so that the suggestions contain fix-it hints, provided that it can get at the correct location. Doing so requires the blt_node infrastructure. gcc/cp/ChangeLog: * class.c: Include "gcc-rich-location.h" and "blt.h". (check_f

[PATCH 12/17] Add server.h and server.c

2017-07-24 Thread David Malcolm
This patch adds a "server" abstract base class for listening on a port, for use by the later patches to implement an LSP server. It's largely adapted from examples in glibc's docs. I suspect that I've introduced platform-specific assumptions (and that it may need some extra configure tests for th

[PATCH 13/17] Add http-server.h and http-server.c

2017-07-24 Thread David Malcolm
This patch implements an abstract class of HTTP server, as a subclass of the server class implemented in the previous patch. gcc/ChangeLog: * Makefile.in (OBJS): Add http-server.o. * http-server.c: New file. * http-server.h: New file. * selftest-run-tests.c (selftes

[PATCH 17/17] Language Server Protocol: work-in-progess on testsuite

2017-07-24 Thread David Malcolm
This file adds the beginnings of a testsuite for the LSP implementation. The test cases are implemented in Python; they aren't currently wired up to DejaGnu (I've been invoking them manually). There's an automated test case, and a PyGTK UI. Both require the language server to be manually started

[PATCH 15/17] Language Server Protocol: add lsp::server abstract base class

2017-07-24 Thread David Malcolm
This patch adds an lsp::server abstract base class for implementing servers for the Language Server Protocol: https://github.com/Microsoft/language-server-protocol along with supporting classes mirroring those from the protocol description. The public specification of the protocol uses CamelCas

[PATCH 11/17] Add JSON implementation

2017-07-24 Thread David Malcolm
This patch is the first part of the Language Server Protocol server proof-of-concept. It adds support to gcc for reading and writing JSON, based on DOM-like trees of "json::value" instances. gcc/ChangeLog: * Makefile.in (OBJS): Add json.o. * json.c: New file. * json.h: New

[PATCH 07/17] C++: use BLT to highlight parameter of callee decl for mismatching types

2017-07-24 Thread David Malcolm
This patch to the C++ frontend uses the BLT infrastructure to improve: extern int callee_1 (int one, const char *two, float three); int test_1 (int first, int second, float third) { return callee_1 (first, second, third); } from: error: invalid conversion from 'int' to 'const char

[PATCH 14/17] Add implementation of JSON-RPC

2017-07-24 Thread David Malcolm
This patch adds an abstract base class for implementing JSON-RPC 2.0 servers, along with a class for wiring them up to the HTTP server class implemented in the previous patch, supporting the serving of JSON-RPC over HTTP on a port. gcc/ChangeLog: * Makefile.in (OBJS): Add json-rpc.o.

[PATCH 06/17] C: use BLT to highlight parameter of callee decl for mismatching types

2017-07-24 Thread David Malcolm
This patch to the C frontend uses the BLT infrastructure to improve: extern int callee_1 (int one, const char *two, float three); int test_1 (int first, int second, float third) { return callee_1 (first, second, third); } from: warning: passing argument 2 of 'callee_1' makes point

[PATCH 09/17] C++: highlight return types when complaining about mismatches

2017-07-24 Thread David Malcolm
This patch to the C++ frontend uses the BLT infrastructure to highlight the return type of a function when complaining about code within the function that doesn't match it. For example, given: error: return-statement with a value, in function returning 'void' [-fpermissive] return 42;

[PATCH 08/17] C: highlight return types when complaining about mismatches

2017-07-24 Thread David Malcolm
This patch to the C frontend uses the BLT infrastructure to highlight the return type of a function when complaining about code within the function that doesn't match it. For example, given: warning: 'return' with a value, in function returning void return 42; ^~ note: declar

[PATCH 04/17] C frontend: capture BLT information

2017-07-24 Thread David Malcolm
This patch extends the C frontend so that it optionally builds a BLT tree, by using an auto_blt_node class within the recursive descent through the parser, so that its ctor/dtors build the blt_node hierarchy; this is rapidly (I hope) rejected in the no -fblt case, so that by default, no blt nodes a

[PATCH 05/17] C++ frontend: capture BLT information

2017-07-24 Thread David Malcolm
This patch extends the C++ frontend so that it optionally builds a BLT tree, by using an auto_blt_node class within the recursive descent through the parser, so that its ctor/dtors build the blt_node hierarchy; this is rapidly (I hope) rejected in the no -fblt case, so that by default, no blt nodes

[PATCH 16/17] Language Server Protocol: proof-of-concept GCC implementation

2017-07-24 Thread David Malcolm
This patch implements a concrete subclass of the lsp::server class implemented in the previous patch, wiring it up to GCC's internal representation. The patch is very much just a proof-of-concept; the only method it implements is "textDocument/definition" i.e. "report the definition of the symbol

Re: c-family PATCH to improve -Wsign-compare (PR c/81417)

2017-07-25 Thread David Malcolm
On Fri, 2017-07-14 at 15:27 +0200, Marek Polacek wrote: > On Thu, Jul 13, 2017 at 04:59:20PM -0400, David Malcolm wrote: > > On Thu, 2017-07-13 at 16:39 -0400, Eric Gallager wrote: > > > On 7/13/17, David Malcolm wrote: > > > > On Thu, 2017-07-13 at 18:33 +0200, Ma

Re: [PATCH 12/17] Add server.h and server.c

2017-07-26 Thread David Malcolm
On Wed, 2017-07-26 at 23:35 +0900, Oleg Endo wrote: > On Mon, 2017-07-24 at 16:05 -0400, David Malcolm wrote: > > > > + > > +You should have received a copy of the GNU General Public License > > +along with GCC; see the file COPYING3. If not see > &

Re: [PATCH 0/2] Python testcases to check DWARF output

2017-07-26 Thread David Malcolm
On Wed, 2017-07-26 at 18:00 +0200, Pierre-Marie de Rodat wrote: > Hello, > > At the last GNU Cauldron, Richard Biener and I talked about DWARF > output > testing. Except for guality tests, which are disabled on several > targets, the only way tests check the DWARF is scanning the annotated > assem

Re: [PATCH 1/2] Introduce testsuite support to run Python tests

2017-07-26 Thread David Malcolm
On Wed, 2017-07-26 at 18:00 +0200, Pierre-Marie de Rodat wrote: [...snip...] > diff --git a/gcc/testsuite/python/testutils.py > b/gcc/testsuite/python/testutils.py > new file mode 100644 > index 000..503105ad9d0 > --- /dev/null > +++ b/gcc/testsuite/python/testutils.py > @@ -0,0 +1,45 @@ >

Re: [PATCH 1/2] Introduce testsuite support to run Python tests

2017-07-26 Thread David Malcolm
On Wed, 2017-07-26 at 18:35 +0200, Pierre-Marie de Rodat wrote: > On 07/26/2017 06:25 PM, David Malcolm wrote: > > str.format was introduced in Python 2.6, so presumably the minimum > > python 2 version here is at least 2.6+; for Python 3 I believe it > > was > > pr

Re: [PATCH 2/2] Introduce Python testcases to check DWARF output

2017-07-26 Thread David Malcolm
On Wed, 2017-07-26 at 18:00 +0200, Pierre-Marie de Rodat wrote: [...] > diff --git a/gcc/testsuite/python/dwarfutils/__init__.py > b/gcc/testsuite/python/dwarfutils/__init__.py > new file mode 100644 > index 000..246fbbd15be > --- /dev/null > +++ b/gcc/testsuite/python/dwarfutils/__init__.p

Re: [PATCH 1/2] Introduce testsuite support to run Python tests

2017-07-27 Thread David Malcolm
On Thu, 2017-07-27 at 10:49 +0200, Pierre-Marie de Rodat wrote: > On 07/26/2017 06:48 PM, David Malcolm wrote: > > IIRC RHEL 6 has Python 2.6 as its /usr/bin/python (but Python 2.7 > > is > > available as a "software collection" add-on). > > > > I d

Re: c-family PATCH to improve -Wsign-compare (PR c/81417)

2017-07-27 Thread David Malcolm
On Thu, 2017-07-27 at 16:42 +0200, Marek Polacek wrote: > On Tue, Jul 25, 2017 at 11:03:12AM -0400, David Malcolm wrote: > > Thanks for updating the patch. > > > > There's still an issue with ordering in the updated patch. > > > > There are three orde

[PATCH] C++: fix ordering of missing std #include suggestion (PR c++/81514)

2017-07-27 Thread David Malcolm
PR c++/81514 reports a problem where g++.dg/lookup/missing-std-include-2.C fails on Solaris, offering the suggestion: error: 'string' is not a member of 'std' note: suggested alternative: 'sprintf' instead of the expected: error: 'string' is not a member of 'std' note: 'std::string' is

Re: [PATCH 00/17] RFC: New source-location representation; Language Server Protocol

2017-07-28 Thread David Malcolm
On Thu, 2017-07-27 at 13:51 -0600, Martin Sebor wrote: > I think this is great. My overall question is: is the new BLT > representation available in the middle-end? Given that, err, I'm not freeing it anywhere yet (ahem), the answer is yes. Although it lives in the "gcc" dir, the generated tre

Re: [PATCH 15/17] Language Server Protocol: add lsp::server abstract base class

2017-07-28 Thread David Malcolm
On Thu, 2017-07-27 at 00:14 -0400, Trevor Saunders wrote: > On Mon, Jul 24, 2017 at 04:05:12PM -0400, David Malcolm wrote: > > This patch adds an lsp::server abstract base class for implementing > > servers for the Language Server Protocol: > > https://github.com/Micr

Re: [PATCH 15/17] Language Server Protocol: add lsp::server abstract base class

2017-07-28 Thread David Malcolm
On Thu, 2017-07-27 at 09:55 +0200, Richard Biener wrote: > On Mon, Jul 24, 2017 at 10:05 PM, David Malcolm > wrote: > > This patch adds an lsp::server abstract base class for implementing > > servers for the Language Server Protocol: > > https://github.com/Microsoft/

Re: C PATCH to further improve diagnostic for -Wsign-compare (PR c/81417)

2017-07-31 Thread David Malcolm
On Mon, 2017-07-31 at 16:14 +0200, Marek Polacek wrote: > This patch improves the diagnostic of -Wsign-compare for ?: by also > printing > the types, similarly to my recent patch. But we can do even better > here if we > actually point to the operand in question, so I passed the locations > of the

Re: [PATCH 0/2] add unique_ptr class

2017-07-31 Thread David Malcolm
On Mon, 2017-07-31 at 19:46 -0400, tbsaunde+...@tbsaunde.org wrote: > From: Trevor Saunders > > Hi, > > I've been saying I'd do this for a long time, but I'm finally getting > to > importing the C++98 compatable unique_ptr class Pedro wrote for gdb a > while > back. I believe the gtl namespace

Re: [PATCH 1/2] add unique_ptr header

2017-08-01 Thread David Malcolm
On Mon, 2017-07-31 at 19:46 -0400, tbsaunde+...@tbsaunde.org wrote: > From: Trevor Saunders > > For most of the history of this see > https://sourceware.org/ml/gdb-patches/2016-10/msg00223.html > The changes are mostly s/gdb/gtl/g > > include/ChangeLog: > > 2017-07-29 Trevor Saunders > >

[PATCH 1/3] matching tokens: c-family parts

2017-08-01 Thread David Malcolm
(Unchanged since v1; already approved by Marek, assuming rest is approved) gcc/c-family/ChangeLog: * c-common.c (c_parse_error): Add rich_location * param, using it rather implicitly using input_location. * c-common.h (c_parse_error): Add rich_location * param. gcc/testsui

[PATCH 0/3 v2] C/C++: show pertinent open token when missing a close token

2017-08-01 Thread David Malcolm
On Wed, 2017-07-12 at 09:13 -0400, Trevor Saunders wrote: > On Tue, Jul 11, 2017 at 11:24:45AM -0400, David Malcolm wrote: > > +/* Some tokens naturally come in pairs e.g.'(' and ')'. > > + This class is for tracking such a matching pair of symbols. > >

[PATCH 2/3] Matching tokens: C parts (v2)

2017-08-01 Thread David Malcolm
Changed in v2: * Renamed template argument to traits_t; eliminated subclasses, just using traits struct. * Moved enum constants into struct bodies (string constants can't be without constexpr, which isn't available in C++98). * Fixed typo. OK for trunk? gcc/c/ChangeLog: * c-parser.c

[PATCH 3/3] matching tokens: C++ parts (v2)

2017-08-01 Thread David Malcolm
Changed in v2: * Renamed template argument to traits_t; eliminated subclasses, just using traits struct. * Moved constants into struct bodies. * Fixed typo. OK for trunk? gcc/cp/ChangeLog: * parser.c (cp_parser_error): Update for new param to c_parse_error. (class token

Re: C PATCH to further improve diagnostic for -Wsign-compare (PR c/81417)

2017-08-01 Thread David Malcolm
On Mon, 2017-07-31 at 18:05 +0200, Marek Polacek wrote: > On Mon, Jul 31, 2017 at 09:54:03AM -0600, Martin Sebor wrote: > > On 07/31/2017 08:14 AM, Marek Polacek wrote: > > > This patch improves the diagnostic of -Wsign-compare for ?: by > > > also printing > > > the types, similarly to my recent p

Re: C PATCH to further improve diagnostic for -Wsign-compare (PR c/81417)

2017-08-01 Thread David Malcolm
On Tue, 2017-08-01 at 16:15 +0200, Marek Polacek wrote: > On Mon, Jul 31, 2017 at 11:31:44AM -0400, David Malcolm wrote: > > On Mon, 2017-07-31 at 16:14 +0200, Marek Polacek wrote: > > > This patch improves the diagnostic of -Wsign-compare for ?: by > > > also >

Re: [PATCH][RFC] Make expansion of balanced binary trees of switches on tree level.

2017-08-02 Thread David Malcolm
On Wed, 2017-08-02 at 13:20 +0200, Martin Liška wrote: > Hello. > > After some discussions with Honza, I've decided to convert current > code in stmt.c that > is responsible for switch expansion. More precisely, I would like to > convert the code > to expand gswitch statements on tree level. Curre

Re: [PATCH 2/3] Matching tokens: C parts (v2)

2017-08-04 Thread David Malcolm
On Thu, 2017-08-03 at 11:34 -0600, Jeff Law wrote: > On 08/01/2017 02:21 PM, David Malcolm wrote: > > Changed in v2: > > > > * Renamed template argument to traits_t; eliminated subclasses, > > just > > using traits struct. > > * Moved enum constants int

[PATCH 02/22] libcpp: add linemap_position_for_file_line_and_column

2017-08-04 Thread David Malcolm
gcc/ChangeLog: * input.c (selftest::test_making_arbitrary_locations): New function. (selftest::input_c_tests): Call it. libcpp/ChangeLog: * include/line-map.h (linemap_position_for_file_line_and_column): New decl. * line-map.c (linemap_position_for_file_line

[PATCH 01/22] Expose assert_loceq outside of input.c; add ASSERT_LOCEQ

2017-08-04 Thread David Malcolm
gcc/ChangeLog: * input.c: Include "selftest-input.h". (selftest::assert_loceq): Remove "static". Add "report_loc" param and update assertions to use it. (selftest::test_accessing_ordinary_linemaps): Use ASSERT_LOCEQ rather than assert_loceq. (selftes

[PATCH 00/22] RFC: integrated 3rd-party static analysis support

2017-08-04 Thread David Malcolm
the output from the tool into the common JSON format. Some notes on the data model can be seen here: http://firehose.readthedocs.io/en/latest/data-model.html (though that's expressed as Python objects and XML, rather than the JSON format). Successfully bootstrapped®rtested the co

[PATCH 03/22] Add JSON implementation

2017-08-04 Thread David Malcolm
This patch adds support to gcc for reading and writing JSON, based on DOM-like trees of json::value instances. gcc/ChangeLog: * Makefile.in (OBJS): Add json.o. * json.cc: New file. * json.h: New file. * selftest-run-tests.c (selftest::run_tests): Call json_cc_tests.

[PATCH 17/22] Add checkers/cppcheck.py

2017-08-04 Thread David Malcolm
0..9b6a864 --- /dev/null +++ b/checkers/cppcheck.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# Copyright 2012, 2013, 2015, 2017 David Malcolm +# Copyright 2012, 2013, 2015, 2017 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the G

[PATCH 08/22] Add GNU_BUILD_ATTRIBUTE_STATIC_ANALYSIS to annobin.h

2017-08-04 Thread David Malcolm
gcc/ChangeLog: * annobin.h (GNU_BUILD_ATTRIBUTE_STATIC_ANALYSIS): New define. --- gcc/annobin.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/annobin.h b/gcc/annobin.h index 76eb01c..1152316 100644 --- a/gcc/annobin.h +++ b/gcc/annobin.h @@ -35,6 +35,7 @@ #define GNU_BUILD_ATTRI

[PATCH 19/22] Add checkers/ianal.py

2017-08-04 Thread David Malcolm
s diagnostic subsystem by checker.cc, these "info" results are emitted as notes, e.g.: ../../src/checkers/test-sources/cpychecker-demo.c:2:4: note: I am not a lawyer [not-a-lawyer:copyright-line] Copyright 2011 David Malcolm ^ ../../src/checkers/test-sources/cpychecker-

[PATCH 07/22] Add minimal version of Nick Clifton's annobin code

2017-08-04 Thread David Malcolm
auto-profile.o \ bb-reorder.o \ diff --git a/gcc/annobin.cc b/gcc/annobin.cc new file mode 100644 index 000..ad8e49a --- /dev/null +++ b/gcc/annobin.cc @@ -0,0 +1,185 @@ +/* annobin - support for annotating binary files. + Copyright (c) 2017 Red Hat. + Created by Nick Clifton

[PATCH 10/22] Add checkers.h/cc

2017-08-04 Thread David Malcolm
This implements a new "policy" class to read a description of a set of checkers to run, along with a "checker" class to handle actually running the checkers, ouputting the results through gcc's diagnostic subsystem, and watermarking the generated binary with the results and metadata. Caveats: * t

[PATCH 22/22] Add contrib/get-static-analysis.py

2017-08-04 Thread David Malcolm
This patch adds a simple Python 2/3 script for reading the static analysis "watermark" from object files, writing the JSON to stdout (prettyprinting it with indentation and newlines for ease of human reading). contrib/ChangeLog: * get-static-analysis.py: New file. --- contrib/get-static-a

[PATCH 09/22] Add selftest::read_file (..., FILE *, ...)

2017-08-04 Thread David Malcolm
This patch is a hack used by the followup checkers.cc patch, and ought to be removed in any final version of the kit. gcc/ChangeLog: * selftest.c (read_file): New overload. * selftest.h (read_file): New overload. --- gcc/selftest.c | 16 +--- gcc/selftest.h | 7 ++

[PATCH 11/22] Add checkers/test-sources

2017-08-04 Thread David Malcolm
/cpychecker-demo.c new file mode 100644 index 000..b379729 --- /dev/null +++ b/checkers/test-sources/cpychecker-demo.c @@ -0,0 +1,110 @@ +/* + Copyright 2011 David Malcolm + Copyright 2011 Red Hat, Inc. + + This is free software: you can redistribute it and/or modify it + under the terms of

[PATCH 16/22] Add checkers/coverity.py

2017-08-04 Thread David Malcolm
!/usr/bin/env python +# Copyright 2017 David Malcolm +# Copyright 2017 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License,

[PATCH 04/22] Add firehose.h/cc

2017-08-04 Thread David Malcolm
"Firehose" is a serialization format for results from code analysis tools: http://firehose.readthedocs.io/en/latest/index.html (along with a Python module for working with the format). This patch implements a set of C++ classes modeling the format, with support for populating them from a JSON

[PATCH 15/22] Add checkers/clang_analyzer.py

2017-08-04 Thread David Malcolm
00755 index 000..ae41d93 --- /dev/null +++ b/checkers/clang_analyzer.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +# Copyright 2012, 2013, 2015, 2017 David Malcolm +# Copyright 2012, 2013, 2015, 2017 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +#

[PATCH 06/22] Makefile.in: hack in -lpthread

2017-08-04 Thread David Malcolm
The checker.cc patch later in the kit can optionally make use of pthread if available. Doing it properly would involve some configure checks; this patch simply hacks in -lpthread into LIB unconditionally for now. gcc/ChangeLog: * Makefile.in (LIB): Hack in -lpthread. --- gcc/Makefile.in

[PATCH 14/22] Add checkers/always_fails.py

2017-08-04 Thread David Malcolm
+) create mode 100755 checkers/always_fails.py diff --git a/checkers/always_fails.py b/checkers/always_fails.py new file mode 100755 index 000..35fd4ac --- /dev/null +++ b/checkers/always_fails.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# Copyright 2012, 2013, 2015, 2017 David Malcolm +#

[PATCH 12/22] Add -Wrun-analyzers= to common.opt, toplev.c, and invoke.texi

2017-08-04 Thread David Malcolm
This patch introduces -Wrun-analyzers= and wires it up to the checkers.cc code, via toplev.c As noted earlier, I'm not a great fan of the monolithic option syntax here; maybe there should be some kind of option that can be supplied multiple times for adding individual checkers. gcc/ChangeLog:

[PATCH 21/22] Add checkers/Makefile

2017-08-04 Thread David Malcolm
This patch adds a rather simplistic Makefile to "checkers", purely for exercising the test suites of the various harness. checkers/ChangeLog: * Makefile: New file. --- checkers/Makefile | 23 +++ 1 file changed, 23 insertions(+) create mode 100644 checkers/Makefile d

[PATCH 18/22] Add checkers/flawfinder.py

2017-08-04 Thread David Malcolm
null +++ b/checkers/flawfinder.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python +# Copyright 2012, 2013, 2015, 2017 David Malcolm +# Copyright 2012, 2013, 2015, 2017 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public

[PATCH 13/22] Add checkers/checker.py

2017-08-04 Thread David Malcolm
f --git a/checkers/ChangeLog b/checkers/ChangeLog new file mode 100644 index 000..9189883 --- /dev/null +++ b/checkers/ChangeLog @@ -0,0 +1,9 @@ +2017-08-03 David Malcolm + + * ChangeLog: New ChangeLog file. + +Copyright (C) 2017 Free Software Foundation, Inc. + +Copying and dist

[PATCH 20/22] Add checkers/splint.py

2017-08-04 Thread David Malcolm
diff --git a/checkers/splint.py b/checkers/splint.py new file mode 100755 index 000..e8f79f2 --- /dev/null +++ b/checkers/splint.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# Copyright 2017 David Malcolm +# Copyright 2017 Red Hat, Inc. +# +# This is free software: you can redistribute

[PATCH 05/22] diagnostic.c/h: add support for external tools

2017-08-04 Thread David Malcolm
This patch adds fields "external_tool" and "external_test_id" to diagnostic_info, allowing for diagnostics to be marked as coming from a 3rd-party tool. Instead of printing the pertinent warning flag e.g.: foo.c:10:1: something is wrong [-Wpointer-arith] the tool "ID" and (optionally) test ID

Re: [PATCH 00/22] RFC: integrated 3rd-party static analysis support

2017-08-07 Thread David Malcolm
On Fri, 2017-08-04 at 21:00 -0400, Eric Gallager wrote: > On 8/4/17, David Malcolm wrote: > > This patch kit clearly isn't ready yet as-is (see e.g. the > > "known unknowns" below), but I'm posting it now in the hope of > > getting early feedback. > &g

[PATCH] matching tokens: C++ parts (v3)

2017-08-08 Thread David Malcolm
On Mon, 2017-08-07 at 14:25 -0400, Jason Merrill wrote: Thanks for looking at this. > On 08/01/2017 04:21 PM, David Malcolm wrote: > > @@ -27632,6 +27769,9 @@ cp_parser_sizeof_operand (cp_parser* > > parser, enum rid keyword) > > { > >

Re: [PATCH 2/3] Matching tokens: C parts (v2)

2017-08-08 Thread David Malcolm
On Fri, 2017-08-04 at 12:09 -0600, Jeff Law wrote: > On 08/04/2017 08:32 AM, David Malcolm wrote: > > On Thu, 2017-08-03 at 11:34 -0600, Jeff Law wrote: > > > On 08/01/2017 02:21 PM, David Malcolm wrote: > > > > Changed in v2: > > > > > > > &g

[PATCH] Changes for v3 of the C++ patch

2017-08-08 Thread David Malcolm
For reference, here's the diff of the v3 C++ patch to the v2 patch, in case it's useful: gcc/cp/ChangeLog: * parser.c (token_pair::require_open): Use tabs rather than spaces. (token_pair::peek_open): Delete. (token_pair::require_close): Use tabs rather than spaces.

[committed] jit: add gcc_jit_type_get_vector

2017-08-09 Thread David Malcolm
On Wed, 2017-08-09 at 20:42 +1200, Michael Cree wrote: > On Mon, Aug 07, 2017 at 10:28:57AM -0400, David Malcolm wrote: > > On Mon, 2017-08-07 at 20:12 +1200, Michael Cree wrote: > > > > Hi Michael > > > > > I am wondering if libgccjit supports vector types,

Re: c-family PATCH to improve -Wtautological-compare (PR c/81783)

2017-08-16 Thread David Malcolm
On Wed, 2017-08-16 at 16:29 +0200, Marek Polacek wrote: > This patch improves -Wtautological-compare so that it also detects > bitwise comparisons involving & and | that are always true or false, > e.g. > > if ((a & 16) == 10) > return 1; > > can never be true. Note that e.g. "(a & 9) == 8

[committed] diagnostic-show-locus.c: remove unused field from class colorizer

2017-08-16 Thread David Malcolm
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. Committed to trunk as r251128. gcc/ChangeLog: * diagnostic-show-locus.c (colorizer::m_caret): Remove unused field. --- gcc/diagnostic-show-locus.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gcc/diagnostic-show-locu

Re: [PATCH] use strnlen in pretty printer for "%.*s" (PR 81859)

2017-08-16 Thread David Malcolm
On Wed, 2017-08-16 at 10:12 -0600, Martin Sebor wrote: > PR c/81859 - [8 Regression] valgrind error from > warn_about_normalization > > gcc/ChangeLog: > > PR c/81859 > * pretty-print.c (pp_format): Use strnlen in %.*s to avoid > reading > past the end of an array. > (test_

[PING] Re: [PATCH] C++: fix ordering of missing std #include suggestion (PR c++/81514)

2017-08-17 Thread David Malcolm
Ping On Thu, 2017-07-27 at 17:36 -0400, David Malcolm wrote: > PR c++/81514 reports a problem where > g++.dg/lookup/missing-std-include-2.C > fails on Solaris, offering the suggestion: > > error: 'string' is not a member of 'std' > note: suggested alte

[committed] jit: make simpler reproducers

2017-08-18 Thread David Malcolm
The C reproducers generated by gcc_jit_context_dump_reproducer_to_file contain numerous pointer values (from %p) to ensure uniqueness of the identifiers, but this makes them less readable than they could be. This patch updates reproducer::make_identifier so that the pointer is only added if it's n

[committed] jit: fix segfault with autovectorization (PR tree-optimization/46805)

2017-08-18 Thread David Malcolm
On Thu, 2017-08-17 at 11:51 -0400, David Malcolm wrote: > On Thu, 2017-08-17 at 09:15 +1200, Michael Cree wrote: > > On Wed, Aug 16, 2017 at 10:01:57AM -0400, David Malcolm wrote: > > > On Wed, 2017-08-16 at 21:58 +1200, Michael Cree wrote: > > > > > > > >

[PATCH 2/2] C: use full locations within c_parser_expr_list's vec

2017-08-18 Thread David Malcolm
The previous patch uncovered a bug in how c_parser_expr_list builds the vec: it was only using the location of the first token within each assignment-expression in the expr-list. This shows up in e.g. this -Wformat warning, where only part of the 2nd param is underlined: printf("hello %i", (lo

[PATCH 1/2] c-family/c/c++: pass optional vec to c-format.c

2017-08-18 Thread David Malcolm
This patch passes along the vec of argument locations at a callsite from the C frontend to check_function_arguments and from there to c-format.c, so that we can underline the pertinent argument to mismatched format codes even for tree codes like decls and constants which lack a location_t for their

Re: [PATCH][RFA/RFC] Stack clash mitigation patch 01/08 - V3

2017-08-22 Thread David Malcolm
On Tue, 2017-08-22 at 09:35 -0600, Jeff Law wrote: > On 08/19/2017 12:22 PM, Martin Sebor wrote: > > On 07/30/2017 11:35 PM, Jeff Law wrote: > > > This patch introduces the stack clash protection options > > > > > > Changes since V2: > > > > > > Adds two new params. The first controls the size o

Re: [PATCH 2/2] C: use full locations within c_parser_expr_list's vec

2017-08-23 Thread David Malcolm
On Tue, 2017-08-22 at 13:01 +0200, Andreas Schwab wrote: > On Aug 18 2017, David Malcolm wrote: > > > gcc/c/ChangeLog: > > * c-parser.c (c_parser_expr_list): Use c_expr::get_location () > > rather than peeking the location of the first token. > > *

[committed] testsuite: add param-type-mismatch.c/C testcases as a baseline

2017-08-23 Thread David Malcolm
I have various patch kits under development that improve how the C and C++ frontends handle mismatched types of params at callsites. For example, given: extern int callee_1 (int one, const char *two, float three); int test_1 (int first, int second, float third) { return callee_1 (first

[PATCH] C: fix logic within c_expr::get_location

2017-08-23 Thread David Malcolm
In r251239 I added a c_expr::get_location method for use by c_parser_expr_list for building the vec for an expression list, rather than using the location of the first token. When determining whether to use the location within the tree node, or fall back to the range in the c_expr, I used EXPR_CAN

[PATCH] C++: use an optional vec for callsites

2017-08-23 Thread David Malcolm
This patch extends various call-handling locations within the C++ frontend so that they can accept a possibly NULL vec *, using the location information if available in various diagnostics. It updates the C++ frontend's parser for this production: postfix-expression: postfix-expression (

[PATCH 2/3] C++: provide macro used-before-defined hint (PR c++/72786).

2017-05-05 Thread David Malcolm
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 { } ^

[PATCH 1/3] c-family: add name_hint/deferred_diagnostic

2017-05-05 Thread David Malcolm
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)

[PATCH 3/3] C: hints for missing stdlib includes for macros and types

2017-05-05 Thread David Malcolm
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 imp

[committed] diagnostic_report_diagnostic: refactor pragma-handling

2017-05-05 Thread David Malcolm
This patch simplifies diagnostic_report_diagnostic by moving the pragma-handling logic into a subroutine. No functional change intended. Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. Committed to trunk as r247660 gcc/ChangeLog: * diagnostic.c (diagnostic_report_diagnostic):

[committed] diagnostic.c: add print_option_information

2017-05-05 Thread David Malcolm
This patch simplifies diagnostic_report_diagnostic by moving option-printing to a new subroutine. Doing so required a slight rewrite. In both the old and new code, context->option_name returns a malloc-ed string. The old behavior was to then use ACONCAT to manipulate the format_spec, appending th

[committed] Eliminate report_diagnostic macro

2017-05-05 Thread David Malcolm
This patch eliminates the report_diagnostic macro, manually expanding it in all sites in the code. No functional change intended. Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. Committed to trunk as r247663. gcc/c-family/ChangeLog: * c-common.c (c_cpp_error): Replace report_d

[committed] Get rid of macros for diagnostic_report_current_module

2017-05-05 Thread David Malcolm
diagnostic.h has a couple of macros (diagnostic_last_module_changed and diagnostic_set_last_module) which are only used within diagnostic_report_current_module. This patch eliminates the macros in favor of static functions within diagnostic.c. No functional change intended. Successfully bootstra

[committed] Convert diagnostic_override_option_index from macro to inline function

2017-05-05 Thread David Malcolm
No functional change intended. Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. Committed to trunk as r247665. gcc/ChangeLog: * diagnostic.h (diagnostic_override_option_index): Convert from macro to inline function. --- gcc/diagnostic.h | 8 ++-- 1 file changed, 6 i

[committed] Convert CARET_LINE_MARGIN to const int

2017-05-05 Thread David Malcolm
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. Committed to trunk as r247666. gcc/ChangeLog: * diagnostic.h (CARET_LINE_MARGIN): Convert from macro to const int. --- gcc/diagnostic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/diagnostic.h b

[PATCH v2] C++: fix-it hints suggesting accessors for private fields

2017-05-05 Thread David Malcolm
On Mon, 2017-05-01 at 14:43 -0400, Jason Merrill wrote: > On Thu, Apr 27, 2017 at 7:23 AM, Nathan Sidwell > wrote: > > On 04/26/2017 12:34 PM, David Malcolm wrote: > > > > > Thanks - yes; that gives information on the const vs non-const of > > > the >

Re: [PATCH 1/2] C++ template type diff printing

2017-05-08 Thread David Malcolm
On Mon, 2017-05-08 at 07:36 -0400, Nathan Sidwell wrote: > On 05/04/2017 07:44 PM, David Malcolm wrote: > > This patch kit implements two new options to make it easier > > to read diagnostics involving mismatched template types: > >-fdiagnostics-show-template-tree and &

[PATCH 2/2] (v2) Use %qH and %qI throughout C++ frontend

2017-05-09 Thread David Malcolm
Changed in v2: use %qH and %qI rather than %H and %I. This is the second half of the kit, which uses %qH and %qI throughout the C++ frontend whenever describing type mismatches between a pair of %qT. gcc/cp/ChangeLog: * call.c (print_conversion_rejection): Replace pairs of %qT with

[PATCH 1/2] (v2) C++ template type diff printing

2017-05-09 Thread David Malcolm
Changes in v2: - pass "quote" as an extra bool argument to the pp_format_decoder callback, so that we can optionally quote the delayed chunks (with %qH and %qI) - use %qH and %qI rather than %H and %I. - use CLASS_TYPE_P. - use TYPE_P rather than EXPR_P in arg_to_string to handle non-type template

[PATCH 0/3] v3 of C++ template type diffing

2017-05-09 Thread David Malcolm
On Tue, 2017-05-09 at 10:52 -0400, Nathan Sidwell wrote: > On 05/09/2017 10:07 AM, David Malcolm wrote: > > > > +static const char * > > +type_to_string_with_compare (tree type, tree peer, bool verbose, > > +bool show_color) > > +

[PATCH 3/3] (v3) Use %qH and %qI throughout C++ frontend

2017-05-09 Thread David Malcolm
(unchanged in v3) Changed in v2: use %qH and %qI rather than %H and %I. This is the second half of the kit, which uses %qH and %qI throughout the C++ frontend whenever describing type mismatches between a pair of %qT. gcc/cp/ChangeLog: * call.c (print_conversion_rejection): Replace pairs

[PATCH 1/3] (v3) Non-C++ parts of template type diff printing

2017-05-09 Thread David Malcolm
This patch is broken out from the C++ patch, for ease of review. I believe I can self-approve this one, assuming the other patches in the kit are OK. The patch: - adds the bool and const char ** params to the pp_format_decoder callback - adds the format_postprocessor class - adds the "type-diff"

[PATCH 2/3] (v3) C++ template type diff printing

2017-05-09 Thread David Malcolm
Changes in v3: - Merge bodies of type_to_string_with_compare and print_template_tree_comparison into a new function, print_template_differences. Use simpler comma-insertion criterion. - Cleanup assertions in cxx_format_postprocessor::handle. Would it make sense to rename "m_type_a"/"m_type_b" to

Re: Trun predicates into a class

2017-05-17 Thread David Malcolm
On Wed, 2017-05-17 at 12:48 +0200, Jan Hubicka wrote: > Hi, > this is first patch of series to modularize function analysis done by > ipa-inline and ipa-cp. This patch turns predicates into a class. It > avoids any > code movement or semnatic changes which I will do next. Main change > is to > t

Re: [New file, Ping] Add testcase to ensure that #pragma GCC diagnostic push/pop works with -Wtraditional.

2017-05-18 Thread David Malcolm
On Tue, 2017-05-02 at 12:56 -0400, Eric Gallager wrote: > On 3/24/17, Eric Gallager wrote: > > On 3/24/17, David Malcolm wrote: > > > On Fri, 2017-03-24 at 14:10 -0400, Eric Gallager wrote: > > > > The attached test case failed with gcc 4.9 and older, but >

Re: SSA range class and removal of VR_ANTI_RANGEs

2017-05-23 Thread David Malcolm
On Tue, 2017-05-23 at 14:11 +0200, Jakub Jelinek wrote: > On Tue, May 23, 2017 at 06:48:15AM -0400, Aldy Hernandez wrote: [...] > > --- /dev/null > > +++ b/gcc/range.h > > + > > +You should have received a copy of the GNU General Public License > > +along with GCC; see the file COPYING3. If not

[PING^2] Re: [PATCH 1/2] Port Doxygen support script from Perl to Python; add unittests

2017-05-26 Thread David Malcolm
Ping On Fri, 2017-04-28 at 18:09 -0400, David Malcolm wrote: > Ping for these two patches: > - https://gcc.gnu.org/ml/gcc-patches/2017-03/msg00909.html > - https://gcc.gnu.org/ml/gcc-patches/2017-03/msg00910.html > > On Thu, 2017-03-16 at 21:51 -0400, David Malcolm wrote: &g

[PING] re [PATCH v2] C++: Add fix-it hints for -Wold-style-cast

2017-05-26 Thread David Malcolm
On Wed, 2017-05-03 at 09:51 -0400, David Malcolm wrote: > On Thu, 2017-04-27 at 23:03 +0200, Marek Polacek wrote: > > On Thu, Apr 27, 2017 at 05:10:24PM -0400, David Malcolm wrote: > > > + /* First try const_cast. */ > > > + trial = build_const_cast (dst_typ

<    24   25   26   27   28   29   30   31   32   33   >