[PATCH v2] c++: Mitigate -Wuseless-cast with classes [PR85043]

2022-10-19 Thread Marek Polacek via Gcc-patches
On Wed, Oct 19, 2022 at 09:27:27AM -0400, Jason Merrill wrote: > On 10/18/22 13:38, Marek Polacek wrote: > > -Wuseless-cast (not part of -Wall/-Wextra) warns here: > > > >struct S { }; > >void g (S&&); > >void f (S&& arg) > >{ > > g (S(arg)); // warning: useless cast to type

[PATCH] c++: Mitigate -Wuseless-cast with classes [PR85043]

2022-10-18 Thread Marek Polacek via Gcc-patches
-Wuseless-cast (not part of -Wall/-Wextra) warns here: struct S { }; void g (S&&); void f (S&& arg) { g (S(arg)); // warning: useless cast to type 'struct S' } which is wrong: the code will not compile without the cast because "arg" is an lvalue which cannot bind to S&&. I'd like

Re: [PATCH v2] c++: ICE with VEC_INIT_EXPR and defarg [PR106925]

2022-10-13 Thread Marek Polacek via Gcc-patches
On Wed, Oct 12, 2022 at 02:23:40PM -0400, Marek Polacek wrote: > On Wed, Oct 12, 2022 at 01:12:57PM -0400, Marek Polacek wrote: > > On Wed, Oct 12, 2022 at 12:47:21PM -0400, Jason Merrill wrote: > > > On 10/12/22 12:27, Marek Polacek wrote: > > > > On Tue, Oct 11, 2022 at 04:28:11PM -0400, Jason

Re: [wwwdocs] porting_to: Two-stage overload resolution for implicit move removed

2022-10-12 Thread Marek Polacek via Gcc-patches
On Wed, Oct 12, 2022 at 11:38:01PM +0100, Jonathan Wakely wrote: > On Wed, 12 Oct 2022 at 23:24, Marek Polacek wrote: > > > > On Wed, Oct 12, 2022 at 09:50:36PM +0100, Jonathan Wakely wrote: > > > On Wed, 12 Oct 2022 at 20:39, Marek Polacek wrote: > > > > > > > > As I promised in > > > >

Re: [wwwdocs] porting_to: Two-stage overload resolution for implicit move removed

2022-10-12 Thread Marek Polacek via Gcc-patches
On Wed, Oct 12, 2022 at 09:50:36PM +0100, Jonathan Wakely wrote: > On Wed, 12 Oct 2022 at 20:39, Marek Polacek wrote: > > > > As I promised in > > , > > I'd like to update our GCC 13 porting_to.html with the following note. > > >

[wwwdocs] porting_to: Two-stage overload resolution for implicit move removed

2022-10-12 Thread Marek Polacek via Gcc-patches
As I promised in , I'd like to update our GCC 13 porting_to.html with the following note. Does this look OK to commit? Thanks, diff --git a/htdocs/gcc-13/porting_to.html b/htdocs/gcc-13/porting_to.html index 84a00f21..243ed29d

Re: [PATCH v2] c++: ICE with VEC_INIT_EXPR and defarg [PR106925]

2022-10-12 Thread Marek Polacek via Gcc-patches
On Wed, Oct 12, 2022 at 01:12:57PM -0400, Marek Polacek wrote: > On Wed, Oct 12, 2022 at 12:47:21PM -0400, Jason Merrill wrote: > > On 10/12/22 12:27, Marek Polacek wrote: > > > On Tue, Oct 11, 2022 at 04:28:11PM -0400, Jason Merrill wrote: > > > > On 10/11/22 16:00, Marek Polacek wrote: > > > > >

Re: [PATCH] c++: Implement excess precision support for C++ [PR107097, PR323]

2022-10-12 Thread Marek Polacek via Gcc-patches
On Tue, Oct 11, 2022 at 03:33:23PM +0200, Jakub Jelinek via Gcc-patches wrote: > Hi! > > The following patch implements excess precision support for C++. > Like for C, it uses EXCESS_PRECISION_EXPR tree to say that its operand > is evaluated in excess precision and what the semantic type of the >

Re: [PATCH v2] c++: ICE with VEC_INIT_EXPR and defarg [PR106925]

2022-10-12 Thread Marek Polacek via Gcc-patches
On Wed, Oct 12, 2022 at 12:47:21PM -0400, Jason Merrill wrote: > On 10/12/22 12:27, Marek Polacek wrote: > > On Tue, Oct 11, 2022 at 04:28:11PM -0400, Jason Merrill wrote: > > > On 10/11/22 16:00, Marek Polacek wrote: > > > > Since r12-8066, in cxx_eval_vec_init we perform expand_vec_init_expr > >

[PATCH v2] c++: ICE with VEC_INIT_EXPR and defarg [PR106925]

2022-10-12 Thread Marek Polacek via Gcc-patches
On Tue, Oct 11, 2022 at 04:28:11PM -0400, Jason Merrill wrote: > On 10/11/22 16:00, Marek Polacek wrote: > > Since r12-8066, in cxx_eval_vec_init we perform expand_vec_init_expr > > while processing the default argument in this test. > > Hmm, why are we calling cxx_eval_vec_init during parsing of

Re: [PATCH v5] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-10-11 Thread Marek Polacek via Gcc-patches
On Tue, Oct 11, 2022 at 09:40:45AM +0200, Andreas Schwab via Gcc-patches wrote: > On Okt 10 2022, Marek Polacek via Gcc-patches wrote: > > > diff --git a/gcc/testsuite/c-c++-common/pointer-to-fn1.c > > b/gcc/testsuite/c-c++-common/pointer-to-fn1.c > > new file mode 1006

[PATCH] c++: ICE with VEC_INIT_EXPR and defarg [PR106925]

2022-10-11 Thread Marek Polacek via Gcc-patches
Since r12-8066, in cxx_eval_vec_init we perform expand_vec_init_expr while processing the default argument in this test. At this point start_preparsed_function hasn't yet set current_function_decl. expand_vec_init_expr then leads to maybe_splice_retval_cleanup which checks DECL_CONSTRUCTOR_P

[PATCH] testsuite: Only run -fcf-protection test on i?86/x86_64 [PR107213]

2022-10-11 Thread Marek Polacek via Gcc-patches
This test fails on non-i?86/x86_64 targets because on those targets we get error: '-fcf-protection=full' is not supported for this target so this patch limits where the test is run. Tested on x86_64-pc-linux-gnu, ok for trunk? gcc/testsuite/ChangeLog: *

Re: [PATCH] c++: Remove maybe-rvalue OR in implicit move

2022-10-10 Thread Marek Polacek via Gcc-patches
Ping. On Wed, Sep 28, 2022 at 05:26:34PM -0400, Marek Polacek via Gcc-patches wrote: > This patch removes the two-stage overload resolution when performing > implicit move, whereby the compiler does two separate overload resolutions: > one treating the operand as

[PATCH v5] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-10-10 Thread Marek Polacek via Gcc-patches
On Mon, Oct 10, 2022 at 10:49:34AM -0400, Jason Merrill wrote: > On 10/7/22 18:16, Marek Polacek wrote: > > On Fri, Oct 07, 2022 at 05:56:18PM -0400, Jason Merrill wrote: > > > On 10/7/22 17:08, Marek Polacek wrote: > > > > On Fri, Oct 07, 2022 at 12:17:34PM -0400, Jason Merrill wrote: > > > > >

Re: [PATCH v4] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-10-07 Thread Marek Polacek via Gcc-patches
On Fri, Oct 07, 2022 at 05:56:18PM -0400, Jason Merrill wrote: > On 10/7/22 17:08, Marek Polacek wrote: > > On Fri, Oct 07, 2022 at 12:17:34PM -0400, Jason Merrill wrote: > > > On 10/6/22 22:12, Marek Polacek wrote: > > > > On Thu, Oct 06, 2022 at 05:42:41PM -0400, Jason Merrill wrote: > > > > >

[PATCH v5] c++: fixes for derived-to-base reference binding [PR107085]

2022-10-07 Thread Marek Polacek via Gcc-patches
On Fri, Oct 07, 2022 at 01:01:35PM -0400, Jason Merrill wrote: > On 10/7/22 12:10, Marek Polacek wrote: > > On Thu, Oct 06, 2022 at 06:03:57PM -0400, Jason Merrill wrote: > > > On 10/6/22 17:43, Marek Polacek wrote: > > > > On Thu, Oct 06, 2022 at 02:00:40PM -0400, Jason Merrill wrote: > > > > >

[PATCH v4] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-10-07 Thread Marek Polacek via Gcc-patches
On Fri, Oct 07, 2022 at 12:17:34PM -0400, Jason Merrill wrote: > On 10/6/22 22:12, Marek Polacek wrote: > > On Thu, Oct 06, 2022 at 05:42:41PM -0400, Jason Merrill wrote: > > > On 10/4/22 19:06, Marek Polacek wrote: > > > > On Fri, Sep 30, 2022 at 09:12:24AM -0400, Jason Merrill wrote: > > > > >

[PATCH v4] c++: fixes for derived-to-base reference binding [PR107085]

2022-10-07 Thread Marek Polacek via Gcc-patches
On Thu, Oct 06, 2022 at 06:03:57PM -0400, Jason Merrill wrote: > On 10/6/22 17:43, Marek Polacek wrote: > > On Thu, Oct 06, 2022 at 02:00:40PM -0400, Jason Merrill wrote: > > > On 10/6/22 13:51, Marek Polacek wrote: > > > > On Thu, Oct 06, 2022 at 10:58:44AM -0400, Jason Merrill wrote: > > > > >

[PATCH v3] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-10-06 Thread Marek Polacek via Gcc-patches
On Thu, Oct 06, 2022 at 05:42:41PM -0400, Jason Merrill wrote: > On 10/4/22 19:06, Marek Polacek wrote: > > On Fri, Sep 30, 2022 at 09:12:24AM -0400, Jason Merrill wrote: > > > On 9/29/22 18:49, Marek Polacek wrote: > > > > When getting the name of an attribute, we ought to use > > > >

[PATCH v3] c++: fixes for derived-to-base reference binding [PR107085]

2022-10-06 Thread Marek Polacek via Gcc-patches
On Thu, Oct 06, 2022 at 02:00:40PM -0400, Jason Merrill wrote: > On 10/6/22 13:51, Marek Polacek wrote: > > On Thu, Oct 06, 2022 at 10:58:44AM -0400, Jason Merrill wrote: > > > On 10/6/22 10:49, Marek Polacek wrote: > > > > On Wed, Oct 05, 2022 at 08:25:29PM -0400, Jason Merrill wrote: > > > > >

Re: [PATCH v2] c++: fixes for derived-to-base reference binding [PR107085]

2022-10-06 Thread Marek Polacek via Gcc-patches
On Thu, Oct 06, 2022 at 10:58:44AM -0400, Jason Merrill wrote: > On 10/6/22 10:49, Marek Polacek wrote: > > On Wed, Oct 05, 2022 at 08:25:29PM -0400, Jason Merrill wrote: > > > On 10/5/22 17:27, Marek Polacek wrote: > > > > This PR reports that > > > > > > > > struct Base {}; > > > >

[PATCH v2] c++: fixes for derived-to-base reference binding [PR107085]

2022-10-06 Thread Marek Polacek via Gcc-patches
On Wed, Oct 05, 2022 at 08:25:29PM -0400, Jason Merrill wrote: > On 10/5/22 17:27, Marek Polacek wrote: > > This PR reports that > > > >struct Base {}; > >struct Derived : Base {}; > >static_assert(__reference_constructs_from_temporary(Base const&, > > Derived)); > > > > doesn't

[PATCH] c++: fixes for derived-to-base reference binding [PR107085]

2022-10-05 Thread Marek Polacek via Gcc-patches
This PR reports that struct Base {}; struct Derived : Base {}; static_assert(__reference_constructs_from_temporary(Base const&, Derived)); doesn't pass, which it should: it's just like const Base& b(Derived{}); where we bind 'b' to the Base subobject of a temporary object of type

[PATCH v2] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-10-04 Thread Marek Polacek via Gcc-patches
On Fri, Sep 30, 2022 at 09:12:24AM -0400, Jason Merrill wrote: > On 9/29/22 18:49, Marek Polacek wrote: > > When getting the name of an attribute, we ought to use > > get_attribute_name, which handles both [[ ]] and __attribute__(()) > > forms. Failure to do so may result in an ICE, like here. >

[PATCH] c-family: ICE with [[gnu::nocf_check]] [PR106937]

2022-09-29 Thread Marek Polacek via Gcc-patches
When getting the name of an attribute, we ought to use get_attribute_name, which handles both [[ ]] and __attribute__(()) forms. Failure to do so may result in an ICE, like here. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c++/106937 gcc/c-family/ChangeLog:

Re: [PATCH RFC] c++: streamline process for adding new builtin trait

2022-09-29 Thread Marek Polacek via Gcc-patches
On Thu, Sep 29, 2022 at 11:05:04AM -0400, Patrick Palka via Gcc-patches wrote: > Adding a new builtin trait currently involves some boilerplate (as can > be seen in r13-2956-g9ca147154074a0) of defining corresponding RID_ and > CPTK_ enumerators and adding them to various switch statements across

[PATCH] c++: Remove maybe-rvalue OR in implicit move

2022-09-28 Thread Marek Polacek via Gcc-patches
This patch removes the two-stage overload resolution when performing implicit move, whereby the compiler does two separate overload resolutions: one treating the operand as an rvalue, and then (if that resolution fails) another one treating the operand as an lvalue. In the standard this was

Re: [PATCH v3] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-27 Thread Marek Polacek via Gcc-patches
On Tue, Sep 27, 2022 at 05:44:12PM -0400, Jason Merrill wrote: > On 9/27/22 16:26, Marek Polacek wrote: > > --- a/gcc/cp/typeck.cc > > +++ b/gcc/cp/typeck.cc > > @@ -11042,8 +11042,13 @@ check_return_expr (tree retval, bool *no_warning) > > the conditions for the named return value

[PATCH v3] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-27 Thread Marek Polacek via Gcc-patches
On Mon, Sep 26, 2022 at 01:29:35PM -0400, Jason Merrill wrote: > On 9/20/22 14:19, Marek Polacek wrote: > > > > There's one FIXME in elision1.C:five, which we should compile but reject > > > > with "passing 'Mutt' as 'this' argument discards qualifiers". That > > > > looks bogus to me, I think

Re: [PATCH v2] c++: Don't quote nothrow in diagnostic

2022-09-27 Thread Marek Polacek via Gcc-patches
On Tue, Sep 27, 2022 at 10:41:29AM +0200, Richard Biener wrote: > On Mon, Sep 26, 2022 at 9:54 PM Marek Polacek wrote: > > > > On Mon, Sep 26, 2022 at 12:34:04PM -0400, Jason Merrill wrote: > > > On 9/26/22 03:50, Richard Biener wrote: > > > > On Fri, Sep 23, 2

Re: [PATCH] c++: Make __is_{,nothrow_}convertible SFINAE on access [PR107049]

2022-09-27 Thread Marek Polacek via Gcc-patches
On Tue, Sep 27, 2022 at 11:35:10AM +0100, Jonathan Wakely wrote: > Tested powerpc64le-linux. OK for trunk? > > -- >8 -- > > The is_convertible built-ins should return false if the conversion fails > an access check, not report an error. Ah, so we do need that sentinel after all. Patch looks

[PATCH v2] c++: Don't quote nothrow in diagnostic

2022-09-26 Thread Marek Polacek via Gcc-patches
On Mon, Sep 26, 2022 at 12:34:04PM -0400, Jason Merrill wrote: > On 9/26/22 03:50, Richard Biener wrote: > > On Fri, Sep 23, 2022 at 8:41 PM Marek Polacek via Gcc-patches > > wrote: > > > > > > In <https://gcc.gnu.org/pipermail/gcc-patches/2022-September/6020

Re: [PATCH] c++: Instantiate less when evaluating __is_convertible

2022-09-26 Thread Marek Polacek via Gcc-patches
On Mon, Sep 26, 2022 at 05:02:36PM +0100, Jonathan Wakely wrote: > On Mon, 26 Sept 2022 at 16:23, Marek Polacek wrote: > > > > Jon reported that evaluating __is_convertible in this test leads to > > instantiating char_traits::eq, which is invalid (because we > > are trying to call a member

[PATCH v2] c++: Instantiate less when evaluating __is_convertible

2022-09-26 Thread Marek Polacek via Gcc-patches
On Mon, Sep 26, 2022 at 11:51:30AM -0400, Patrick Palka wrote: > On Mon, 26 Sep 2022, Marek Polacek via Gcc-patches wrote: > > > Jon reported that evaluating __is_convertible in this test leads to > > instantiating char_traits::eq, which is invalid (because we > > are

[PATCH] c++: Instantiate less when evaluating __is_convertible

2022-09-26 Thread Marek Polacek via Gcc-patches
Jon reported that evaluating __is_convertible in this test leads to instantiating char_traits::eq, which is invalid (because we are trying to call a member function on a char) and so we fail to compile the test. __is_convertible doesn't and shouldn't need to instantiate so much, so let's limit it

[PATCH] c++: P2513R4, char8_t Compatibility and Portability Fix [PR106656]

2022-09-23 Thread Marek Polacek via Gcc-patches
P0482R6, which added char8_t, didn't allow const char arr[] = u8"howdy"; because it said "Declarations of arrays of char may currently be initialized with UTF-8 string literals. Under this proposal, such initializations would become ill-formed." This caused too many issues, so P2513R4

[PATCH] c++: Don't quote nothrow in diagnostic

2022-09-23 Thread Marek Polacek via Gcc-patches
In Jason noticed that we quote "nothrow" in diagnostics even though it's not a keyword in C++. Just removing the quotes didn't work because then -Wformat-diag complains, so this patch replaces it with "no-throw".

Re: [PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784]

2022-09-23 Thread Marek Polacek via Gcc-patches
On Fri, Sep 23, 2022 at 05:34:21PM +0100, Jonathan Wakely wrote: > On Fri, 23 Sept 2022 at 15:43, Jonathan Wakely wrote: > > > > On Fri, 23 Sept 2022 at 15:34, Marek Polacek wrote: > > > > > > On Thu, Sep 22, 2022 at 06:14:44PM -0400, Jason Merrill wrote: > > > > On 9/22/22 09:39, Marek Polacek

Re: [PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784]

2022-09-23 Thread Marek Polacek via Gcc-patches
On Fri, Sep 23, 2022 at 11:54:53AM -0400, Jason Merrill wrote: > On 9/23/22 10:34, Marek Polacek wrote: > > On Thu, Sep 22, 2022 at 06:14:44PM -0400, Jason Merrill wrote: > > > On 9/22/22 09:39, Marek Polacek wrote: > > > > To improve compile times, the C++ library could use compiler built-ins > >

Re: [PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784]

2022-09-23 Thread Marek Polacek via Gcc-patches
On Fri, Sep 23, 2022 at 03:40:23PM +0100, Jonathan Wakely wrote: > On Thu, 22 Sept 2022 at 23:14, Jason Merrill wrote: > > On 9/22/22 09:39, Marek Polacek wrote: > > > This patch doesn't make libstdc++ use the new built-ins, but I had to > > > rename a class otherwise its name would clash with the

Re: [PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784]

2022-09-23 Thread Marek Polacek via Gcc-patches
On Thu, Sep 22, 2022 at 06:14:44PM -0400, Jason Merrill wrote: > On 9/22/22 09:39, Marek Polacek wrote: > > To improve compile times, the C++ library could use compiler built-ins > > rather than implementing std::is_convertible (and _nothrow) as class > > templates. This patch adds the built-ins.

[PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784]

2022-09-22 Thread Marek Polacek via Gcc-patches
To improve compile times, the C++ library could use compiler built-ins rather than implementing std::is_convertible (and _nothrow) as class templates. This patch adds the built-ins. We already have __is_constructible and __is_assignable, and the nothrow forms of those. Microsoft (and clang, for

[PATCH] c++: ICE-on-invalid with designated initializer [PR106983]

2022-09-20 Thread Marek Polacek via Gcc-patches
We ICE in the code added in r12-7117: type_build_dtor_call gets the error_mark_node because the type of 'prev' wasn't declared. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c++/106983 gcc/cp/ChangeLog: * typeck2.cc (split_nonconstant_init_1): Check TYPE_P.

Re: [PATCH] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-20 Thread Marek Polacek via Gcc-patches
On Mon, Sep 12, 2022 at 04:27:27PM -0400, Jason Merrill wrote: > On 9/8/22 18:54, Marek Polacek wrote: > > On Tue, Sep 06, 2022 at 10:38:12PM -0400, Jason Merrill wrote: > > > On 9/3/22 12:42, Marek Polacek wrote: > > > > This patch implements https://wg21.link/p2266, which, once again, > > > >

[PATCH v2] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-20 Thread Marek Polacek via Gcc-patches
On Tue, Sep 06, 2022 at 10:38:12PM -0400, Jason Merrill wrote: > On 9/3/22 12:42, Marek Polacek wrote: > > This patch implements https://wg21.link/p2266, which, once again, > > changes the implicit move rules. Here's a brief summary of various > > changes in this area: > > > > r125211:

[PATCH] c: Stray inform note with -Waddress [PR106947]

2022-09-19 Thread Marek Polacek via Gcc-patches
A trivial fix for maybe_warn_for_null_address where we print an inform note without first checking the return value of a warning call. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/12? PR c/106947 gcc/c/ChangeLog: * c-typeck.cc (maybe_warn_for_null_address): Don't

Re: [PATCH] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-08 Thread Marek Polacek via Gcc-patches
On Tue, Sep 06, 2022 at 10:38:12PM -0400, Jason Merrill wrote: > On 9/3/22 12:42, Marek Polacek wrote: > > This patch implements https://wg21.link/p2266, which, once again, > > changes the implicit move rules. Here's a brief summary of various > > changes in this area: > > > > r125211:

[PATCH] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-03 Thread Marek Polacek via Gcc-patches
This patch implements https://wg21.link/p2266, which, once again, changes the implicit move rules. Here's a brief summary of various changes in this area: r125211: Introduced moving from certain lvalues when returning them r171071: CWG 1148, enable move from value parameter on return r212099:

[pushed] c++: Remove unused declaration

2022-09-01 Thread Marek Polacek via Gcc-patches
This declaration was added in r260905 but the function was never defined. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * cp-tree.h (maybe_strip_ref_conversion): Remove. --- gcc/cp/cp-tree.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gcc/cp/cp-tree.h

Re: [PATCH] c/c++: new warning: -Wxor-used-as-pow [PR90885]

2022-08-30 Thread Marek Polacek via Gcc-patches
This looks good to me, one thing though: On Thu, Aug 11, 2022 at 09:38:12PM -0400, David Malcolm via Gcc-patches wrote: > --- a/gcc/c-family/c.opt > +++ b/gcc/c-family/c.opt > @@ -1439,6 +1439,10 @@ Wwrite-strings > C ObjC C++ ObjC++ Var(warn_write_strings) Warning > In C++, nonzero means warn

Re: -Wformat-overflow handling for %b and %B directives in C2X standard

2022-08-30 Thread Marek Polacek via Gcc-patches
On Mon, Aug 15, 2022 at 07:42:39PM +0300, Frolov Daniil wrote: > вт, 12 апр. 2022 г. в 00:56, Marek Polacek : > > > > > On Thu, Apr 07, 2022 at 02:10:48AM +0500, Frolov Daniil wrote: > > > Hello! Thanks for your feedback. I've tried to take into account your > > > comments. New patch applied to

Re: C++: add -std={c,gnu}++{current,future}

2022-08-30 Thread Marek Polacek via Gcc-patches
On Tue, Aug 30, 2022 at 09:22:14AM -0400, Jason Merrill via Gcc-patches wrote: > On 7/13/22 15:29, Nathan Sidwell wrote: > > Inspired by a user question.  Jason, thoughts? > > > > Since C++ is such a moving target, Microsoft have /std:c++latest > > (AFAICT clang does not), to select the currently

Re: C++: add -std={c,gnu}++{current,future}

2022-08-30 Thread Marek Polacek via Gcc-patches
On Wed, Jul 13, 2022 at 03:29:04PM -0400, Nathan Sidwell via Gcc-patches wrote: > Inspired by a user question. Jason, thoughts? FWIW, this makes sense. I mean, how could I be against a patch quoting Macbeth?! > Since C++ is such a moving target, Microsoft have /std:c++latest > (AFAICT clang

[PATCH] c++: __has_builtin gives the wrong answer [PR106759]

2022-08-29 Thread Marek Polacek via Gcc-patches
We've supported __is_nothrow_constructible since r11-4386, but names_builtin_p didn't know about it, so it gave the wrong answer for #if __has_builtin(__is_nothrow_constructible) ... #endif I've tested all C++-only built-ins and only two were missing. Bootstrapped/regtested on

[PATCH v2] c++: Fix C++11 attribute propagation [PR106712]

2022-08-29 Thread Marek Polacek via Gcc-patches
On Mon, Aug 29, 2022 at 01:32:29PM -0400, Jason Merrill wrote: > On 8/26/22 19:01, Marek Polacek wrote: > > When we have > > > >[[noreturn]] int fn1 [[nodiscard]](), fn2(); > > > > "noreturn" should apply to both fn1 and fn2 but "nodiscard" only to fn1: > > [dcl.pre]/3: "The

[PATCH] c++: Fix C++11 attribute propagation [PR106712]

2022-08-26 Thread Marek Polacek via Gcc-patches
When we have [[noreturn]] int fn1 [[nodiscard]](), fn2(); "noreturn" should apply to both fn1 and fn2 but "nodiscard" only to fn1: [dcl.pre]/3: "The attribute-specifier-seq appertains to each of the entities declared by the declarators of the init-declarator-list." [dcl.spec.general]: "The

[PATCH v5] c++: Implement -Wself-move warning [PR81159]

2022-08-26 Thread Marek Polacek via Gcc-patches
On Thu, Aug 25, 2022 at 08:52:58PM -0400, Jason Merrill wrote: > On 8/25/22 17:49, Marek Polacek wrote: > > On Thu, Aug 25, 2022 at 09:25:43AM -0400, Jason Merrill wrote: > > > On 8/24/22 17:30, Marek Polacek wrote: > > > > On Tue, Aug 23, 2022 at 05:27:00PM -0400, Jason Merrill wrote: > > > > >

Re: [PATCH v3] c: Implement C23 nullptr (N3042)

2022-08-25 Thread Marek Polacek via Gcc-patches
On Thu, Aug 25, 2022 at 09:12:07PM +, Joseph Myers wrote: > On Thu, 25 Aug 2022, Marek Polacek via Gcc-patches wrote: > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > This version is OK. Thanks a lot. I've gone ahead and updated GCC 13 cha

Re: [PATCH v4] c++: Implement -Wself-move warning [PR81159]

2022-08-25 Thread Marek Polacek via Gcc-patches
On Thu, Aug 25, 2022 at 09:25:43AM -0400, Jason Merrill wrote: > On 8/24/22 17:30, Marek Polacek wrote: > > On Tue, Aug 23, 2022 at 05:27:00PM -0400, Jason Merrill wrote: > > > On 8/23/22 09:39, Marek Polacek wrote: > > > > + tree arg = CALL_EXPR_ARG (fn, 0); > > > > + extract_op (arg); > > > >

[PATCH v3] c: Implement C23 nullptr (N3042)

2022-08-25 Thread Marek Polacek via Gcc-patches
On Thu, Aug 25, 2022 at 05:28:09PM +, Joseph Myers wrote: > On Wed, 24 Aug 2022, Marek Polacek via Gcc-patches wrote: > > > Ah, okay. I had just copied what we do in C++ in null_ptr_cst_p and the > > rest of the patch worked under that assumption. I've added some test

Re: [PATCH v4] c++: Implement -Wself-move warning [PR81159]

2022-08-24 Thread Marek Polacek via Gcc-patches
On Tue, Aug 23, 2022 at 05:27:00PM -0400, Jason Merrill wrote: > On 8/23/22 09:39, Marek Polacek wrote: > > + tree arg = CALL_EXPR_ARG (fn, 0); > > + extract_op (arg); > > + if (TREE_CODE (arg) == ADDR_EXPR) > > +arg = TREE_OPERAND (arg, 0); > > + tree type = TREE_TYPE (lhs); > > + lhs =

Re: [PATCH] c: Implement C23 nullptr (N3042)

2022-08-24 Thread Marek Polacek via Gcc-patches
On Mon, Aug 15, 2022 at 04:03:13PM -0400, Jason Merrill wrote: > On 8/13/22 14:35, Marek Polacek wrote: > > This patch implements the C23 nullptr literal: > > , which is > > intended to replace the problematic definition of NULL which

[PATCH v2] c: Implement C23 nullptr (N3042)

2022-08-24 Thread Marek Polacek via Gcc-patches
On Mon, Aug 15, 2022 at 05:48:34PM +, Joseph Myers wrote: > On Sat, 13 Aug 2022, Marek Polacek via Gcc-patches wrote: > > > This patch also defines nullptr_t in . I'm uncertain about > > the __STDC_VERSION__ version I should be checking. Also, I'm not >

[PATCH v4] c++: Implement -Wself-move warning [PR81159]

2022-08-23 Thread Marek Polacek via Gcc-patches
On Sat, Aug 20, 2022 at 05:31:52PM -0400, Jason Merrill wrote: > On 8/19/22 15:34, Marek Polacek wrote: > > On Thu, Aug 18, 2022 at 08:33:47PM -0400, Jason Merrill wrote: > > > On 8/18/22 13:19, Marek Polacek wrote: > > > > On Mon, Aug 15, 2022 at 03:54:05PM -0400, Jason Merrill wrote: > > > > >

[PATCH] c++: Quash bogus -Wredundant-move warning

2022-08-22 Thread Marek Polacek via Gcc-patches
This patch fixes a pretty stoopid thinko. When I added code to warn about pessimizing std::move in initializations like T t{std::move(T())}; I also added code to unwrap the expression from { }. But when we have return {std::move(t)}; we cannot warn about a redundant std::move because the

Re: [PATCH] c++: Extend -Wpessimizing-move to other contexts

2022-08-22 Thread Marek Polacek via Gcc-patches
On Mon, Aug 22, 2022 at 01:48:34PM +0200, Stephan Bergmann wrote: > On 16/08/2022 14:27, Marek Polacek via Gcc-patches wrote: > > Ping. (The other std::move patches depend on this one.) > > <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8d22c7cb8b1a6f9b67c54a798dd5504244614e

[PATCH v2] testsuite: Add test for r11-4123

2022-08-22 Thread Marek Polacek via Gcc-patches
On Mon, Aug 22, 2022 at 10:16:23AM -0700, Andrew Pinski wrote: > On Mon, Aug 22, 2022 at 9:58 AM Marek Polacek via Gcc-patches > wrote: > > > > r11-4123 came without a test but I happened upon a nice test case that > > got fixed by that revision. So I think it'd be good

[PATCH] testsuite: Add test for r11-4123

2022-08-22 Thread Marek Polacek via Gcc-patches
r11-4123 came without a test but I happened upon a nice test case that got fixed by that revision. So I think it'd be good to add it. The ICE was: phi-1.C: In constructor 'ElementManager::ElementManager()': phi-1.C:28:1: error: missing definition 28 | ElementManager::ElementManager() :

[PATCH v3] c++: Implement -Wself-move warning [PR81159]

2022-08-19 Thread Marek Polacek via Gcc-patches
On Thu, Aug 18, 2022 at 08:33:47PM -0400, Jason Merrill wrote: > On 8/18/22 13:19, Marek Polacek wrote: > > On Mon, Aug 15, 2022 at 03:54:05PM -0400, Jason Merrill wrote: > > > On 8/9/22 09:37, Marek Polacek wrote: > > > > + /* We're looking for *std::move ((T &) ), or > > > > + *std::move

[PATCH v2] c++: Implement -Wself-move warning [PR81159]

2022-08-18 Thread Marek Polacek via Gcc-patches
On Mon, Aug 15, 2022 at 03:54:05PM -0400, Jason Merrill wrote: > On 8/9/22 09:37, Marek Polacek wrote: > > + /* We're looking for *std::move ((T &) ), or > > + *std::move ((T &) (T *) r) if the argument it a reference. */ > > + if (!REFERENCE_REF_P (rhs) > > + || TREE_CODE

[pushed] c++: Add new std::move test [PR67906]

2022-08-17 Thread Marek Polacek via Gcc-patches
As discussed in 67906, let's make sure we don't warn about a std::move when initializing when there's a T(const T&&) ctor. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/67906 gcc/testsuite/ChangeLog: * g++.dg/cpp0x/Wredundant-move11.C: New test. ---

Re: [PATCH v2] c++: Extend -Wredundant-move for const-qual objects [PR90428]

2022-08-17 Thread Marek Polacek via Gcc-patches
On Mon, Aug 15, 2022 at 03:43:38PM -0400, Jason Merrill wrote: > On 8/8/22 13:27, Marek Polacek wrote: > > This is to warn about this: > > > > T f5(const T t) > > { > >return std::move(t); // { dg-warning "redundant move" } > > } > > > > where OR fails because there's no T(const T&&) (or

Re: add more C++ name hints

2022-08-17 Thread Marek Polacek via Gcc-patches
On Fri, Aug 05, 2022 at 09:35:33PM +0200, Ulrich Drepper via Gcc-patches wrote: > How about adding a few more names from the std namespace to get appropriate > hints? This patch compiles and the appropriate messages are printed. Is > there a problem with just adding more or even at some point

Re: [PATCH] c++: Extend -Wpessimizing-move to other contexts

2022-08-16 Thread Marek Polacek via Gcc-patches
On Tue, Aug 16, 2022 at 03:23:18PM -0400, Jason Merrill wrote: > On 8/2/22 16:04, Marek Polacek wrote: > > In my recent patch which enhanced -Wpessimizing-move so that it warns > > about class prvalues too I said that I'd like to extend it so that it > > warns in more contexts where a std::move

[wwwdocs] Add C++23 papers approved by WG21 at the July plenary

2022-08-16 Thread Marek Polacek via Gcc-patches
We have a lot of new papers to implement. I've also opened PRs for them. Pushed. commit c6f8ab1adad76d2b43f6cbdacd84202131ae1e5c Author: Marek Polacek Date: Tue Aug 16 13:39:34 2022 -0400 cxx-status: Add C++23 papers approved by WG21 at the July plenary diff --git

[wwwdocs] Update C++ DR table from Core Language Issue TOC, Revision 109

2022-08-16 Thread Marek Polacek via Gcc-patches
A lot of updates this time. Pushed. commit 0a423169f0abf14b765493d7b11b790d847494e8 Author: Marek Polacek Date: Tue Aug 16 11:32:24 2022 -0400 cxx-dr-status: Update from C++ Core Language Issue TOC, Revision 109 diff --git a/htdocs/projects/cxx-dr-status.html

Re: [PATCH] c++: Extend -Wpessimizing-move to other contexts

2022-08-16 Thread Marek Polacek via Gcc-patches
Ping. (The other std::move patches depend on this one.) (can_do_rvo_p is renamed to can_elide_copy_prvalue_p in the PR90428 patch.) On Tue, Aug 02, 2022 at 07:04:47PM -0400, Marek Polacek via Gcc-patches wrote: > In my recent patch which enhanced -Wpessimizing-move so that it warns >

Re: [PATCH] c++: Implement P2327R1 - De-deprecating volatile compound operations

2022-08-15 Thread Marek Polacek via Gcc-patches
On Mon, Aug 15, 2022 at 12:31:10PM +0200, Jakub Jelinek wrote: > Hi! > > From what I can see, this has been voted in as a DR and as it means > we warn less often than before in -std={gnu,c}++2{0,3} modes or with > -Wvolatile, I wonder if it shouldn't be backported to affected release > branches

[PATCH] c: Implement C23 nullptr (N3042)

2022-08-13 Thread Marek Polacek via Gcc-patches
This patch implements the C23 nullptr literal: , which is intended to replace the problematic definition of NULL which might be either of integer type or void*. Since C++ has had nullptr for over a decade now, it was relatively easy to

[PATCH] c++: Implement -Wself-move warning [PR81159]

2022-08-09 Thread Marek Polacek via Gcc-patches
About 5 years ago we got a request to implement -Wself-move, which warns about useless moves like this: int x; x = std::move (x); This patch implements that warning. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c++/81159 gcc/c-family/ChangeLog: * c.opt

Re: [PATCH v2] c++: Extend -Wredundant-move for const-qual objects [PR90428]

2022-08-09 Thread Marek Polacek via Gcc-patches
On Mon, Aug 08, 2022 at 04:27:10PM -0400, Marek Polacek wrote: > + /* Also try to warn about redundant std::move in code such as > + T f (const T& t) > + { > + return std::move(t); > + } > +for which EXPR will be something like > + *std::move ((const struct T &) (const

[PATCH v2] c++: Extend -Wredundant-move for const-qual objects [PR90428]

2022-08-08 Thread Marek Polacek via Gcc-patches
On Sat, Aug 06, 2022 at 03:58:13PM -0800, Jason Merrill wrote: > On 8/6/22 11:13, Marek Polacek wrote: > > In this PR, Jon suggested extending the -Wredundant-move warning > > to warn when the user is moving a const object as in: > > > >struct T { }; > > > >T f(const T& t) > >{ > >

[PATCH v2] c++: Tweak for -Wpessimizing-move in templates [PR89780]

2022-08-08 Thread Marek Polacek via Gcc-patches
On Sat, Aug 06, 2022 at 04:02:13PM -0700, Jason Merrill wrote: > On 8/4/22 11:46, Marek Polacek wrote: > > In my previous patches I've been extending our std::move warnings, > > but this tweak actually dials it down a little bit. As reported in > > bug 89780, it's questionable to warn about

[PATCH v2] c++: Extend -Wpessimizing-move for class prvalues [PR106276]

2022-08-08 Thread Marek Polacek via Gcc-patches
On Sat, Aug 06, 2022 at 04:07:54PM -0700, Jason Merrill wrote: > On 8/6/22 15:49, Jason Merrill wrote: > > On 7/27/22 17:14, Marek Polacek wrote: > > > We already have a warning that warns about pessimizing std::move > > > in a return statement, when it prevents the NRVO: > > > > > >    T fn() >

[PATCH v2] c-family: Honor -Wno-init-self for cv-qual vars [PR102633]

2022-08-08 Thread Marek Polacek via Gcc-patches
On Sat, Aug 06, 2022 at 03:29:05PM -0700, Jason Merrill wrote: > On 7/26/22 14:31, Marek Polacek wrote: > > On Tue, Jul 26, 2022 at 04:24:18PM -0400, Jason Merrill wrote: > > > On 7/26/22 15:03, Marek Polacek wrote: > > > > Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r > > > >

[PATCH] c++: Extend -Wredundant-move for const-qual objects [PR90428]

2022-08-06 Thread Marek Polacek via Gcc-patches
In this PR, Jon suggested extending the -Wredundant-move warning to warn when the user is moving a const object as in: struct T { }; T f(const T& t) { return std::move(t); } where the std::move is redundant, because T does not have a T(const T&&) constructor (which is very

[PATCH] c++: Tweak for -Wpessimizing-move in templates [PR89780]

2022-08-04 Thread Marek Polacek via Gcc-patches
In my previous patches I've been extending our std::move warnings, but this tweak actually dials it down a little bit. As reported in bug 89780, it's questionable to warn about expressions in templates that were type-dependent, but aren't anymore because we're instantiating the template. As in,

[PATCH] c++: Extend -Wpessimizing-move to other contexts

2022-08-02 Thread Marek Polacek via Gcc-patches
In my recent patch which enhanced -Wpessimizing-move so that it warns about class prvalues too I said that I'd like to extend it so that it warns in more contexts where a std::move can prevent copy elision, such as: T t = std::move(T()); T t(std::move(T())); T t{std::move(T())}; T t =

Re: How to check -std=c89 or -std=gnu89 is set in C FE?

2022-08-02 Thread Marek Polacek via Gcc-patches
On Tue, Aug 02, 2022 at 04:19:56PM +, Qing Zhao via Gcc-patches wrote: > Hi, Joseph, > > When -std=c89 or -std=gnu89 present in the command line, in C FE, which flags > should be > checked to decide it’s -std=c89 or -std=gnu89? You should be able to check flag_iso and related. Marek

[PATCH] c++: Extend -Wpessimizing-move for class prvalues [PR106276]

2022-07-27 Thread Marek Polacek via Gcc-patches
We already have a warning that warns about pessimizing std::move in a return statement, when it prevents the NRVO: T fn() { T t; return std::move (t); // warning \o/ } However, the warning doesn't warn when what we are returning is a class prvalue, that is, when std::move prevents

Re: [PATCH] c-family: Honor -Wno-init-self for cv-qual vars [PR102633]

2022-07-27 Thread Marek Polacek via Gcc-patches
On Wed, Jul 27, 2022 at 06:41:09AM +, Richard Biener via Gcc-patches wrote: > On Tue, 26 Jul 2022, Marek Polacek wrote: > > > Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r > > conversion by creating a NOP_EXPR. For e.g. > > > > const int i = i; > > > > that means that

Re: [PATCH] c-family: Honor -Wno-init-self for cv-qual vars [PR102633]

2022-07-26 Thread Marek Polacek via Gcc-patches
On Tue, Jul 26, 2022 at 04:24:18PM -0400, Jason Merrill wrote: > On 7/26/22 15:03, Marek Polacek wrote: > > Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r > > conversion by creating a NOP_EXPR. For e.g. > > > >const int i = i; > > > > that means that the DECL_INITIAL is

[PATCH] c-family: Honor -Wno-init-self for cv-qual vars [PR102633]

2022-07-26 Thread Marek Polacek via Gcc-patches
Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r conversion by creating a NOP_EXPR. For e.g. const int i = i; that means that the DECL_INITIAL is '(int) i' and not 'i' anymore. Consequently, we don't suppress_warning here: 711 case DECL_EXPR: 715 if (VAR_P

[v2 PATCH] c++: ICE with erroneous template redeclaration [PR106311]

2022-07-25 Thread Marek Polacek via Gcc-patches
On Fri, Jul 22, 2022 at 05:21:58PM -0400, Jason Merrill wrote: > On 7/15/22 11:29, Marek Polacek wrote: > > Here we ICE trying to get DECL_SOURCE_LOCATION of the parm that happens > > to be error_mark_node in this ill-formed test. I kept running into this > > while reducing code, so it'd be good

Re: [PATCH] c++: ICE with erroneous template redeclaration [PR106311]

2022-07-22 Thread Marek Polacek via Gcc-patches
Ping. On Fri, Jul 15, 2022 at 11:29:20AM -0400, Marek Polacek via Gcc-patches wrote: > Here we ICE trying to get DECL_SOURCE_LOCATION of the parm that happens > to be error_mark_node in this ill-formed test. I kept running into this > while reducing code, so it'd be good to have

Re: [pushed] match.pd: Add new abs pattern [PR94920]

2022-07-21 Thread Marek Polacek via Gcc-patches
On Thu, Jul 21, 2022 at 05:28:34PM -0400, Sam Feifer via Gcc-patches wrote: > This patch is intended to fix a missed optimization in match.pd. It optimizes > (x >= 0 ? x : 0) + (x <= 0 ? -x : 0) to just abs(x). Additionally, the > pattern (x <= 0 ? -x : 0) now gets optimized to max(-x, 0), which

Re: [PATCH] c++: Enable __has_builtin for new reference binding built-ins

2022-07-19 Thread Marek Polacek via Gcc-patches
On Tue, Jul 19, 2022 at 02:11:02PM +0100, Jonathan Wakely wrote: > Tested x86_64-linux, OK for trunk? > > -- >8 -- > > The new built-ins need to be detectable using __has_builtin, and the > library should use that to check for them. > > This fixes an error with Clang when C++23 is enabled.

Re: [PATCH] c++: Add __reference_con{struc,ver}ts_from_temporary [PR104477]

2022-07-15 Thread Marek Polacek via Gcc-patches
On Fri, Jul 15, 2022 at 10:59:41PM +0300, Ville Voutilainen wrote: > Well, is_xible is not is_xible_p because it doesn't need to be both is_* > and *_p. But xes_from_temporary is less obviously a question, so > xes_from_temporary_p would imho be a better name. Yeah, I guess so. But I've already

Re: [PATCH] c++: Add __reference_con{struc,ver}ts_from_temporary [PR104477]

2022-07-15 Thread Marek Polacek via Gcc-patches
On Thu, Jul 14, 2022 at 11:48:51PM -0400, Jason Merrill wrote: > On 7/14/22 13:43, Marek Polacek wrote: > > On Tue, Jul 12, 2022 at 04:15:00PM -0400, Jason Merrill wrote: > > > On 7/12/22 16:10, Jason Merrill wrote: > > > > On 7/8/22 13:41, Marek Polacek wrote: > > > > > This patch implements

<    1   2   3   4   5   6   7   8   9   10   >