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

2022-03-28 Thread Marek Polacek via Gcc-patches
Hi, On Sun, Mar 27, 2022 at 06:25:16PM -0300, Alexandre Oliva via Gcc-patches wrote: > Hello, Marek, > > The patch looks good to me, and I'd have no trouble approving it if we > were in stage1. Since we aren't, I'd prefer if we waited for another > build system maintainer to give it a look, if

[PATCH] c++: ICE with aggregate assignment and DMI [PR104583]

2022-03-25 Thread Marek Polacek via Gcc-patches
The attached 93280 test no longer ICEs but looks like it was never added to the testsuite. The 104583 test, modified so that it closely resembles 93280, still ICEs. The problem is that in 104583 we have a value-init from {} (the line A a{};), so this code in convert_like_internal 7960

Re: [PATCH] c++: diagnosing if-stmt with non-constant branches [PR105050]

2022-03-25 Thread Marek Polacek via Gcc-patches
On Fri, Mar 25, 2022 at 12:07:31PM -0400, Patrick Palka via Gcc-patches wrote: > When an if-stmt is deemed non-constant because both of its branches are > non-constant, we issue a rather generic error which, given that it points > to the 'if' token, misleadingly suggests the condition is at fault:

Re: [PATCH v3] c++: alignas and alignof void [PR104944]

2022-03-25 Thread Marek Polacek via Gcc-patches
On Fri, Mar 25, 2022 at 09:36:10AM -0400, Jason Merrill wrote: > On 3/24/22 18:43, Marek Polacek wrote: > > On Thu, Mar 24, 2022 at 05:12:12PM -0400, Jason Merrill wrote: > > > On 3/24/22 15:56, Marek Polacek wrote: > > > > On Thu, Mar 24, 2022 at 12:02:29PM -0400, Jason Merrill wrote: > > > > >

[PATCH v3] c++: alignas and alignof void [PR104944]

2022-03-24 Thread Marek Polacek via Gcc-patches
On Thu, Mar 24, 2022 at 05:12:12PM -0400, Jason Merrill wrote: > On 3/24/22 15:56, Marek Polacek wrote: > > On Thu, Mar 24, 2022 at 12:02:29PM -0400, Jason Merrill wrote: > > > On 3/24/22 11:49, Marek Polacek wrote: > > > > I started looking into this PR because in GCC 4.9 we were able to > > > >

[PATCH v3] c++: ICE with template code in constexpr [PR104284]

2022-03-24 Thread Marek Polacek via Gcc-patches
On Thu, Mar 24, 2022 at 11:40:11AM -0400, Jason Merrill wrote: > On 3/18/22 17:55, Marek Polacek wrote: > > On Fri, Mar 11, 2022 at 06:46:42PM -0500, Jason Merrill wrote: > > > On 3/10/22 18:04, Marek Polacek wrote: > > > > Since r9-6073 cxx_eval_store_expression preevaluates the value to > > > >

[PATCH v2] c++: alignas and alignof void [PR104944]

2022-03-24 Thread Marek Polacek via Gcc-patches
On Thu, Mar 24, 2022 at 12:02:29PM -0400, Jason Merrill wrote: > On 3/24/22 11:49, Marek Polacek wrote: > > I started looking into this PR because in GCC 4.9 we were able to > > detect the invalid > > > >struct alignas(void) S{}; > > > > but I broke it in r210262. > > > > It's ill-formed

[PATCH v2] c++: FIX_TRUNC_EXPR in tsubst [PR102990]

2022-03-24 Thread Marek Polacek via Gcc-patches
On Thu, Mar 24, 2022 at 09:32:19AM -0400, Jason Merrill wrote: > On 3/23/22 19:26, Marek Polacek wrote: > > On Wed, Mar 23, 2022 at 04:35:32PM -0400, Jason Merrill wrote: > > > On 3/22/22 19:55, Marek Polacek wrote: > > > > This is a crash where a FIX_TRUNC_EXPR gets into tsubst_copy_and_build > >

[PATCH] c, c++: alignas and alignof void [PR104944]

2022-03-24 Thread Marek Polacek via Gcc-patches
I started looking into this PR because in GCC 4.9 we were able to detect the invalid struct alignas(void) S{}; but I broke it in r210262. It's ill-formed code in C++: [dcl.align]/3: "An alignment-specifier of the form alignas(type-id) has the same effect as alignas(alignof(type-id))", and

Re: [PATCH] c++: FIX_TRUNC_EXPR in tsubst [PR102990]

2022-03-23 Thread Marek Polacek via Gcc-patches
On Wed, Mar 23, 2022 at 04:35:32PM -0400, Jason Merrill wrote: > On 3/22/22 19:55, Marek Polacek wrote: > > This is a crash where a FIX_TRUNC_EXPR gets into tsubst_copy_and_build > > where it hits gcc_unreachable (). > > > > The history of tsubst_copy_and_build/FIX_TRUNC_EXPR is such that it > >

