Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-06-19 Thread Marek Polacek
On Mon, Jun 16, 2014 at 01:23:04PM +0200, Jakub Jelinek wrote: On Mon, Jun 16, 2014 at 12:39:07PM +0200, Marek Polacek wrote: Jason/Joseph, could you please look at the C++/C FE parts? As mentioned on IRC, you need to differentiate between taking address and not taking address. struct S

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-06-19 Thread Marek Polacek
On Thu, Jun 19, 2014 at 04:56:53PM +0200, Marek Polacek wrote: Regtested/bootstrapped on x86_64-linux. How does this look? Now even bootstrap-ubsan passed, with 92258 runtime errors: index 1 out of bounds for type 'rtunion [1]' - heh. Marek

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-06-20 Thread Marek Polacek
the internal function before calling print_call_name, since that gets NULL node - and we can't determine CALL_EXPR_IFN. I added some docs as well, as promised. 2014-06-20 Marek Polacek pola...@redhat.com * asan.c (pass_sanopt::execute): Handle IFN_UBSAN_BOUNDS. * flag-types.h

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-06-20 Thread Marek Polacek
On Fri, Jun 20, 2014 at 10:57:47AM +0200, Jakub Jelinek wrote: On Fri, Jun 20, 2014 at 10:43:04AM +0200, Marek Polacek wrote: + +/* Internal function code. */ +ENUM_BITFIELD(internal_fn) ifn : 5; Any reason for the : 5 here? I mean, the union also contains unsigned int, so

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-06-20 Thread Marek Polacek
On Fri, Jun 20, 2014 at 11:39:23AM +0200, Jakub Jelinek wrote: On Fri, Jun 20, 2014 at 11:34:26AM +0200, Marek Polacek wrote: On Fri, Jun 20, 2014 at 10:57:47AM +0200, Jakub Jelinek wrote: On Fri, Jun 20, 2014 at 10:43:04AM +0200, Marek Polacek wrote: + +/* Internal function code

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-06-20 Thread Marek Polacek
On Thu, Jun 19, 2014 at 07:47:54PM +0200, Jakub Jelinek wrote: On Thu, Jun 19, 2014 at 04:56:53PM +0200, Marek Polacek wrote: + /* Don't instrument this FMA-like array in non-strict Also, please don't use FMA to mean flexible member array, it is flexible array member, but more importantly

[PATCH] Fix arrays in rtx.u + add minor rtx verification

2014-06-20 Thread Marek Polacek
it in gengenrtl.c as that doesn't include rtl.h) so this won't happen again. Verified that the bootstrap crashes by bootstrapping with changed RTX_FLD_WIDTH/RTX_HWINT_WIDTH, otherwise the bootstrapp passes. Ok for trunk? 2014-06-20 Marek Polacek pola...@redhat.com * genpreds.c (verify_rtx_codes

Re: [PATCH] Fix arrays in rtx.u + add minor rtx verification

2014-06-20 Thread Marek Polacek
On Fri, Jun 20, 2014 at 09:01:14PM +0200, Jakub Jelinek wrote: On Fri, Jun 20, 2014 at 07:36:41PM +0200, Marek Polacek wrote: 2014-06-20 Marek Polacek pola...@redhat.com * genpreds.c (verify_rtx_codes): New function. (main): Call it. * rtl.h (RTX_FLD_WIDTH

Re: [PATCH] Fix arrays in rtx.u + add minor rtx verification

2014-06-20 Thread Marek Polacek
On Fri, Jun 20, 2014 at 11:10:18PM +0200, Jakub Jelinek wrote: On Fri, Jun 20, 2014 at 01:55:41PM -0600, Jeff Law wrote: like spot. Most RTLs are allocated through rtx_alloc and the size is determined from RTX_HDR_SIZE (i.e. offsetof) and/or RTX_CODE_SIZE, so your rtl.h change IMHO

Re: [C/C++ PATCH] Add -Wlogical-not-parentheses (PR c/49706)

2014-06-23 Thread Marek Polacek
On Sun, Jun 22, 2014 at 10:33:57PM +0200, Gerald Pfeifer wrote: On Mon, 2 Jun 2014, Marek Polacek wrote: * c-typeck.c (parser_build_binary_op): Warn when logical not is used on the left hand side operand of a comparison. This... +/* Warn about logical not used on the left hand

[PATCH] Don't segv on __atomic_store (PR c/61553)

2014-06-23 Thread Marek Polacek
We ICEd on the following testcase since the void type has a NULL TYPE_SIZE_UNIT. I took Andrew's patch from gcc@ ML and added a testcase. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2014-06-23 Marek Polacek pola...@redhat.com Andrew MacLeod amacl...@redhat.com

Re: [PATCH] Don't segv on __atomic_store (PR c/61553)

2014-06-23 Thread Marek Polacek
On Mon, Jun 23, 2014 at 04:39:55PM +0200, Marek Polacek wrote: --- gcc/testsuite/c-c++-common/pr61553.c +++ gcc/testsuite/c-c++-common/pr61553.c @@ -0,0 +1,8 @@ +/* PR c/61553 */ +/* { dg-do compile } */ + +void +foo (char *s) +{ + __atomic_store (s, (void *) 0, __ATOMIC_SEQ_CST); Oops

[C PATCH] Better column info for return stmts (PR c/61162)

2014-06-25 Thread Marek Polacek
This is the last piece to fix PR61162: it's better to point to the expression of the return statement (if any) than to the return keyword itself. Tested x86_64-unknown-linux-gnu, applying to trunk. 2014-06-25 Marek Polacek pola...@redhat.com PR c/61162 * c-parser.c

[PATCH] Fix ubsan/bounds-2.c

2014-06-25 Thread Marek Polacek
read. Ramana, does this patch help on ARM? Tested x86_64-unknown-linux-gnu, ok for trunk? 2014-06-25 Marek Polacek pola...@redhat.com * c-c++-common/ubsan/bounds-2.c: Adjust dg-output. (fn1): Remove store to out-of-bounds location. Add memory barrier. (fn2): Likewise

Re: [PATCH] Fix ubsan/bounds-2.c

2014-06-25 Thread Marek Polacek
it looks good to me. Ah, sure, hopefully the following is fine then: 2014-06-25 Marek Polacek pola...@redhat.com * c-c++-common/ubsan/bounds-2.c: Adjust dg-output. (fn1): Remove store to out-of-bounds location. Add memory barrier. (fn2): Likewise. (fn5): Likewise

[C/C++ PATCH] Implement -Wsizeof-array-argument (PR c/6940)

2014-06-26 Thread Marek Polacek
in elfutils - so -Wsizeof-array-argument might be indeed useful. (The warning didn't trigger during GCC bootstrap though.) Jason/Joseph, could you please look at the C++, resp. C FE parts? Tested x86_64-unknown-linux-gnu, ok for trunk? 2014-06-26 Marek Polacek pola...@redhat.com PR c/6940

Re: [PATCH v2] typeof: Remove type qualifiers for atomic types

2014-06-27 Thread Marek Polacek
On Fri, Jun 27, 2014 at 08:36:38AM +0200, Sebastian Huber wrote: Thanks for your patience. It would be nice if this can be applied to GCC 4.9 as well. Can someone please commit this for me, since I don't have write access. I will commit it for you. Marek

Re: [c++-concepts] Change constraint equivalence

2014-06-27 Thread Marek Polacek
On Fri, Jun 27, 2014 at 03:22:39AM -0400, Braden Obrzut wrote: To bring the implementation in line with changes going into the concepts draft, use syntactical equivalence in place of logical equivalence when matching declarations. 2014-06-27 Braden Obrzut ad...@maniacsvault.net Two spaces

Re: [c++-concepts] Change constraint equivalence

2014-06-27 Thread Marek Polacek
On Fri, Jun 27, 2014 at 03:41:36AM -0400, Braden Obrzut wrote: On 06/27/2014 03:27 AM, Marek Polacek wrote: Two spaces after you name. I'm not sure what happened to the second space. It's there in the source I copied. I'll have to be sure to double check the paste next time. Please drop gcc

Re: [PATCH] gcc/c/c-decl.c: Let NEWDECL dereference shared data to fix segment fault issue.

2014-06-29 Thread Marek Polacek
On Sun, Jun 29, 2014 at 10:00:34PM +0200, Jan Hubicka wrote: On Sun, 29 Jun 2014, Chen Gang wrote: NEWDECL dereferences shared data of OLDDECL, or when free NEWDECL, also have effect with OLDDECL. At present, only fix the related reference for current issue. If find another related

[PATCH] Properly honor no_sanitize_undefined attribute

2014-06-30 Thread Marek Polacek
Marek Polacek pola...@redhat.com * convert.c (convert_to_integer): Don't instrument conversions if the function has no_sanitize_undefined attribute. * ubsan.c: Don't run the ubsan pass if the function has no_sanitize_undefined attribute. c/ * c-decl.c

Re: [PATCH v2] typeof: Remove type qualifiers for atomic types

2014-06-30 Thread Marek Polacek
On Fri, Jun 27, 2014 at 08:49:24AM +0200, Marek Polacek wrote: On Fri, Jun 27, 2014 at 08:36:38AM +0200, Sebastian Huber wrote: Thanks for your patience. It would be nice if this can be applied to GCC 4.9 as well. Can someone please commit this for me, since I don't have write access

Re: [PATCH] Properly honor no_sanitize_undefined attribute

2014-06-30 Thread Marek Polacek
On Mon, Jun 30, 2014 at 03:00:11PM +0200, Jakub Jelinek wrote: Actually, please change current_function_decl != 0 to current_function_decl != NULL_TREE everywhere in the patch. Ok with that change. Ok, I'm applying the following then. 2014-06-30 Marek Polacek pola...@redhat.com

[C PATCH] Add -Wincompatible-pointer-types option (PR c/58286)

2014-06-30 Thread Marek Polacek
pointer type seems to be too austere. (We say expected T but argument is of type U when passing arguments.) This is for C/ObjC only, since in C++, we'd issue cannot convert error. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-06-30 Marek Polacek pola...@redhat.com PR c

[C PATCH] Add -Wint-conversion option

2014-06-30 Thread Marek Polacek
the user that or * may be used to fix the code. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-06-30 Marek Polacek pola...@redhat.com * doc/invoke.texi: Document -Wint-conversion. c-family/ * c.opt (Wint-conversion): New option. c/ * c-typeck.c

Re: [PATCH] Improve -fdump-tree-all efficiency

2014-06-30 Thread Marek Polacek
On Thu, Jun 26, 2014 at 06:42:09AM -0700, Teresa Johnson wrote: 2014-06-26 Teresa Johnson tejohn...@google.com * c-family/c-common.h (get_dump_info): Declare. * c-family/c-gimplify.c (c_genericize): Use saved dump files. * c-family/c-opts.c (c_common_parse_file):

Re: [C PATCH] Add -Wincompatible-pointer-types option (PR c/58286)

2014-07-01 Thread Marek Polacek
On Mon, Jun 30, 2014 at 08:14:52PM +, Joseph S. Myers wrote: On Mon, 30 Jun 2014, Marek Polacek wrote: This patch adds the -Wincompatible-pointer-types option for a warning we already have, so it's possible to suppress this specific warning, or use it with -Werror= and so

Re: [C PATCH] Add -Wint-conversion option

2014-07-01 Thread Marek Polacek
On Mon, Jun 30, 2014 at 08:16:01PM +, Joseph S. Myers wrote: On Mon, 30 Jun 2014, Marek Polacek wrote: Basically everything I wrote in the patch for -Wincompatible-pointer-types applies here as well. A new option, -Wint-conversion (to be compatible with clang), is added to allow more

Re: [C PATCH] Add -Wint-conversion option

2014-07-01 Thread Marek Polacek
On Mon, Jun 30, 2014 at 11:07:57PM +0200, Gerald Pfeifer wrote: On Mon, 30 Jun 2014, Jakub Jelinek wrote: We don't have gcc-4.10/ directory, because the version of the next release is still to be decided (hopefully at Cauldron next month). I'm a bit worried we'll miss entries in the

Re: [C/C++ PATCH] Implement -Wsizeof-array-argument (PR c/6940)

2014-07-03 Thread Marek Polacek
On Wed, Jul 02, 2014 at 07:27:07PM -0700, Jason Merrill wrote: On 06/26/2014 03:22 PM, Marek Polacek wrote: The following is a revamped patch for -Wsizeof-array-argument. Its purpose is to detect suspicious usage of the sizeof operator on an array function parameter. Then the name should

Re: [PATCH] Don't ICE with huge alignment (PR middle-end/60226)

2014-07-03 Thread Marek Polacek
On Mon, Jun 30, 2014 at 01:50:12PM -0600, Jeff Law wrote: On 03/04/14 09:40, Marek Polacek wrote: This should fix ICE on insane alignment. Normally, check_user_alignment detects e.g. alignment 1 32, but not 1 28. However, record_align is in bits, so it's actually 8 * (1 28) and that's

Re: [PATCH] Don't ICE with huge alignment (PR middle-end/60226)

2014-07-03 Thread Marek Polacek
unsigned). Yeah, I did that. One issue with that is that round_up now wraps the value, so I had to add a check for huge size before rounding up, otherwise we'd regress on e.g. PR42611. How about the following? Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-07-03 Marek Polacek pola

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-07-03 Thread Marek Polacek
On Sat, Jun 28, 2014 at 06:52:00PM +0200, Gerald Pfeifer wrote: On Fri, 20 Jun 2014, Marek Polacek wrote: +@item -fsanitize=bounds +@opindex fsanitize=bounds + +This option enables instrumentation of array bounds. Various out of bounds +accesses are detected. Flexible array members

Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs

2014-07-03 Thread Marek Polacek
On Thu, Jul 03, 2014 at 12:46:35PM +0200, Jakub Jelinek wrote: On Thu, Jul 03, 2014 at 12:41:46PM +0200, Marek Polacek wrote: On Sat, Jun 28, 2014 at 06:52:00PM +0200, Gerald Pfeifer wrote: On Fri, 20 Jun 2014, Marek Polacek wrote: +@item -fsanitize=bounds +@opindex fsanitize=bounds

Re: Strenghten assumption about dynamic type changes (placement new)

2014-07-06 Thread Marek Polacek
(will commit as obvious). 2014-07-06 Marek Polacek pola...@redhat.com * g++.dg/ipa/imm-devirt-1.C: Fix regexp in dg-final. * g++.dg/ipa/imm-devirt-2.C: Likewise. diff --git gcc/testsuite/g++.dg/ipa/imm-devirt-1.C gcc/testsuite/g++.dg/ipa/imm-devirt-1.C index 115277f..85f1a8f

[PATCH] Implement -fsanitize=object-size

2014-07-13 Thread Marek Polacek
pass then expands this internal call, and if the pointer points outside of the object, it issues a runtime error. Bootstrapped(-ubsan)/regtested on x86_64-linux, ok for trunk? 2014-07-13 Marek Polacek pola...@redhat.com * ubsan.h (struct ubsan_mismatch_data): * asan.c

Re: [PATCH][www] disallow /git/ in robots.txt

2014-07-15 Thread Marek Polacek
On Tue, Jul 15, 2014 at 09:54:02AM +0200, Gerald Pfeifer wrote: On Tue, 15 Jul 2014, Richard Biener wrote: Seems like somebody is mirroring gitweb urls. 2014-07-15 Richard Biener rguent...@suse.de * robots.txt: Disallow /git/ Makes sense. (I checked, and we already block /svn

[PATCH] Fix -imacros (PR c/57653)

2014-07-15 Thread Marek Polacek
look ok. Bootstrapped/regtested on x86_64-linux, ok for trunk? Ok also for 4.9/4.8? 2014-07-14 Marek Polacek pola...@redhat.com Manuel López-Ibáñez m...@gcc.gnu.org PR c/57653 * c-opts.c (c_finish_options): If -imacros is in effect, return. * c-c++-common

[PATCH] Fix ubsan ICE with flexible array members

2014-07-15 Thread Marek Polacek
We were missing a check that the TYPE_MAX_VALUE is not NULL. If it is, we ICE later when gimplifying the UBSAN_BOUNDS call arguments. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-07-15 Marek Polacek pola...@redhat.com * c-ubsan.c (ubsan_instrument_bounds): Don't

[C PATCH] Better location for implicit_decl_warning (PR c/61852)

2014-07-20 Thread Marek Polacek
implicit_decl_warning wasn't getting a location, so the column info was poor. It's easy to fix this up. Bootstrapped/regtested on x86_64-linux, applying to trunk. 2014-07-20 Marek Polacek pola...@redhat.com PR c/61852 * c-decl.c (implicit_decl_warning): Add location_t

[libcpp PATCH] Fix up location of builtin macros (PR c/61861)

2014-07-23 Thread Marek Polacek
on x86_64-linux, ok for trunk? 2014-07-23 Marek Polacek pola...@redhat.com PR c/61861 * macro.c (builtin_macro): Add location parameter. Set location of builtin macro to the expansion point. (enter_macro_context): Pass location to builtin_macro. * gcc.dg

[ubsan PATCH] Fix bounds-2.c test with -fstack-protector-strong

2014-07-23 Thread Marek Polacek
Jakub reported to me that bounds-2.c test fails with -fstack-protector-strong -Os. The following hack fixes it. Tested x86_64-linux, applying to trunk as obvious. 2014-07-23 Marek Polacek pola...@redhat.com * c-c++-common/ubsan/bounds-2.c (fn4): Adjust to check the array size

Re: [libcpp PATCH] Fix up location of builtin macros (PR c/61861)

2014-07-23 Thread Marek Polacek
CCing Dodji, please, can you have a look? (I don't believe it is caused by yours https://gcc.gnu.org/ml/gcc-patches/2014-07/msg01063.html though, this was wrong even in 4.8 and maybe earlier.) On Wed, Jul 23, 2014 at 03:15:53PM +0200, Marek Polacek wrote: Bultin macros like __FILE__, __DATE__

Re: [libcpp PATCH] Fix up location of builtin macros (PR c/61861)

2014-07-23 Thread Marek Polacek
[Though Dodji is on a vacation for next two weeks, so if anyone else can review this patch, it would be appreciated.] On Wed, Jul 23, 2014 at 05:39:51PM +0200, Marek Polacek wrote: CCing Dodji, please, can you have a look? (I don't believe it is caused by yours https://gcc.gnu.org/ml/gcc

Re: [PATCH] Fix -imacros (PR c/57653)

2014-07-23 Thread Marek Polacek
to trunk. 2014-07-23 Marek Polacek pola...@redhat.com PR c/57653 * c-opts.c (c_finish_options): If -imacros is in effect, return. * c-c++-common/pr57653.c: New test. * c-c++-common/pr57653.h: New file. * c-c++-common/pr57653-2.c: New test. * c-c

[committed] Fix pr61077.c test

2014-07-26 Thread Marek Polacek
Marc reported that using .* regexp can cause spurious fails, so fixed by using \[^\n\]* instead. Tested on x86_64-linux, applying to trunk. 2014-07-26 Marek Polacek pola...@redhat.com * gcc.dg/pr61077.c: Use \[^\n\]* instead of .* in the regexp. diff --git gcc/testsuite/gcc.dg

[PATCH] Fix ICE with -Wodr (PR middle-end/61913)

2014-07-27 Thread Marek Polacek
Wodr in common.opt was missing a Var, which means: 1) we ICE with -Wodr, since -Wodr isn't handled in opts.c; 2) -Wno-odr wouldn't work. Thus fixed. I'd think this doesn't need a testcase... Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-07-27 Marek Polacek pola...@redhat.com

Re: [PATCH] Fix ICE with -Wodr (PR middle-end/61913)

2014-07-28 Thread Marek Polacek
On Mon, Jul 28, 2014 at 10:23:36AM +0200, Jan Hubicka wrote: On Sun, Jul 27, 2014 at 1:02 PM, Marek Polacek pola...@redhat.com wrote: Wodr in common.opt was missing a Var, which means: 1) we ICE with -Wodr, since -Wodr isn't handled in opts.c; 2) -Wno-odr wouldn't work. Thus fixed

[DOC PATCH] Fix -Wno-odr entry

2014-07-28 Thread Marek Polacek
-Wodr entry was missing an @item. Plus some corrections. Ok for trunk? 2014-07-28 Marek Polacek pola...@redhat.com * doc/invoke.texi (-Wno-odr): Fix @item entry. Tweak wording. diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index aaa5a68..7cebb9e 100644 --- gcc/doc/invoke.texi

Re: Warn when returning the address of a temporary (middle-end) v2

2014-07-29 Thread Marek Polacek
On Tue, Jul 29, 2014 at 02:58:03PM -0400, David Malcolm wrote: This is possibly a dumb question, but what happens for a static local, rather than an auto local? e.g. int *f (void) { static int i; return i; } This is fine. The variable i has a static storage duration, so is

Re: [wwwdocs] Add gcc-5/{changes,criteria}.html

2014-07-30 Thread Marek Polacek
On Wed, Jul 30, 2014 at 08:31:35AM +0200, Tobias Burnus wrote: This patch adds the files gcc-5/{changes,criteria}.html - and populates the former with Fortran changes; the latter is a copy of the GCC 4.9 file. Is the patch OK? Thanks for the patch! gcc-5/changes.html | 60

Re: [C PATCH] warn for empty struct -Wc++-compat

2014-11-10 Thread Marek Polacek
On Tue, Nov 11, 2014 at 03:24:48AM +0530, Prathamesh Kulkarni wrote: * gcc/c/c-decl.c (warn_cxx_compat_finish_struct): Add new parameter of type location_t. Warn for empty struct. (finish_struct): Pass loc to warn_cxx_compat_finish_struct. * gcc/testsuite/gcc.dg/Wcxx-compat-22.c:

Re: [C PATCH] warn for empty struct -Wc++-compat

2014-11-11 Thread Marek Polacek
On Tue, Nov 11, 2014 at 04:45:46AM +0530, Prathamesh Kulkarni wrote: Index: gcc/c/c-decl.c === --- gcc/c/c-decl.c(revision 217287) +++ gcc/c/c-decl.c(working copy) @@ -606,6 +606,8 @@ /* If warn_cxx_compat, a list of

Re: [C PATCH] warn for empty struct -Wc++-compat

2014-11-11 Thread Marek Polacek
On Tue, Nov 11, 2014 at 12:13:32PM +0100, Marc Glisse wrote: On Tue, 11 Nov 2014, Marek Polacek wrote: @@ -7506,12 +7509,19 @@ /* Finish up struct info used by -Wc++-compat. */ static void -warn_cxx_compat_finish_struct (tree fieldlist) +warn_cxx_compat_finish_struct (tree fieldlist

[PATCH] Peg down -(-A) - A transformation

2014-11-11 Thread Marek Polacek
allowed this transformation for constants, because VRP seems to rely on that (abs_extent_range calls fold_unary). Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-11-11 Marek Polacek pola...@redhat.com * fold-const.c (fold_unary_loc): Don't call fold_negate_expr when doing

Re: [C PATCH] warn for empty struct -Wc++-compat

2014-11-11 Thread Marek Polacek
On Tue, Nov 11, 2014 at 11:27:21PM +0530, Prathamesh Kulkarni wrote: I tried the following: struct A { struct B {}; int x; } /* { dg-warning empty struct has size 0 in C } */ /* { dg-bogus delcaration does not declare anything } */ but it fails in

Re: [C PATCH] warn for empty struct -Wc++-compat

2014-11-11 Thread Marek Polacek
On Wed, Nov 12, 2014 at 02:08:03AM +0530, Prathamesh Kulkarni wrote: Is this version okay ? I have no further comments on this patch, so deferring to Joseph. Thanks, Marek

Re: [PATCH] Peg down -(-A) - A transformation

2014-11-12 Thread Marek Polacek
On Tue, Nov 11, 2014 at 07:45:40PM +0100, Richard Biener wrote: On November 11, 2014 6:49:34 PM CET, Jakub Jelinek ja...@redhat.com wrote: On Tue, Nov 11, 2014 at 06:40:25PM +0100, Marek Polacek wrote: --- gcc/fold-const.c +++ gcc/fold-const.c @@ -7862,9 +7862,15 @@ fold_unary_loc

[PATCH] Don't perform A - (-B) - A + B when sanitizing

2014-11-12 Thread Marek Polacek
for trunk? 2014-11-12 Marek Polacek pola...@redhat.com * match.pd (A - (-B) - A + B): Check for TYPE_OVERFLOW_WRAPS and SANITIZE_SI_OVERFLOW. * fold-const.c (fold_binary_loc): Likewise. * c-c++-common/ubsan/overflow-sub-4.c: New test. * c-c++-common/ubsan

Re: [PATCH][dejagnu] truncate absolute file path into relative for dg-output

2014-11-12 Thread Marek Polacek
\[^\n\r]*(\n|\r\n|\r) } */ but since the note's are already gone, the test fails. The following patch moves the path prunning code into a separate procedure and fixes the failures. Ok for trunk? 2014-11-12 Marek Polacek pola...@redhat.com * lib/gcc-dg.exp (${tool}_load): Call

Re: [PATCH] Don't perform A - (-B) - A + B when sanitizing

2014-11-12 Thread Marek Polacek
Marek Polacek pola...@redhat.com * fold-const.c (fold_binary_loc): Don't fold if the result is undefined. * match.pd (A + (-B) - A - B, A - (-B) - A + B, -(-A) - A): Likewise. * c-c++-common/ubsan/overflow-sub-4.c: New test. * c-c++-common/ubsan

Re: [PR c/52952] More precise locations within format strings

2014-11-12 Thread Marek Polacek
On Wed, Nov 12, 2014 at 03:35:06PM +0100, Manuel López-Ibáñez wrote: ../../libcpp/line-map.c:667:65: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body] I just (r217418) bootstrapped this code and it did not produce this error (or warning). Could you give

Re: [PATCH] Don't perform A - (-B) - A + B when sanitizing

2014-11-12 Thread Marek Polacek
On Wed, Nov 12, 2014 at 03:22:41PM +0100, Richard Biener wrote: TYPE_OVERFLOW_SANITIZES? Can I call it sanitize_fold_p and put it as a static inline fn into tree.h? Marek

[PATCH] Introduce TYPE_OVERFLOW_SANITIZED

2014-11-12 Thread Marek Polacek
This patch introduces TYPE_OVERFLOW_SANITIZED predicate to consolidate a common check. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-11-12 Marek Polacek pola...@redhat.com * tree.h (TYPE_OVERFLOW_SANITIZED): Define. * fold-const.c (fold_binary_loc): Use

Re: [PATCH 2/5] remove the remaining uses of if_marked

2014-11-12 Thread Marek Polacek
On Thu, Nov 13, 2014 at 12:55:40AM -0500, tsaund...@mozilla.com wrote: From: Trevor Saunders tsaund...@mozilla.com diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b70c56c..227509a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -14032,14 +14032,34 @@

Re: [PATCH] Introduce TYPE_OVERFLOW_SANITIZED

2014-11-13 Thread Marek Polacek
bit baffling ;). So - can you invert the predicates (and uses)? In the sanitizer you then can guard instrumentations with TYPE_OVERFLOW_SANITIZED. Done. Ok with that change. Thanks, this is the inverted version: 2014-11-13 Marek Polacek pola...@redhat.com * tree.h

