Re: [PATCH] c: Avoid clobbering TREE_TYPE (error_mark_node) [PR99990]

2021-04-10 Thread Marek Polacek via Gcc-patches
On Sat, Apr 10, 2021 at 08:13:08AM +0200, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs during error recovery, because finish_decl > overwrites TREE_TYPE (error_mark_node), which better should stay always > to be error_mark_node. > > Fixed thusly, bootstrapped/regtested on x86_64-lin

[PATCH] c++: ICE with bogus late return type [PR99803]

2021-04-14 Thread Marek Polacek via Gcc-patches
Here we ICE when compiling this code in C++20, because we're trying to slam a 'typename' after the ->. The cp_parser_template_id call just before the spot I'm changing parsed A::template A as a BASELINK that contains a constructor, but make_typename_type crashes on that. My fix is the same as c++

Re: [PATCH] c++: ICE with bogus late return type [PR99803]

2021-04-15 Thread Marek Polacek via Gcc-patches
On Thu, Apr 15, 2021 at 03:31:24PM -0400, Jason Merrill wrote: > On 4/14/21 9:21 PM, Marek Polacek wrote: > > Here we ICE when compiling this code in C++20, because we're trying to > > slam a 'typename' after the ->. The cp_parser_template_id call just > > before the spot I'm changing parsed A::te

[PATCH] c++: ICE with concept defined in function [PR97536]

2021-04-19 Thread Marek Polacek via Gcc-patches
This is an ICE-on-invalid, but I keep seeing it when reducing code so I'd like to fix it. We crash on template void forward() { concept C = true; } which breaks two requirements: [temp.concept]/1: A concept is a template ... [temp.concept]/3: A concept-definition shall inhabit a namespa

[PATCH] c++: Don't allow defining types in enum-base [PR96380]

2021-04-20 Thread Marek Polacek via Gcc-patches
In r11-2064 I made cp_parser_enum_specifier commit to tentative parse when seeing a '{'. That still looks like the correct thing to do, but it caused an ICE-on-invalid as well as accepts-invalid. When we have something sneaky like this, which is broken in multiple ways: template enum struct

[PATCH] c++: Prevent bogus -Wtype-limits warning with NTTP [PR100161]

2021-04-20 Thread Marek Polacek via Gcc-patches
Recently, we made sure that we never call value_dependent_expression_p on an expression that isn't potential_constant_expression. That caused this bogus warning with a non-type template parameter, something that users don't want to see. The problem is that in tsubst_copy_and_build/LE_EXPR 't' is

Re: [PATCH] testsuite: Add -fchecking to dg-ice tests