[PATCH] c++: FIX_TRUNC_EXPR in tsubst [PR102990]

2022-03-22 Thread Marek Polacek via Gcc-patches
This is a crash where a FIX_TRUNC_EXPR gets into tsubst_copy_and_build where it hits gcc_unreachable (). The history of tsubst_copy_and_build/FIX_TRUNC_EXPR is such that it was introduced in r181478, but it did the wrong thing, whereupon it was turned into gcc_unreachable () in r258821 (see this

Re: [PATCH] c++: Fall through for arrays of T vs T cv [PR104996]

2022-03-22 Thread Marek Polacek via Gcc-patches
On Tue, Mar 22, 2022 at 08:39:21PM +, Ed Catmur wrote: > If two arrays do not have the exact same element type including > qualification, this could be e.g. f(int (&&)[]) vs. f(int const (&)[]), which > can still be distinguished by the lvalue-rvalue tiebreaker. > > By tightening this

[PATCH] c: -Wmissing-field-initializers and designated inits [PR82283, PR84685]

2022-03-22 Thread Marek Polacek via Gcc-patches
This patch fixes two kinds of wrong -Wmissing-field-initializers warnings. Our docs say that this warning "does not warn about designated initializers", but we give a warning for 1) the array case: struct S { struct N { int a; int b; } c[1]; } d = { .c[0].a = 1,

[PATCH v2] c++: ICE with template code in constexpr [PR104284]

2022-03-18 Thread Marek Polacek via Gcc-patches
On Fri, Mar 11, 2022 at 06:46:42PM -0500, Jason Merrill wrote: > On 3/10/22 18:04, Marek Polacek wrote: > > Since r9-6073 cxx_eval_store_expression preevaluates the value to > > be stored, and that revealed a crash where a template code (here, > > code=IMPLICIT_CONV_EXPR) leaks into cxx_eval*. > >

Re: [PATCH v2] middle-end/104854: Limit strncmp overread warnings

2022-03-17 Thread Marek Polacek via Gcc-patches
On Wed, Mar 16, 2022 at 06:54:51AM +0530, Siddhesh Poyarekar wrote: > On 16/03/2022 02:06, Martin Sebor wrote: > > The intended use of the strncmp bound is to limit the comparison to > > at most the size of the arrays or (in a subset of cases) the length > > of an initial substring. Providing an

[PATCH] c++: alias template and empty parameter packs [PR104008]

2022-03-16 Thread Marek Polacek via Gcc-patches
Zero-length pack expansions are treated as if no list were provided at all, that is, with template struct S { }; template void g() { S...>; } g will result in S<>. In the following test we have something similar: template using IsOneOf = disjunction...>; and then we have

[wwwdocs] cxx-dr-status: Update from C++ Core Language Issue TOC, Revision 108

2022-03-15 Thread Marek Polacek via Gcc-patches
It was high time I updated our C++ DR table. Pushed. --- htdocs/projects/cxx-dr-status.html | 153 +++-- 1 file changed, 122 insertions(+), 31 deletions(-) diff --git a/htdocs/projects/cxx-dr-status.html b/htdocs/projects/cxx-dr-status.html index b49a97f2..63ec6d51

Re: [PATCH] gcc: add --enable-systemtap switch [PR61257]

2022-03-14 Thread Marek Polacek via Gcc-patches
On Mon, Mar 14, 2022 at 01:48:21PM +0100, David Seifert via Gcc-patches wrote: > Bug: https://bugs.gentoo.org/654748 > > gcc/configure.ac > * Add --enable-systemtap switch to explicitly allow for > disabling systemtap even if the target libc supports it. > --- > gcc/configure.ac

Re: [PATCH] c++: ICE with template code in constexpr [PR104284]

2022-03-10 Thread Marek Polacek via Gcc-patches
On Thu, Mar 10, 2022 at 05:04:59PM -0500, Marek Polacek via Gcc-patches wrote: > Since r9-6073 cxx_eval_store_expression preevaluates the value to > be stored, and that revealed a crash where a template code (here, > code=IMPLICIT_CONV_EXPR) leaks into cxx_eval*. > > It happen

[PATCH] c++: ICE with template code in constexpr [PR104284]

2022-03-10 Thread Marek Polacek via Gcc-patches
Since r9-6073 cxx_eval_store_expression preevaluates the value to be stored, and that revealed a crash where a template code (here, code=IMPLICIT_CONV_EXPR) leaks into cxx_eval*. It happens because we're performing build_vec_init while processing a template, which calls get_temp_regvar which

[PATCH] c++: ICE with operator delete [PR104846]

2022-03-09 Thread Marek Polacek via Gcc-patches
This is an ICE-on-invalid with "auto operator delete[] (void *)" whose return type must be void. The return type is checked in coerce_delete_type but we never got there in this test, because we took the wrong path in grokdeclarator, set type to error_mark_node, ended up creating a FIELD_DECL with

[PATCH v2] c++: Don't allow type-constraint auto(x) [PR104752]

2022-03-09 Thread Marek Polacek via Gcc-patches
On Tue, Mar 08, 2022 at 02:47:42PM -0500, Jason Merrill wrote: > On 3/2/22 14:31, Marek Polacek wrote: > > 104752 points out that > > > >template > >concept C = true; > >auto y = C auto(1); > > > > is ill-formed as per [dcl.type.auto.deduct]: "For an explicit type > > conversion, >

[PATCH] c++: Wrong error with alias template in class tmpl [PR104108]

2022-03-08 Thread Marek Polacek via Gcc-patches
In r10-6329 I tried to optimize the number of calls to v_d_e_p in convert_nontype_argument by remembering whether the expression was value-dependent in a bool flag. I did that wrongly assuming that its value-dependence will not be changed by build_converted_constant_expr. This testcase shows that

[PATCH v2] rtl: ICE with thread_local and inline asm [PR104777]

2022-03-08 Thread Marek Polacek via Gcc-patches
On Tue, Mar 08, 2022 at 10:24:50AM -0600, Segher Boessenkool wrote: > On Tue, Mar 08, 2022 at 05:12:43PM +0100, Jakub Jelinek wrote: > > On Tue, Mar 08, 2022 at 09:49:15AM -0600, Segher Boessenkool wrote: > > > > But like I said above, even if we didn't copy these XVECLEN 0 rtvecs, > > > > the

Re: [PATCH] rtl: ICE with thread_local and inline asm [PR104777]

2022-03-08 Thread Marek Polacek via Gcc-patches
On Tue, Mar 08, 2022 at 05:12:43PM +0100, Jakub Jelinek wrote: > On Tue, Mar 08, 2022 at 09:49:15AM -0600, Segher Boessenkool wrote: > > > But like I said above, even if we didn't copy these XVECLEN 0 rtvecs, > > > the crash would not go away. > > > > An rtvec should never have length 0. Look at

Re: [PATCH] rtl: ICE with thread_local and inline asm [PR104777]

2022-03-08 Thread Marek Polacek via Gcc-patches
On Tue, Mar 08, 2022 at 09:49:15AM -0600, Segher Boessenkool wrote: > On Tue, Mar 08, 2022 at 10:25:45AM -0500, Marek Polacek wrote: > > On Tue, Mar 08, 2022 at 09:14:56AM -0600, Segher Boessenkool wrote: > > > On Tue, Mar 08, 2022 at 10:08:25AM -0500, Marek Polacek wrote: > > > > ...I don't see

Re: [PATCH] rtl: ICE with thread_local and inline asm [PR104777]

2022-03-08 Thread Marek Polacek via Gcc-patches
On Tue, Mar 08, 2022 at 09:14:56AM -0600, Segher Boessenkool wrote: > Hi! > > On Tue, Mar 08, 2022 at 10:08:25AM -0500, Marek Polacek wrote: > > On Mon, Mar 07, 2022 at 07:19:09PM -0600, Segher Boessenkool wrote: > > > On Mon, Mar 07, 2022 at 07:03:17PM -0500, Marek

Re: [PATCH] rtl: ICE with thread_local and inline asm [PR104777]

2022-03-08 Thread Marek Polacek via Gcc-patches
On Mon, Mar 07, 2022 at 07:19:09PM -0600, Segher Boessenkool wrote: > On Mon, Mar 07, 2022 at 07:03:17PM -0500, Marek Polacek via Gcc-patches wrote: > > In r270550, Jakub fixed classify_insn to handle asm goto: if the asm can > > jump to a label, the insn should be a JUMP_INSN. &

[PATCH] rtl: ICE with thread_local and inline asm [PR104777]

2022-03-07 Thread Marek Polacek via Gcc-patches
In r270550, Jakub fixed classify_insn to handle asm goto: if the asm can jump to a label, the insn should be a JUMP_INSN. However, as the following testcase shows, non-null ASM_OPERANDS_LABEL_VEC doesn't guarantee that the rtx has any actual labels it can branch to. Here, the rtvec has 0 elements

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

2022-03-04 Thread Marek Polacek via Gcc-patches
On Fri, Feb 25, 2022 at 12:04:32AM +, Joseph Myers wrote: > On Thu, 24 Feb 2022, Marek Polacek via Gcc-patches wrote: > > > gmp/mpfr/mpc/isl are DSOs I believe and therefore always PIC. > > They are *not* DSOs when built in-tree (see the use of --disable-shared in &g

[PATCH] c++: Don't allow type-constraint auto(x) [PR104752]

2022-03-02 Thread Marek Polacek via Gcc-patches
104752 points out that template concept C = true; auto y = C auto(1); is ill-formed as per [dcl.type.auto.deduct]: "For an explicit type conversion, T is the specified type, which shall be auto." which doesn't allow type-constraint auto. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok

[PATCH] c++: Attribute deprecated/unavailable divergence

2022-03-02 Thread Marek Polacek via Gcc-patches
Attributes deprecated and unavailable are largely the same, except that the former produces a warning whereas the latter produces an error. So is_late_template_attribute should treat them the same. Confirmed by Iain that this divergence is not intentional:

[PATCH v2] c++: ->template and implicit typedef [PR104608]

2022-03-01 Thread Marek Polacek via Gcc-patches
On Mon, Feb 28, 2022 at 12:31:37PM -0400, Jason Merrill wrote: > On 2/22/22 17:46, Marek Polacek wrote: > > Here we have a forward declaration of Parameter for which we create > > an implicit typedef, which is a TYPE_DECL. Then, when looking it up > > at template definition time,

Re: [PATCH] c++: Lost deprecated/unavailable attr in class tmpl [PR104682]

2022-02-28 Thread Marek Polacek via Gcc-patches
On Mon, Feb 28, 2022 at 04:30:01PM +, Iain Sandoe wrote: > > > > On 28 Feb 2022, at 16:13, Jason Merrill wrote: > > > > On 2/25/22 17:59, Marek Polacek wrote: > >> [ Most likely a GCC 13 patch, but I'm posting it now so that I don't lose > >> it. ] > >> When looking into the other PR I

Re: [PATCH] c++: ICE with attribute on enumerator [PR104667]

2022-02-28 Thread Marek Polacek via Gcc-patches
On Mon, Feb 28, 2022 at 12:16:47PM -0400, Jason Merrill wrote: > On 2/25/22 17:59, Marek Polacek wrote: > > When processing a template, the enumerators we build don't have a type > > yet. But is_late_template_attribute is not prepared to see a _DECL > > without a type, so we crash on > > > >

Re: [PATCH] c++: Lost deprecated/unavailable attr in class tmpl [PR104682]

2022-02-28 Thread Marek Polacek via Gcc-patches
On Mon, Feb 28, 2022 at 12:13:36PM -0400, Jason Merrill wrote: > On 2/25/22 17:59, Marek Polacek wrote: > > [ Most likely a GCC 13 patch, but I'm posting it now so that I don't lose > > it. ] > > > > When looking into the other PR I noticed that we fail to give a warning > > for a deprecated

[PATCH] c++: Lost deprecated/unavailable attr in class tmpl [PR104682]

2022-02-25 Thread Marek Polacek via Gcc-patches
[ Most likely a GCC 13 patch, but I'm posting it now so that I don't lose it. ] When looking into the other PR I noticed that we fail to give a warning for a deprecated enumerator when the enum is in a class template. This only happens when the attribute doesn't have an argument. The reason is

[PATCH] c++: ICE with attribute on enumerator [PR104667]

2022-02-25 Thread Marek Polacek via Gcc-patches
When processing a template, the enumerators we build don't have a type yet. But is_late_template_attribute is not prepared to see a _DECL without a type, so we crash on enum tree_code code = TREE_CODE (type); (I found that we don't give the "is deprecated" warning for the enumerator 'f' in

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

2022-02-24 Thread Marek Polacek via Gcc-patches
On Thu, Feb 10, 2022 at 09:10:17PM +, Joseph Myers wrote: > Some general observations: Thanks for the comment and sorry for the delay (I was on vacation). > * There are various toplevel GCC subdirectories that are built for the > host (possibly in addition to the target in some cases) but

[pushed] c++: Add new test [PR79493]

2022-02-23 Thread Marek Polacek via Gcc-patches
A nice side effect of r12-1822 was improving the diagnostic we emit for the following test. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/79493 gcc/testsuite/ChangeLog: * g++.dg/diagnostic/undeclared1.C: New test. --- gcc/testsuite/g++.dg/diagnostic/undeclared1.C | 7

[pushed] c++: Add fixed test [PR70077]

2022-02-23 Thread Marek Polacek via Gcc-patches
Fixed with r10-1280. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/70077 gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept76.C: New test. --- gcc/testsuite/g++.dg/cpp0x/noexcept76.C | 17 + 1 file changed, 17 insertions(+) create mode 100644

[PATCH] c++: ->template and implicit typedef [PR104608]

2022-02-22 Thread Marek Polacek via Gcc-patches
Here we have a forward declaration of Parameter for which we create an implicit typedef, which is a TYPE_DECL. Then, when looking it up at template definition time, cp_parser_template_id gets (since r12-6754) this TYPE_DECL which it can't handle. This patch defers lookup for implicit typedefs, a

[PATCH] configure: Implement --enable-host-bind-now

2022-02-10 Thread Marek Polacek via Gcc-patches
As promised in the --enable-host-pie patch, this patch adds another configure option, --enable-host-bind-now, which adds -z now when linking the compiler executables in order to extend hardening. BIND_NOW with RELRO allows the GOT to be marked RO; this prevents GOT modification attacks. This

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

2022-02-10 Thread Marek Polacek via Gcc-patches
This patch implements the --enable-host-pie configure option which makes the compiler executables PIE. This can be used to enhance protection against ROP attacks, and can be viewed as part of a wider trend to harden binaries. It is similar to the option --enable-host-shared, except that --e-h-s

Re: [PATCH] Speed up fixincludes.

2022-02-04 Thread Marek Polacek via Gcc-patches
On Fri, Feb 04, 2022 at 10:26:07AM +0100, Martin Liška wrote: > On 2/3/22 22:51, Jakub Jelinek wrote: > > On Thu, Feb 03, 2022 at 04:29:39PM -0500, Marek Polacek wrote: > > > On Thu, Feb 03, 2022 at 10:13:36PM +0100, Martin Liška wrote: > > > > On 2/3/22 19:44, Andreas Schwab wrote: > > > > > On

Re: [PATCH] Speed up fixincludes.

2022-02-03 Thread Marek Polacek via Gcc-patches
On Thu, Feb 03, 2022 at 10:13:36PM +0100, Martin Liška wrote: > On 2/3/22 19:44, Andreas Schwab wrote: > > On Feb 03 2022, Martin Liška wrote: > > > > > +cd $LIB > > > +echo "$all_dirs" | xargs mkdir -p > > > +cd .. > > > + > > > > $LIB always contains slashes. > > > > And what is the problem?

[PATCH] c++: Reject union std::initializer_list [PR102434]

2022-01-28 Thread Marek Polacek via Gcc-patches
Weird things are going to happen if you define your std::initializer_list as a union. In this case, we crash in output_constructor_regular_field. Let's not allow such a definition in the first place. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c++/102434

Re: [PATCH v2] preprocessor: -Wbidi-chars and UCNs [PR104030]

2022-01-28 Thread Marek Polacek via Gcc-patches
in Liška wrote: > > > > > On 1/24/22 23:36, Marek Polacek via Gcc-patches wrote: > > > > > > |@@ -7820,6 +7820,10 @@ bidi contexts. @option{-Wbidi-chars=none} > > > > > > turns the warning off. @option{-Wbidi-chars=any} warns about an

[PATCH v2] c++: ICE with auto[] and VLA [PR102414]

2022-01-28 Thread Marek Polacek via Gcc-patches
On Thu, Jan 27, 2022 at 10:17:00PM -0500, Jason Merrill wrote: > On 1/27/22 20:02, Marek Polacek wrote: > > @@ -11159,8 +11159,16 @@ create_array_type_for_decl (tree name, tree type, > > tree size, location_t loc) > > /* Figure out the index type for the array. */ > > if (size) > > -

Re: [PATCH v2] preprocessor: -Wbidi-chars and UCNs [PR104030]

2022-01-28 Thread Marek Polacek via Gcc-patches
On Fri, Jan 28, 2022 at 04:08:18PM +0100, Martin Liška wrote: > On 1/28/22 15:59, Marek Polacek wrote: > > On Fri, Jan 28, 2022 at 02:53:16PM +0100, Martin Liška wrote: > > > On 1/24/22 23:36, Marek Polacek via Gcc-patches wrote: > > > > |@@ -7820,6 +7820,10 @@ bidi

Re: [PATCH v2] preprocessor: -Wbidi-chars and UCNs [PR104030]

2022-01-28 Thread Marek Polacek via Gcc-patches
On Fri, Jan 28, 2022 at 02:53:16PM +0100, Martin Liška wrote: > On 1/24/22 23:36, Marek Polacek via Gcc-patches wrote: > > |@@ -7820,6 +7820,10 @@ bidi contexts. @option{-Wbidi-chars=none} turns the > > warning off. @option{-Wbidi-chars=any} warns about any use of bidirection

[PATCH] c++: ICE with auto[] and VLA [PR102414]

2022-01-27 Thread Marek Polacek via Gcc-patches
Here we ICE in unify_array_domain when we're trying to deduce the type of an array, as in auto(*p)[i] = (int(*)[i])0; but unify_array_domain doesn't arbitrarily complex bounds. Another test is, e.g., auto (*b)[0/0] = where the type of the array is <<< Unknown tree: template_type_parm

[PATCH] c++: new-expr of array of deduced class tmpl [PR101988]

2022-01-26 Thread Marek Polacek via Gcc-patches
In r12-1933 I attempted to implement DR2397 aka allowing int a[3]; auto ()[3] = a; by removing the type_uses_auto check in create_array_type_for_decl. That may have gone too far, because it also allows arrays of CLASS_PLACEHOLDER_TEMPLATE and it looks like [dcl.type.class.deduct] prohibits

[PATCH v2] warn-access: Prevent -Wuse-after-free on ARM [PR104213]

2022-01-26 Thread Marek Polacek via Gcc-patches
On Wed, Jan 26, 2022 at 09:39:46AM -0700, Martin Sebor wrote: > On 1/26/22 08:24, Jason Merrill via Gcc-patches wrote: > > On 1/25/22 18:33, Marek Polacek wrote: > > > Here, -Wuse-after-free warns about using 'this' which, on ARM, cdtors > > > return, as mandated by the EABI.  To be entirely

Re: [PATCH] warn-access: Prevent -Wuse-after-free on ARM [PR104213]

2022-01-25 Thread Marek Polacek via Gcc-patches
On Tue, Jan 25, 2022 at 05:35:20PM -0700, Martin Sebor wrote: > On 1/25/22 16:33, Marek Polacek via Gcc-patches wrote: > > Here, -Wuse-after-free warns about using 'this' which, on ARM, cdtors > > return, as mandated by the EABI. To be entirely correct, it only > > requires i

[PATCH] warn-access: Prevent -Wuse-after-free on ARM [PR104213]

2022-01-25 Thread Marek Polacek via Gcc-patches
Here, -Wuse-after-free warns about using 'this' which, on ARM, cdtors return, as mandated by the EABI. To be entirely correct, it only requires it for C1 and C2 ctors and D2 and D1 dtors, but I don't feel like changing that now and possibly running into issues later on. This patch uses

[PATCH v2] preprocessor: -Wbidi-chars and UCNs [PR104030]

2022-01-24 Thread Marek Polacek via Gcc-patches
Here's an updated version of the patch which uses EnumSet (great to have it, thanks Jakub!) rather than hardcoding strings. With this patch we accept -Wbidi-chars=none,ucn as well as -Wbidi-chars=ucn. I think that's OK. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 --

Re: [PATCH] c++: Fix non-portable default argument of make_auto_1 [PR104197]

2022-01-24 Thread Marek Polacek via Gcc-patches
On Mon, Jan 24, 2022 at 10:27:40AM -0500, Patrick Palka via Gcc-patches wrote: > Avoid using the macro current_template_depth, which expands to an > expression in terms of __FUNCTION__, within the signature of a function. > Clang warns about this and MSVC rejects it. > > Bootstrapped and

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

2022-01-21 Thread Marek Polacek via Gcc-patches
On Fri, Jan 21, 2022 at 09:27:17AM -0500, Jason Merrill wrote: > On 1/20/22 20:03, Marek Polacek wrote: > > @@ -2815,12 +2816,23 @@ fixup_deferred_exception_variants (tree type, tree > > raises) > > cp_cv_quals var_quals = TYPE_QUALS (variant); > > cp_ref_qualifier rqual =

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

2022-01-20 Thread Marek Polacek via Gcc-patches
On Thu, Jan 20, 2022 at 03:23:24PM -0500, Jason Merrill wrote: > On 1/18/22 11:05, Marek Polacek wrote: > > On Mon, Jan 17, 2022 at 01:48:48PM -0500, Jason Merrill wrote: > > > On 1/14/22 19:22, Marek Polacek wrote: > > > > This is a "canonical types differ for identical types" ICE, which > > > >

[pushed] c++: Add test for fixed PR [PR102338]

2022-01-20 Thread Marek Polacek via Gcc-patches
This was fixed by r12-6025 and is sufficiently different from noexcept71.C that I think we should add it. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102338 gcc/testsuite/ChangeLog: * g++.dg/cpp1y/noexcept2.C: New test. --- gcc/testsuite/g++.dg/cpp1y/noexcept2.C | 20

[PATCH] preprocessor: -Wbidi-chars and UCNs [PR104030]

2022-01-20 Thread Marek Polacek via Gcc-patches
Stephan Bergmann reported that our -Wbidi-chars breaks the build of LibreOffice because we warn about UCNs even when their usage is correct: LibreOffice constructs strings piecewise, as in: aText = u"\u202D" + aText; and warning about that is overzealous. Since no editor (AFAIK) interprets

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

2022-01-18 Thread Marek Polacek via Gcc-patches
On Sat, Jan 15, 2022 at 09:24:05AM -0500, Patrick Palka wrote: > On Fri, 14 Jan 2022, Marek Polacek via Gcc-patches wrote: > > > This is a "canonical types differ for identical types" ICE, which started > > with r11-4682. It's a bit tricky to explain. Consider: &

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

2022-01-18 Thread Marek Polacek via Gcc-patches
On Mon, Jan 17, 2022 at 01:48:48PM -0500, Jason Merrill wrote: > On 1/14/22 19:22, Marek Polacek wrote: > > 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()

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: > > >

[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: [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

[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 ---

[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.

[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"; > > > }

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 + > > ((sizetype

[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.

[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

[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 =

[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 } } } */ > > +/* {

[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

[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] 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

[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

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 >

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

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

2021-12-10 Thread Marek Polacek via Gcc-patches
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 placeholder alone." But this made us reject 'constexpr decltype(auto)', which, after clarification from CWG, should be

[pushed] c++: Add test for C++23 auto(x)

2021-12-10 Thread Marek Polacek via Gcc-patches
I was curious if our auto(x) works in contexts like bit-field width and similar. It appears that it does. Might be worth adding a test for it. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/testsuite/ChangeLog: * g++.dg/cpp23/auto-fncast10.C: New test. ---

Re: [PATCH] c++: remove COMPOUND_EXPR_OVERLOADED flag

2021-12-10 Thread Marek Polacek via Gcc-patches
On Fri, Dec 10, 2021 at 10:48:00AM -0500, Patrick Palka via Gcc-patches wrote: > This flag is never set because non-dependent COMPOUND_EXPRs are fully > resolved into a CALL_EXPR at template definition time (in > build_x_compound_expr) ever since r6-5772. > > Bootstrapped and regtested on

[PATCH v4] c++: Handle auto(x) in parameter-declaration-clause [PR103401]

2021-12-08 Thread Marek Polacek via Gcc-patches
On Wed, Dec 08, 2021 at 03:09:00PM -0500, Jason Merrill wrote: > On 12/8/21 13:32, Marek Polacek wrote: > > On Wed, Dec 08, 2021 at 09:15:05AM -0500, Jason Merrill wrote: > > > On 12/7/21 19:25, Marek Polacek wrote: > > > > On Mon, Dec 06, 2021 at 04:44:06PM -0500, Jason Merrill wrote: > > > > >

Re: [PATCH v3] c++: Handle auto(x) in parameter-declaration-clause [PR103401]

2021-12-08 Thread Marek Polacek via Gcc-patches
On Wed, Dec 08, 2021 at 09:15:05AM -0500, Jason Merrill wrote: > On 12/7/21 19:25, Marek Polacek wrote: > > On Mon, Dec 06, 2021 at 04:44:06PM -0500, Jason Merrill wrote: > > > Please also make this change to cp_parser_sizeof_operand, and add tests > > > involving sizeof/alignof in array bounds.

[PATCH v3] c++: Handle auto(x) in parameter-declaration-clause [PR103401]

2021-12-07 Thread Marek Polacek via Gcc-patches
On Mon, Dec 06, 2021 at 04:44:06PM -0500, Jason Merrill wrote: > Please also make this change to cp_parser_sizeof_operand, and add tests > involving sizeof/alignof in array bounds. OK with that change. Turns out we reject sizeof(auto(4)) because cp_parser_type_id_1 errors "invalid use of auto".

[pushed] c++: Fix decltype-bitfield1.C on i?86

2021-12-07 Thread Marek Polacek via Gcc-patches
This test was failing on i?86 because of: warning: width of 'A::l' exceeds its type so change the type to 'long long' and make the test run only on arches where sizeof(long long) == 8 to avoid failing like this again. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/testsuite/ChangeLog:

Re: [PATCH] Fix C++/93809 and C++/83469: typenames and unions

2021-12-07 Thread Marek Polacek via Gcc-patches
On Tue, Dec 07, 2021 at 09:59:42AM -0800, apinski--- via Gcc-patches wrote: > From: Andrew Pinski > > There are a few issues here with typenames and unions (and even struct > keywords with unions). First in cp_parser_check_class_key, > we need to allow typenames to name union types and union key

[pushed] c++: Add fixed test [PR93614]

2021-12-04 Thread Marek Polacek via Gcc-patches
This was fixed by r11-86. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/93614 gcc/testsuite/ChangeLog: * g++.dg/template/lookup18.C: New test. --- gcc/testsuite/g++.dg/template/lookup18.C | 17 + 1 file changed, 17 insertions(+) create mode 100644

[PATCH] c++: Fix for decltype and bit-fields [PR95009]

2021-12-04 Thread Marek Polacek via Gcc-patches
Here, decltype deduces the wrong type for certain expressions involving bit-fields. Unlike in C, in C++ bit-field width is explicitly not part of the type, so I think decltype should never deduce to 'int:N'. The problem isn't that we're not calling unlowered_expr_type--we are--it's that

[PATCH v2] c++: Handle auto(x) in parameter-declaration-clause [PR103401]

2021-12-03 Thread Marek Polacek via Gcc-patches
On Thu, Dec 02, 2021 at 12:56:38PM -0500, Jason Merrill wrote: > On 12/2/21 10:27, Marek Polacek wrote: > > On Wed, Dec 01, 2021 at 11:24:58PM -0500, Jason Merrill wrote: > > > On 12/1/21 10:16, Marek Polacek wrote: > > > > In C++23, auto(x) is valid, so decltype(auto(x)) should also be valid, > >

Re: [PATCH] libcpp: Fix up handling of deferred pragmas [PR102432]

2021-12-03 Thread Marek Polacek via Gcc-patches
On Fri, Dec 03, 2021 at 11:27:27AM +0100, Jakub Jelinek wrote: > Hi! > > The https://gcc.gnu.org/pipermail/gcc-patches/2020-November/557903.html > change broke the following testcases. The problem is when a pragma > namespace allows expansion (i.e. p->is_nspace && p->allow_expansion), > e.g. the

[PATCH v2] c++: Fix for decltype(auto) and parenthesized expr [PR103403]

2021-12-02 Thread Marek Polacek via Gcc-patches
On Wed, Dec 01, 2021 at 11:16:27PM -0500, Jason Merrill wrote: > On 12/1/21 10:16, Marek Polacek wrote: > > In r11-4758, I tried to fix this problem: > > > >int & = 0; > >decltype(auto) j = i; // should behave like int & = i; error > > > > wherein do_auto_deduction was getting confused

Re: [PATCH] c++: Handle auto(x) in parameter-declaration-clause [PR103401]

2021-12-02 Thread Marek Polacek via Gcc-patches
On Wed, Dec 01, 2021 at 11:24:58PM -0500, Jason Merrill wrote: > On 12/1/21 10:16, Marek Polacek wrote: > > In C++23, auto(x) is valid, so decltype(auto(x)) should also be valid, > > so > > > >void f(decltype(auto(0))); > > > > should be just as > > > >void f(int); > > > > but

[PATCH v2] c++: ICE with auto(0) in requires-expression [PR103408]

2021-12-01 Thread Marek Polacek via Gcc-patches
On Wed, Dec 01, 2021 at 12:17:47PM -0500, Patrick Palka wrote: > On Wed, Dec 1, 2021 at 10:26 AM Marek Polacek via Gcc-patches > wrote: > > > > Here we ICE on > > > > int f() requires (auto(0)); > > > > in do_auto_deduction when handling the a

[PATCH] c++: Fix bogus error with __integer_pack [PR94490]

2021-12-01 Thread Marek Polacek via Gcc-patches
Here we issue a bogus: error: '(0 ? fake_tuple_size_v : fake_tuple_size_v)' is not a constant expression because cxx_constant_value in expand_integer_pack gets *(0 ? VIEW_CONVERT_EXPR(fake_tuple_size_v) : VIEW_CONVERT_EXPR(fake_tuple_size_v)) which is a REFERENCE_REF_P and we evaluate its

[PATCH] c++: Fix for decltype(auto) and parenthesized expr [PR103403]

2021-12-01 Thread Marek Polacek via Gcc-patches
In r11-4758, I tried to fix this problem: int & = 0; decltype(auto) j = i; // should behave like int & = i; error wherein do_auto_deduction was getting confused with a REFERENCE_REF_P and it didn't realize its operand was a name, not an expression, and deduced the wrong type. Unfortunately

[PATCH] c++: ICE with unnamed tparm and concept [PR103408]

2021-12-01 Thread Marek Polacek via Gcc-patches
Here we crash when issuing the "constraint C has type T, not bool" error, because pp_cxx_parameter_mapping wasn't prepared to see an anonymous template parameter. With this patch we print error: constraint 'auto() [with = 0]' has type '', not 'bool' The "" is what this patch adds.

[PATCH] c++: ICE with auto(0) in requires-expression [PR103408]

2021-12-01 Thread Marek Polacek via Gcc-patches
Here we ICE on int f() requires (auto(0)); in do_auto_deduction when handling the auto: we're in a non-templated requires-expression which are parsed under processing_template_decl == 1 and empty current_template_parms, so 'current_template_args ()' will crash. This code is invalid as per

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