Re: [PATCH, libgfortran] PR 60324 Unbounded stack allocations in libgfortran

2014-11-13 Thread Marek Polacek
On Thu, Nov 13, 2014 at 02:05:52PM +0200, Janne Blomqvist wrote: Thanks for the quick review, committed as r217480. This broke bootstrap because of implicit declaration of free. The following (untested) should fix it, ok for trunk? 2014-11-13 Marek Polacek pola...@redhat.com

Re: [PATCH, libgfortran] PR 60324 Unbounded stack allocations in libgfortran

2014-11-13 Thread Marek Polacek
On Thu, Nov 13, 2014 at 04:59:09PM +0100, Jakub Jelinek wrote: On Thu, Nov 13, 2014 at 04:57:08PM +0100, Marek Polacek wrote: On Thu, Nov 13, 2014 at 02:05:52PM +0200, Janne Blomqvist wrote: Thanks for the quick review, committed as r217480. This broke bootstrap because of implicit

[PATCH] -fsanitize=unreachable overhaul (PR sanitizer/63839)

2014-11-13 Thread Marek Polacek
?). Now, BUILT_IN_TRAP should probably be also marked as const+cold; I'm happy to do that as a follow-up. Bootstrapped/regtested on power8-linux, ok for trunk? 2014-11-13 Marek Polacek pola...@redhat.com PR sanitizer/63839 * asan.c (ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST

