Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jonathan Wakely
On 25/05/17 16:56 +0200, Jakub Jelinek wrote: On Thu, May 25, 2017 at 03:52:47PM +0100, Jonathan Wakely wrote: I'd probably write that like this instead: void foo (const void *p) { typedef const int* ptr_type; ptr_type const q = (ptr_type) p; ptr_type const r = (ptr_type) p; (void) q;

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jakub Jelinek
On Thu, May 25, 2017 at 03:52:47PM +0100, Jonathan Wakely wrote: > I'd probably write that like this instead: > > void > foo (const void *p) > { > typedef const int* ptr_type; > ptr_type const q = (ptr_type) p; > ptr_type const r = (ptr_type) p; > (void) q; > (void) r; > } > > It names the

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jonathan Wakely
On 25/05/17 16:11 +0200, Jakub Jelinek wrote: On Thu, May 25, 2017 at 03:02:42PM +0100, Jonathan Wakely wrote: On 25/05/17 11:07 +0100, Jonathan Wakely wrote: > On 25/05/17 10:05 +0200, Andreas Schwab wrote: > > ../../gcc/ada/gcc-interface/utils2.c: In function 'int compare_elmt_bitpos(const

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Marek Polacek
On Thu, May 25, 2017 at 04:11:19PM +0200, Jakub Jelinek wrote: > On Thu, May 25, 2017 at 03:02:42PM +0100, Jonathan Wakely wrote: > > On 25/05/17 11:07 +0100, Jonathan Wakely wrote: > > > On 25/05/17 10:05 +0200, Andreas Schwab wrote: > > > > ../../gcc/ada/gcc-interface/utils2.c: In function 'int

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jakub Jelinek
On Thu, May 25, 2017 at 04:11:19PM +0200, Jakub Jelinek wrote: > So, what can one do with typeof or similar to avoid the warning? > > void > foo (const void *p) > { > const int *const q = (const int *const) p; > typeof (q) r = (typeof (q)) p; > (void) q; > (void) r; > } > > AFAIK typeof

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jakub Jelinek
On Thu, May 25, 2017 at 03:02:42PM +0100, Jonathan Wakely wrote: > On 25/05/17 11:07 +0100, Jonathan Wakely wrote: > > On 25/05/17 10:05 +0200, Andreas Schwab wrote: > > > ../../gcc/ada/gcc-interface/utils2.c: In function 'int > > > compare_elmt_bitpos(const void*, const void*)': > > >

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jonathan Wakely
On 25/05/17 11:07 +0100, Jonathan Wakely wrote: On 25/05/17 10:05 +0200, Andreas Schwab wrote: ../../gcc/ada/gcc-interface/utils2.c: In function 'int compare_elmt_bitpos(const void*, const void*)': ../../gcc/ada/gcc-interface/utils2.c:1937:73: error: type qualifiers ignored on cast result

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jonathan Wakely
On 25/05/17 10:05 +0200, Andreas Schwab wrote: ../../gcc/ada/gcc-interface/utils2.c: In function 'int compare_elmt_bitpos(const void*, const void*)': ../../gcc/ada/gcc-interface/utils2.c:1937:73: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers] const

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Jonathan Wakely
On 24/05/17 20:09 -0700, Andrew Pinski wrote: On Wed, May 24, 2017 at 8:07 PM, Andrew Pinski wrote: This change caused a bootstrap failure on aarch64-linux-gnu and x86_64-linux-gnu: In file included from ../../gcc/gcc/system.h:691:0, from

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-25 Thread Andreas Schwab
../../gcc/ada/gcc-interface/utils2.c: In function 'int compare_elmt_bitpos(const void*, const void*)': ../../gcc/ada/gcc-interface/utils2.c:1937:73: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers] const constructor_elt * const elmt1 = (const constructor_elt *

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-24 Thread Andrew Pinski
On Wed, May 24, 2017 at 8:07 PM, Andrew Pinski wrote: > On Wed, May 24, 2017 at 12:29 PM, Jonathan Wakely wrote: >> On 24/05/17 14:50 -0400, Jason Merrill wrote: >>> >>> On Wed, May 24, 2017 at 10:20 AM, Jonathan Wakely >>> wrote:

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-24 Thread Andrew Pinski
On Wed, May 24, 2017 at 12:29 PM, Jonathan Wakely wrote: > On 24/05/17 14:50 -0400, Jason Merrill wrote: >> >> On Wed, May 24, 2017 at 10:20 AM, Jonathan Wakely >> wrote: >>> >>> On 23/05/17 16:26 -0400, Jason Merrill wrote: On Tue, May 23,

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-24 Thread Jonathan Wakely
On 24/05/17 14:50 -0400, Jason Merrill wrote: On Wed, May 24, 2017 at 10:20 AM, Jonathan Wakely wrote: On 23/05/17 16:26 -0400, Jason Merrill wrote: On Tue, May 23, 2017 at 2:00 PM, Jonathan Wakely wrote: On 19/05/17 15:14 -0400, Jason Merrill

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-24 Thread Jason Merrill
On Wed, May 24, 2017 at 10:20 AM, Jonathan Wakely wrote: > On 23/05/17 16:26 -0400, Jason Merrill wrote: >> >> On Tue, May 23, 2017 at 2:00 PM, Jonathan Wakely >> wrote: >>> >>> On 19/05/17 15:14 -0400, Jason Merrill wrote: On Thu, Apr 27,

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-24 Thread Jonathan Wakely
On 23/05/17 16:26 -0400, Jason Merrill wrote: On Tue, May 23, 2017 at 2:00 PM, Jonathan Wakely wrote: On 19/05/17 15:14 -0400, Jason Merrill wrote: On Thu, Apr 27, 2017 at 12:59 PM, Jonathan Wakely wrote: I also tried to add a warning like EDG's

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-23 Thread Jason Merrill
On Tue, May 23, 2017 at 2:00 PM, Jonathan Wakely wrote: > On 19/05/17 15:14 -0400, Jason Merrill wrote: >> >> On Thu, Apr 27, 2017 at 12:59 PM, Jonathan Wakely >> wrote: >>> >>> I also tried to add a warning like EDG's (see the PR) but it gave a >>> false

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-23 Thread Jonathan Wakely
On 23/05/17 13:58 -0400, Nathan Sidwell wrote: On 05/23/2017 01:56 PM, Jonathan Wakely wrote: On 18/05/17 13:44 -0400, Nathan Sidwell wrote: References can't be CV qualified, so the REFERENCE_TYPE check seems superfluous? True. I did it because that matches the semantics of the cast

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-23 Thread Jonathan Wakely
On 19/05/17 15:14 -0400, Jason Merrill wrote: On Thu, Apr 27, 2017 at 12:59 PM, Jonathan Wakely wrote: I also tried to add a warning like EDG's (see the PR) but it gave a false positive for direct-list-init of scoped enums (P0138R2, r240449) because that code goes through

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-23 Thread Nathan Sidwell
On 05/23/2017 01:56 PM, Jonathan Wakely wrote: On 18/05/17 13:44 -0400, Nathan Sidwell wrote: References can't be CV qualified, so the REFERENCE_TYPE check seems superfluous? True. I did it because that matches the semantics of the cast according to the standard, but it isn't needed here.

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-23 Thread Jonathan Wakely
On 18/05/17 13:44 -0400, Nathan Sidwell wrote: On 05/18/2017 01:40 PM, Jonathan Wakely wrote: + /* A prvalue of non-class type is cv-unqualified. */ + if (TREE_CODE (type) != REFERENCE_TYPE && !CLASS_TYPE_P (type)) +type = cv_unqualified (type); + References can't be CV qualified, so

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-19 Thread Jason Merrill
On Thu, Apr 27, 2017 at 12:59 PM, Jonathan Wakely wrote: > I also tried to add a warning like EDG's (see the PR) but it gave a > false positive for direct-list-init of scoped enums (P0138R2, r240449) > because that code goes through build_c_cast to perform the conversion, > so

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-18 Thread Nathan Sidwell
On 05/18/2017 01:40 PM, Jonathan Wakely wrote: + /* A prvalue of non-class type is cv-unqualified. */ + if (TREE_CODE (type) != REFERENCE_TYPE && !CLASS_TYPE_P (type)) +type = cv_unqualified (type); + References can't be CV qualified, so the REFERENCE_TYPE check seems superfluous?

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-05-18 Thread Jonathan Wakely
Ping for https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01414.html ... On 27/04/17 17:59 +0100, Jonathan Wakely wrote: This is probably not the best way to do this, but it seems to work. I also tried to add a warning like EDG's (see the PR) but it gave a false positive for direct-list-init of

Re: [PATCH] PR c++/80544 strip cv-quals from cast results

2017-04-27 Thread Paolo Carlini
Hi, On 27/04/2017 18:59, Jonathan Wakely wrote: This is probably not the best way to do this, but it seems to work. Eventually, if this is the way to go, a small maybe_strip_* helper could tidy a bit the code... Paolo.