2021-04-21 Thread Marek Polacek via Gcc-patches
On Wed, Apr 21, 2021 at 12:52:39PM +0200, Jakub Jelinek wrote: > Hi! > > In --enable-checking=release builds (which is the default on release > branches), I'm getting various extra FAILs that don't appear in > --enable-checking=yes builds. > > XPASS: g++.dg/cpp0x/constexpr-52830.C -std=c++14 (in

Re: [PATCH v2] c++: Prevent bogus -Wtype-limits warning with NTTP [PR100161]

2021-04-21 Thread Marek Polacek via Gcc-patches
On Tue, Apr 20, 2021 at 10:40:52PM -0400, Jason Merrill wrote: > On 4/20/21 8:42 PM, Marek Polacek wrote: > > Recently, we made sure that we never call value_dependent_expression_p > > on an expression that isn't potential_constant_expression. That caused > > this bogus warning with a non-type tem

[wwwdocs] New C++23 papers

2021-06-22 Thread Marek Polacek via Gcc-patches
P1847 has always been "implemented" as the paper says. P2186 needs a few libstdc++ changes that Jonathan already implemented. Pushed. commit 7b804041d34c344a190105e78c6058e2645bf7cb Author: Marek Polacek Date: Tue Jun 22 13:10:41 2021 -0400 cxx-status: Add more C++23 proposals diff --git

[wwwdocs] Document new C++ features in C++23

2021-06-22 Thread Marek Polacek via Gcc-patches
It's time to start adding new C++ features. Pushed. commit e373348138d8d767067c0a79b3ddc6a70cbee3a4 Author: Marek Polacek Date: Tue Jun 22 13:19:37 2021 -0400 gcc-12/changes.html: Add if consteval diff --git a/htdocs/gcc-12/changes.html b/htdocs/gcc-12/changes.html index 42ded16d..07f70b

Re: [wwwdocs] New C++23 papers

2021-06-22 Thread Marek Polacek via Gcc-patches
On Tue, Jun 22, 2021 at 02:38:46PM -0400, Jason Merrill wrote: > On 6/22/21 1:14 PM, Marek Polacek wrote: > > P1847 has always been "implemented" as the paper says. > > P2186 needs a few libstdc++ changes that Jonathan already implemented. > > I figured these removals didn't need to be called out

Re: [PATCH] c: Fix up c_parser_has_attribute_expression [PR101176]

2021-06-24 Thread Marek Polacek via Gcc-patches
On Thu, Jun 24, 2021 at 12:20:56PM +0200, Jakub Jelinek wrote: > Hi! > > This function keeps src_range member of the result uninitialized, which at > least under valgrind can show up later when those uninitialized location_t's > can make it into the IL or location_t hash tables. > > Fixed thusly,

Re: [PATCH] c: Fix C cast error-recovery [PR101171]

2021-06-24 Thread Marek Polacek via Gcc-patches
On Thu, Jun 24, 2021 at 12:11:23PM +0200, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs during error-recovery, as build_c_cast calls > note_integer_operands on error_mark_node and that wraps it into > C_MAYBE_CONST_EXPR which is unexpected and causes ICE later on. > Seems most other c

Re: [PATCH v2] c++: Failure to delay noexcept parsing with ptr-operator [PR100752]

2021-06-25 Thread Marek Polacek via Gcc-patches
On Thu, Jun 10, 2021 at 10:31:33PM -0400, Jason Merrill wrote: > On 6/10/21 5:19 PM, Marek Polacek wrote: > > On Thu, Jun 10, 2021 at 03:09:29PM -0400, Jason Merrill wrote: > > > On 6/8/21 8:25 PM, Marek Polacek wrote: > > > > We weren't passing 'flags' to the recursive call to cp_parser_declarator

[wwwdocs] Update C++ DR table

2021-06-25 Thread Marek Polacek via Gcc-patches
It's been a minute since I've updated our C++ DR table, so this patch adds news DRs. I've also written a script that check each DR's status against the upstream document. That revealed that many entries in our table were out of sync, so I've gone through all of them and fixed them. I've also use

[PATCH] c++: DR2397 - auto specifier for * and & to arrays [PR100975]

2021-06-29 Thread Marek Polacek via Gcc-patches
This patch implements DR2397, which removes the restriction in [dcl.array]p4 that the array element type may not be a placeholder type. We don't need to worry about decltype(auto) here, so this allows code like int a[3]; auto (*p)[3] = &a; auto (&r)[3] = a; However, note that auto (&&r)

Re: [PATCH] c++: DR2397 - auto specifier for * and & to arrays [PR100975]

2021-06-29 Thread Marek Polacek via Gcc-patches
On Tue, Jun 29, 2021 at 03:50:27PM -0400, Jason Merrill wrote: > On 6/29/21 3:25 PM, Marek Polacek wrote: > > --- a/gcc/testsuite/g++.dg/cpp0x/auto3.C > > +++ b/gcc/testsuite/g++.dg/cpp0x/auto3.C > > @@ -10,7 +10,7 @@ auto x; // { dg-error "auto" } > > auto i = 42, j = 4

Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions

2022-11-18 Thread Marek Polacek via Gcc-patches
On Fri, Nov 18, 2022 at 08:48:32AM +0100, Jakub Jelinek wrote: > On Thu, Nov 17, 2022 at 07:15:05PM -0500, Marek Polacek wrote: > > > --- gcc/cp/decl.cc.jj 2022-11-16 14:44:43.692339668 +0100 > > > +++ gcc/cp/decl.cc2022-11-17 20:53:44.102011594 +0100 > > > @@ -5600,6 +5600,57 @@ grokty

[PATCH v2] c++: Reject UDLs in certain contexts [PR105300]

2022-11-18 Thread Marek Polacek via Gcc-patches
On Thu, Nov 17, 2022 at 07:06:34PM -0500, Jason Merrill wrote: > On 11/16/22 20:12, Marek Polacek wrote: > > On Wed, Nov 16, 2022 at 08:22:39AM -0500, Jason Merrill wrote: > > > On 11/15/22 19:35, Marek Polacek wrote: > > > > On Tue, Nov 15, 2022 at 06:58:39PM -0500, Jason Merrill wrote: > > > > >

Re: [PATCH] configure: Implement --enable-host-pie

2022-11-22 Thread Marek Polacek via Gcc-patches
On Sun, Nov 20, 2022 at 08:06:55AM -0700, Jeff Law wrote: > > On 11/10/22 19:52, Marek Polacek via Gcc-patches wrote: > > This is a rebased version of the patch I posted in March: > > <https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591239.html> > > wh

Re: [PATCH v3] c++: P2448 - Relaxing some constexpr restrictions [PR106649]

2022-12-02 Thread Marek Polacek via Gcc-patches
On Fri, Nov 18, 2022 at 09:26:26PM -0500, Jason Merrill wrote: > On 11/16/22 15:27, Jason Merrill wrote: > > On 11/16/22 11:06, Marek Polacek wrote: > > > On Wed, Nov 16, 2022 at 08:41:53AM -0500, Jason Merrill wrote: > > > > On 11/15/22 19:30, Marek Polacek wrote: > > > > > @@ -996,19 +1040,26 @@

[PATCH v3] c++: Reject UDLs in certain contexts [PR105300]

2022-12-02 Thread Marek Polacek via Gcc-patches
On Fri, Nov 18, 2022 at 08:39:10PM -0500, Jason Merrill wrote: > On 11/18/22 18:52, Marek Polacek wrote: > > +/* Parse a string literal or user defined string literal. > > + > > + user-defined-string-literal : > > + string-literal ud-suffix > > + > > + Parameters as for cp_parser_string_lit

[PATCH] docs: Suggest options to improve ASAN stack traces

2022-12-07 Thread Marek Polacek via Gcc-patches
I got a complaint that while Clang docs suggest options that improve the quality of the backtraces ASAN prints (cf. ), our docs don't say anything to that effect. This patch amends that with a new paragraph. (It deliberately doesn't mention

Re: [PATCH] docs: Suggest options to improve ASAN stack traces

2022-12-08 Thread Marek Polacek via Gcc-patches
On Thu, Dec 08, 2022 at 08:25:26AM +0100, Florian Weimer wrote: > * Marek Polacek via Gcc-patches: > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > index 726392409b6..2de14466dd3 100644 > > --- a/gcc/doc/invoke.texi > > +++ b/gcc/doc/invoke.texi &g

[PATCH v2] docs: Suggest options to improve ASAN stack traces

2022-12-08 Thread Marek Polacek via Gcc-patches
On Thu, Dec 08, 2022 at 03:28:13PM +0100, Jakub Jelinek wrote: > On Thu, Dec 08, 2022 at 09:11:54AM -0500, Marek Polacek via Gcc-patches wrote: > > On Thu, Dec 08, 2022 at 08:25:26AM +0100, Florian Weimer wrote: > > > * Marek Polacek via Gcc-patches: > > > > > >

[PATCH v3] docs: Suggest options to improve ASAN stack traces

2022-12-08 Thread Marek Polacek via Gcc-patches
On Thu, Dec 08, 2022 at 04:00:15PM +0100, Jakub Jelinek wrote: > On Thu, Dec 08, 2022 at 09:34:34AM -0500, Marek Polacek wrote: > > I got a complaint that while Clang docs suggest options that improve > > the quality of the backtraces ASAN prints (cf. > >

Re: [PATCH] c++: Allow constexpr decltype(auto) [PR102229]

2021-12-15 Thread Marek Polacek via Gcc-patches
On Mon, Dec 13, 2021 at 10:02:24AM -0500, Jason Merrill wrote: > On 12/10/21 17:29, Marek Polacek wrote: > > My r11-2202 was trying to enforce [dcl.type.auto.deduct]/4, which says > > "If the placeholder-type-specifier is of the form type-constraint[opt] > > decltype(auto), T shall be the placehold

Re: [PATCH] c++: Allow constexpr decltype(auto) [PR102229]

2021-12-15 Thread Marek Polacek via Gcc-patches
On Wed, Dec 15, 2021 at 04:17:37PM -0500, Jason Merrill wrote: > On 12/15/21 15:20, Marek Polacek wrote: > > On Mon, Dec 13, 2021 at 10:02:24AM -0500, Jason Merrill wrote: > > > On 12/10/21 17:29, Marek Polacek wrote: > > > > My r11-2202 was trying to enforce [dcl.type.auto.deduct]/4, which says >

[PATCH] c++: delayed noexcept in member function template [PR99980]

2021-12-16 Thread Marek Polacek via Gcc-patches
Some time ago I noticed that we don't properly delay parsing of noexcept for member function templates. This patch fixes that. It didn't work because even though we set CP_PARSER_FLAGS_DELAY_NOEXCEPT in cp_parser_member_declaration, member template declarations take a different path: we call cp_p

[PATCH] attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]

2021-12-16 Thread Marek Polacek via Gcc-patches
My patch to implement -Wno-attribute=A::b caused a bogus error when parsing [[foo::bar(1, 2)]]; when -Wno-attributes=foo::bar was specified on the command line, because when we create a fake foo::bar attribute and insert it into our attribute table, it is created with max_length == 0 which does

[PATCH] c++: Improve diagnostic for class tmpl/class redecl [PR103749]

2021-12-16 Thread Marek Polacek via Gcc-patches
For code like template struct bar; struct bar { int baz; }; bar var; we emit a fairly misleading and unwieldy diagnostic: ~ $ g++ -c u.cc u.cc:6:8: error: template argument required for 'struct bar' 6 | struct bar { |

[PATCH v2] attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]

2021-12-16 Thread Marek Polacek via Gcc-patches
On Thu, Dec 16, 2021 at 11:53:46PM +0100, Jakub Jelinek wrote: > On Thu, Dec 16, 2021 at 05:35:55PM -0500, Marek Polacek wrote: > > My patch to implement -Wno-attribute=A::b caused a bogus error when > > parsing > > > > [[foo::bar(1, 2)]]; > > > > when -Wno-attributes=foo::bar was specified on

[PATCH v2] c++: Improve diagnostic for class tmpl/class redecl [PR103749]

2021-12-17 Thread Marek Polacek via Gcc-patches
On Thu, Dec 16, 2021 at 08:13:01PM -0500, Jason Merrill wrote: > On 12/16/21 17:36, Marek Polacek wrote: > > + if (DECL_CLASS_TEMPLATE_P (decl) > > + && !template_header_p > > + && how == TAG_how::CURRENT_ONLY) > > +{ > > + error ("%qD was declared as template but no template he

[PATCH v3] attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]

2021-12-17 Thread Marek Polacek via Gcc-patches
On Thu, Dec 16, 2021 at 08:06:43PM -0500, Jason Merrill wrote: > On 12/16/21 19:52, Marek Polacek wrote: > > --- /dev/null > > +++ b/gcc/testsuite/c-c++-common/Wno-attributes-6.c > > @@ -0,0 +1,14 @@ > > +/* PR c/103649 */ > > +/* { dg-do compile { target { c || c++11 } } } */ > > +/* { dg-addition

[PATCH v4] attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]

2021-12-17 Thread Marek Polacek via Gcc-patches
On Fri, Dec 17, 2021 at 02:33:01PM -0500, Jason Merrill wrote: > On 12/17/21 13:14, Marek Polacek wrote: > > @@ -28979,7 +28979,9 @@ cp_parser_std_attribute (cp_parser *parser, tree > > attr_ns) > > /* A GNU attribute that takes an identifier in parameter. */ > > attr_flag = id_at

[PATCH] c++: Avoid narrowing in make_char_string_pack

2021-12-17 Thread Marek Polacek via Gcc-patches
This fixes gcc/cp/parser.c:4618:41: warning: narrowing conversion of '(char)(*(str + ((sizetype)i)))' from 'char' to 'unsigned char' [-Wnarrowing] 4618 | unsigned char s[3] = { '\'', str[i], '\'' }; |~^ Bootstrapped/regtested on x86_64-pc-linu

[PATCH] c-family: Have -Wformat-diag accept "decl-specifier" [PR103758]

2021-12-17 Thread Marek Polacek via Gcc-patches
I'm tired of seeing cp/parser.c:15923:55: warning: misspelled term 'decl' in format; use 'declaration' instead [-Wformat-diag] cp/parser.c:15925:57: warning: misspelled term 'decl' in format; use 'declaration' instead [-Wformat-diag] every time I compile cp/parser.c, which happens...a lot. I'd

Re: [PATCH] c++: Avoid narrowing in make_char_string_pack

2022-01-03 Thread Marek Polacek via Gcc-patches
On Sat, Dec 18, 2021 at 07:43:55PM -0500, Eric Gallager wrote: > On Fri, Dec 17, 2021 at 5:59 PM Marek Polacek via Gcc-patches > wrote: > > > > This fixes > > > > gcc/cp/parser.c:4618:41: warning: narrowing conversion of '(char)(*(str + > > ((siz

[PATCH v2] c-family: Have -Wformat-diag accept "decl-specifier" [PR103758]

2022-01-03 Thread Marek Polacek via Gcc-patches
On Mon, Dec 20, 2021 at 09:53:25PM +0100, Jakub Jelinek wrote: > On Mon, Dec 20, 2021 at 03:21:04PM -0500, Jason Merrill via Gcc-patches wrote: > > > @@ -3215,6 +3215,14 @@ check_tokens (const token_t *tokens, unsigned > > > ntoks, > > > plural = "s"; > > > }

[PATCH] Avoid more -Wformat-diag warnings [PR103758]

2022-01-05 Thread Marek Polacek via Gcc-patches
Let's use "%, %, or %" rather than "[x|y|z]" as in the rest of our codebase. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/11? PR c++/103758 gcc/c-family/ChangeLog: * c-pragma.c (handle_pragma_scalar_storage_order): Use %< %> in diagnostic messages.

[wwwdocs] Update C++ DR table

2022-01-06 Thread Marek Polacek via Gcc-patches
A new batch of DRs. Pushed. commit ecbd709b2ecb1e3c35fa4ede09bcb7ceb443def6 Author: Marek Polacek Date: Thu Jan 6 17:06:24 2022 -0500 Update C++ DR table diff --git a/htdocs/projects/cxx-dr-status.html b/htdocs/projects/cxx-dr-status.html index e8002b27..cc2afc03 100644 --- a/htdocs/pro

Re: [PATCH] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026]