[PATCH] Remove doubled ECF_LEAF

2014-11-13 Thread Marek Polacek
Bootstrapped/regtested on power8-linux, ok for trunk? 2014-11-13 Marek Polacek pola...@redhat.com * tree.c (build_common_builtin_nodes): Remove doubled ECF_LEAF. diff --git gcc/tree.c gcc/tree.c index cf37a19..5c6fe0b 100644 --- gcc/tree.c +++ gcc/tree.c @@ -9935,7 +9935,7

Re: [PATCH] -fsanitize=unreachable overhaul (PR sanitizer/63839)

2014-11-14 Thread Marek Polacek
Marek Polacek pola...@redhat.com PR sanitizer/63839 * asan.c (ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST, ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST): Define. * builtin-attrs.def (ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST): Define. * builtins.c

Re: [PATCH] Peg down -(-A) - A transformation

2014-11-14 Thread Marek Polacek
.) Bootstrapped/regtested on power8-linux. 2014-11-14 Marek Polacek pola...@redhat.com * fold-const.c (fold_negate_expr): Don't fold INTEGER_CST if that overflows when SANITIZE_SI_OVERFLOW is on. Guard -(-A) folding with TYPE_OVERFLOW_SANITIZED. * c-c++-common/ubsan

[PATCH] Use TYPE_DECLs for TYPE_NAMEs (PR sanitizer/63866)

2014-11-14 Thread Marek Polacek
, ok for trunk? 2014-11-14 Marek Polacek pola...@redhat.com PR sanitizer/63866 * asan.c (asan_global_struct): Create a TYPE_DECL for __asan_global, put it into TYPE_NAME and TYPE_STUB_DECL. * ubsan.c (ubsan_type_descriptor_type): New variable. Function

[PATCH] Fix Cilk+ ICEs with overflow builtins (PR middle-end/63884)

2014-11-15 Thread Marek Polacek
on powerpc64-linux, ok for trunk? 2014-11-15 Marek Polacek pola...@redhat.com PR middle-end/63884 c-family/ * array-notation-common.c (is_sec_implicit_index_fn): Return false for NULL fndecl. (extract_array_notation_exprs): Return for NULL node. testsuite

Re: [PATCH] gcc/ubsan.c: Extend 'pretty_name' space to avoid memory overflow

2014-11-16 Thread Marek Polacek
On Mon, Nov 17, 2014 at 06:40:26AM +0800, Chen Gang wrote: According to the next code, 'pretty_name' may need additional bytes more than 16. For simplify thinking and being extensible in future, extent it to 256 bytes, directly. I think + 128 bytes should be enough for everyone. Marek

Re: [PATCH] gcc/ubsan.c: Extend 'pretty_name' space to avoid memory overflow