2022-01-14 Thread Marek Polacek via Gcc-patches
On Fri, Jan 14, 2022 at 10:23:16AM +0100, Stephan Bergmann wrote: > On 30/11/2021 16:27, Marek Polacek wrote: > > I guess we were concerned with programs that generate other programs. > > Maybe UCNs should be ignored by default. There's still time to adjust > > the behavior. > > Is there any upda

[PATCH] c++: ICE with noexcept and canonical types [PR101715]

2022-01-14 Thread Marek Polacek via Gcc-patches
This is a "canonical types differ for identical types" ICE, which started with r11-4682. It's a bit tricky to explain. Consider: template struct S { S bar() noexcept(T::value); // #1 S foo() noexcept(T::value); // #2 }; template S S::foo() noexcept(T::value) {} // #3 We ICE

Re: PING^5 [PATCH v4 0/2] Implement indirect external access

2022-01-17 Thread Marek Polacek via Gcc-patches
Ping, could a global maintainer take a look at this? On Mon, Jan 03, 2022 at 07:32:25PM -0800, H.J. Lu via Gcc-patches wrote: > On Sat, Dec 11, 2021 at 10:44 AM H.J. Lu wrote: > > > > On Thu, Nov 25, 2021 at 9:54 AM H.J. Lu wrote: > > > > > > On Mon, Nov 1, 2021 at 7:02 AM H.J. Lu wrote: > > >