2014-11-17 Thread Marek Polacek
On Mon, Nov 17, 2014 at 08:38:19AM +0100, Jakub Jelinek wrote: On Mon, Nov 17, 2014 at 08:16:32AM +0100, Marek Polacek wrote: On Mon, Nov 17, 2014 at 06:40:26AM +0800, Chen Gang wrote: According to the next code, 'pretty_name' may need additional bytes more than 16. For simplify thinking

[PATCH] Fix for fold_negate_expr (PR sanitizer/63879)

2014-11-19 Thread Marek Polacek
-19 Marek Polacek pola...@redhat.com PR sanitizer/63879 * fold-const.c (negate_expr_p) case NEGATE_EXPR: Return !TYPE_OVERFLOW_SANITIZED. (fold_negate_expr) case INTEGER_CST: Fold when overflow does not trap and when overflow wraps, or when

[PATCH] Fix sanitizer/63690

2014-11-19 Thread Marek Polacek
As the testcase shows, we should really check first that we have a MEM_REF, otherwise subsequent TREE_OPERAND might ICE. On an invalid testcase we might get e.g. STRING_CST. Bootstrapped/regtested on power8-linux, ok for trunk? 2014-11-19 Marek Polacek pola...@redhat.com PR sanitizer

Re: [PATCH] Fix sanitizer/63690

2014-11-19 Thread Marek Polacek
On Wed, Nov 19, 2014 at 03:12:05PM +0100, Jakub Jelinek wrote: On Wed, Nov 19, 2014 at 02:51:11PM +0100, Marek Polacek wrote: As the testcase shows, we should really check first that we have a MEM_REF, otherwise subsequent TREE_OPERAND might ICE. On an invalid testcase we might get e.g

Re: [PATCH] rs6000: Fix signed integer overflows

2014-11-19 Thread Marek Polacek
On Wed, Nov 19, 2014 at 04:24:25PM +0100, Markus Trippelsdorf wrote: ;; Return 1 if op is a constant integer valid for addition @@ -827,7 +827,7 @@ (define_predicate mask_operand (match_code const_int) { - HOST_WIDE_INT c, lsb; + unsigned HOST_WIDE_INT c, lsb; c = INTVAL

Re: [patch] Warn on undefined loop exit

2014-11-19 Thread Marek Polacek
On Wed, Nov 19, 2014 at 04:32:43PM +, Andrew Stubbs wrote: + if (warning_at (gimple_location (elt-stmt), + OPT_Waggressive_loop_optimizations, + Loop exit may only be reached after undefined behaviour.))

[PATCH] Fix sanitizer/63788

2014-11-19 Thread Marek Polacek
-unknown-linux-gnu/libsanitizer/ubsan/.libs/ -B ../x86_64-unknown-linux-gnu/libgfortran/.libs/ -O -fsanitize=undefined testcase.f -lgfortran; ./a.out on the testcase attached in PR - and it doesn't ICE. Bootstrapped/regtested on ppc64-linux, ok for trunk? 2014-11-19 Marek Polacek pola...@redhat.com

[PATCH] Fix ubsan and C++14 constexpr ICEs (PR sanitizer/63956)

2014-11-20 Thread Marek Polacek
on ppc64-linux, ok for trunk? 2014-11-20 Marek Polacek pola...@redhat.com PR sanitizer/63956 * constexpr.c: Include ubsan.h. (cxx_eval_call_expression): Bail out for IFN_UBSAN_{NULL,BOUNDS} internal functions and for ubsan builtins in constexpr functions

Re: [PATCH] Fix ubsan and C++14 constexpr ICEs (PR sanitizer/63956)

2014-11-20 Thread Marek Polacek
On Thu, Nov 20, 2014 at 06:27:25PM +0100, Jakub Jelinek wrote: On Thu, Nov 20, 2014 at 06:14:52PM +0100, Marek Polacek wrote: + if (!current_function_decl is_ubsan_builtin_p (fun)) +return void_node; + I don't understand the !current_function_decl here. That is because I only

Re: [patch] Warn on undefined loop exit

2014-11-20 Thread Marek Polacek
-niter.c:3420:38: error: ‘struct vecgimple_statement_base*’ has no member named ‘empty’ if (exit_warned !problem_stmts.empty ()) ^ make: *** [tree-ssa-loop-niter.o] Error 1 I'm applying the following. 2014-11-20 Marek Polacek pola...@redhat.com

[C++ PATCH] Allow void type as a literal type in C++14

2014-11-21 Thread Marek Polacek
. Bootstrapped/regtested on ppc64-linux, ok for trunk? 2014-11-21 Marek Polacek pola...@redhat.com * constexpr.c (literal_type_p): Return true for void type in C++14. * g++.dg/cpp0x/constexpr-function2.C: Limit dg-error to C++11. * g++.dg/cpp0x/constexpr-neg1.C

[C++ PATCH] Detect UB in shifts in constexpr functions

2014-11-24 Thread Marek Polacek
for a shift containing UB. So I wrote a function that checks whether the shift operation is ok. I'm not sure yet if anything else needs similar treatment. Bootstrapped/regtested on ppc64-linux, ok for trunk? 2014-11-24 Marek Polacek pola...@redhat.com * constexpr.c (cxx_eval_check_shift_p

[C PATCH] Fix PR63877

2014-11-24 Thread Marek Polacek
functions. Bootstrapped/regtested on ppc64-linux, ok for trunk? 2014-11-24 Marek Polacek pola...@redhat.com PR c/63877 * c-decl.c (start_function): Disable -Wmissing-declarations warning for inline functions. * gcc.dg/pr63877.c: New test. diff --git gcc/c/c

Re: [C++ PATCH] Detect UB in shifts in constexpr functions

2014-11-24 Thread Marek Polacek
On Mon, Nov 24, 2014 at 04:49:25PM +0100, Jakub Jelinek wrote: On Mon, Nov 24, 2014 at 02:51:14PM +0100, Marek Polacek wrote: --- gcc/cp/constexpr.c +++ gcc/cp/constexpr.c @@ -1451,6 +1451,43 @@ verify_constant (tree t, bool allow_non_constant, bool *non_constant_p, return

Re: [C++ PATCH] Detect UB in shifts in constexpr functions

2014-11-24 Thread Marek Polacek
On Mon, Nov 24, 2014 at 05:05:08PM +0100, Jakub Jelinek wrote: On Mon, Nov 24, 2014 at 04:58:22PM +0100, Marek Polacek wrote: Consider say: constexpr int p = 1; constexpr int foo (int a) { return a (int) p; } constexpr int bar (int a) { return ((int) p

Re: [PATCH] Fix sanitizer/63788

2014-11-26 Thread Marek Polacek
Ping. On Wed, Nov 19, 2014 at 08:09:21PM +0100, Marek Polacek wrote: As discussed in the PR, the problem here is that when running gfortran, the __builtin_object_size decl isn't available, because c-family's c_define_builtins wasn't called. One way how to fix this is to build

[C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Marek Polacek
ok? Bootstrapped/regtested on ppc64-linux; ubsan.exp tested even on x86_64. 2014-11-26 Marek Polacek pola...@redhat.com PR c/63862 c-family/ * c-ubsan.c (ubsan_instrument_shift): Change the type of a MINUS_EXPR to op1_utype. c/ * c-typeck.c (build_binary_op

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Marek Polacek
On Wed, Nov 26, 2014 at 06:50:29PM +0100, Jakub Jelinek wrote: On Wed, Nov 26, 2014 at 06:39:44PM +0100, Marek Polacek wrote: Both C11 and C++14 standards specify that integral promotions are performed on both operands of a shift-expression. This we do just fine. But then we convert

Re: [PATCH] Fix ubsan and C++14 constexpr ICEs (PR sanitizer/63956)

2014-11-27 Thread Marek Polacek
On Wed, Nov 26, 2014 at 12:03:45PM -0500, Jason Merrill wrote: On 11/20/2014 02:04 PM, Marek Polacek wrote: + if (fun == NULL_TREE) +switch (CALL_EXPR_IFN (t)) + { + case IFN_UBSAN_NULL: + case IFN_UBSAN_BOUNDS: +return void_node; + default: +break

Re: [C++ PATCH] Detect UB in shifts in constexpr functions

2014-11-27 Thread Marek Polacek
then? Bootstrapped/regtested on ppc64-linux. 2014-11-27 Marek Polacek pola...@redhat.com * constexpr.c (cxx_eval_check_shift_p): New function. (cxx_eval_binary_expression): Call it. * g++.dg/cpp0x/constexpr-shift1.C: New test. * g++.dg/cpp1y/constexpr-shift1.C: New

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-27 Thread Marek Polacek
is the best thing we can do until we have type demotion/promotion pass. Seems that unsigned_type_node there works well. (What happened to Kai's type elevation pass?) Bootstrapped/regtested on ppc64-linux, ok for trunk? 2014-11-27 Marek Polacek pola...@redhat.com PR c/63862 c-family

Re: [PATCH] Fix PR preprocessor/58893 access to uninitialized memory

2014-09-26 Thread Marek Polacek
On Fri, Sep 26, 2014 at 02:16:05PM +0200, Bernd Edlinger wrote: Boot-Strapped and Regression-tested on x86_64-linux-gnu Ok for trunk? -ENOPATCH. Marek

[PATCH] gcc.c-torture/ cleanup

2014-09-30 Thread Marek Polacek
this approach make sense? 2014-09-30 Marek Polacek pola...@redhat.com * gcc.c-torture/compile/2120-2.c: Use -fgnu89-inline. * gcc.c-torture/compile/2009-1.c: Likewise. * gcc.c-torture/compile/2009-2.c: Likewise. * gcc.c-torture/compile/20021120-1.c

[PATCH] gcc.dg/tree-ssa/ cleanup

2014-10-02 Thread Marek Polacek
== results with this patch and gnu11 as a default. Ok for trunk? 2014-10-02 Marek Polacek pola...@redhat.com * gcc.dg/tree-ssa/20030530-2.c: Add function declarations. * gcc.dg/tree-ssa/20030708-1.c: Likewise. * gcc.dg/tree-ssa/20030709-2.c: Likewise. * gcc.dg

Re: [PATCH] gcc.dg/tree-ssa/ cleanup

2014-10-02 Thread Marek Polacek
and/or defaulting to int. Yeah, probably, thanks. The following uses -std=gnu89 for ~15 tests. 2014-10-02 Marek Polacek pola...@redhat.com * gcc.dg/tree-ssa/20030731-1.c: Use -std=gnu89. * gcc.dg/tree-ssa/20030729-1.c: Likewise. * gcc.dg/tree-ssa/20030807-8.c: Likewise

  1   2   3   4   5   6   7   8   9   10   >