Re: [PATCH] c, ubsan: Instrument even shortened divisions [PR109151]

2023-03-17 Thread Marek Polacek via Gcc-patches
On Fri, Mar 17, 2023 at 09:14:04AM +0100, Jakub Jelinek wrote: > Hi! > > On the following testcase, the C FE decides to shorten the division because > it has a guarantee that INT_MIN / -1 division won't be encountered, the > first operand is widened from narrower unsigned and/or the second operand

[PATCH] c++: further -Wdangling-reference refinement [PR107532]

2023-03-17 Thread Marek Polacek via Gcc-patches
Based on , it seems like we should treat *any* class with a reference member as a reference wrapper. This simplifies the code so I'm happy to make that change. The patch, however, does not suppress the warning in int i = 42; auto const

[PATCH] c++: explicit ctor and list-initialization [PR109159]

2023-03-20 Thread Marek Polacek via Gcc-patches
When I implemented explicit(bool) in r9-3735, I added this code to add_template_candidate_real: + /* Now the explicit specifier might have been deduced; check if this + declaration is explicit. If it is and we're ignoring non-converting + constructors, don't add this function to the set o

[PATCH v2] c++: further -Wdangling-reference refinement [PR107532]

2023-03-20 Thread Marek Polacek via Gcc-patches
On Sat, Mar 18, 2023 at 08:35:36AM -0400, Jason Merrill wrote: > On 3/17/23 16:29, Marek Polacek wrote: > > Based on , > > it seems like we should treat *any* class with a reference member > > as a reference wrapper. This simplifies the code

Re: [PATCH] sanitizer: missing signed integer overflow errors [PR109107]

2023-03-27 Thread Marek Polacek via Gcc-patches
Ping. On Tue, Mar 14, 2023 at 06:50:26PM -0400, Marek Polacek via Gcc-patches wrote: > Here we're failing to detect a signed overflow with -O because match.pd, > since r8-1516, transforms > > c = (a + 1) - (int) (short int) b; > > into > > c = (int) (

<    6   7   8   9   10   11