Re: [PATCH] c++: constexpr init of union sub-aggr w/ base [PR105491]

2022-05-06 Thread Jason Merrill via Gcc-patches
On 5/6/22 16:10, Patrick Palka wrote: On Fri, 6 May 2022, Patrick Palka wrote: On Fri, 6 May 2022, Jason Merrill wrote: On 5/6/22 14:00, Patrick Palka wrote: On Fri, 6 May 2022, Patrick Palka wrote: On Fri, 6 May 2022, Jason Merrill wrote: On 5/6/22 11:22, Patrick Palka wrote: Here

Re: [PATCH] c++: constexpr init of union sub-aggr w/ base [PR105491]

2022-05-06 Thread Jason Merrill via Gcc-patches
On 5/6/22 14:00, Patrick Palka wrote: On Fri, 6 May 2022, Patrick Palka wrote: On Fri, 6 May 2022, Jason Merrill wrote: On 5/6/22 11:22, Patrick Palka wrote: Here ever since r10-7313-gb599bf9d6d1e18, reduced_constant_expression_p in C++11/14 is rejecting the marked sub-aggregate initializer

Re: [PATCH] c++: constexpr init of union sub-aggr w/ base [PR105491]

2022-05-06 Thread Jason Merrill via Gcc-patches
On 5/6/22 11:22, Patrick Palka wrote: Here ever since r10-7313-gb599bf9d6d1e18, reduced_constant_expression_p in C++11/14 is rejecting the marked sub-aggregate initializer (of type S) W w = {.D.2445={.s={.D.2387={.m=0}, .b=0}}} ^ ultimately because said initializer has

Re: [PATCH v2] c++: wrong error with MVP and pushdecl [PR64679]

2022-05-05 Thread Jason Merrill via Gcc-patches
On 5/5/22 16:57, Marek Polacek wrote: On Wed, May 04, 2022 at 09:29:46PM -0400, Jason Merrill wrote: On 5/4/22 19:20, Marek Polacek wrote: On Wed, May 04, 2022 at 05:44:45PM -0400, Jason Merrill wrote: On 5/4/22 16:03, Marek Polacek wrote: This patch fixes the second half of 64679. Here we

[PATCH RFA] attribs: fix typedefs in generic code [PR105492]

2022-05-05 Thread Jason Merrill via Gcc-patches
In my patch for PR100545 I added an assert to check for broken typedefs in set_underlying_type, and it found one in this case: rs6000_handle_altivec_attribute had the same problem as handle_mode_attribute. So let's move the fixup into decl_attributes. Tested that this fixes the ICE on a cross

Re: [PATCH] c++: wrong error with MVP and pushdecl [PR64679]

2022-05-04 Thread Jason Merrill via Gcc-patches
On 5/4/22 19:20, Marek Polacek wrote: On Wed, May 04, 2022 at 05:44:45PM -0400, Jason Merrill wrote: On 5/4/22 16:03, Marek Polacek wrote: This patch fixes the second half of 64679. Here we issue a wrong "redefinition of 'int x'" for the following: struct Bar { Bar(int, int, int);

[pushed] c++: alias CTAD refactoring [PR104470]

2022-05-04 Thread Jason Merrill via Gcc-patches
In my previous PR104470 patch I added yet another place that needs to handle dependent member rewriting for deduction guides; this patches centralizes rewriting into maybe_dependent_member_ref. tsubst_baselink still has its own handling because that's simpler than teaching

Re: [PATCH] c++: wrong error with MVP and pushdecl [PR64679]

2022-05-04 Thread Jason Merrill via Gcc-patches
On 5/4/22 16:03, Marek Polacek wrote: This patch fixes the second half of 64679. Here we issue a wrong "redefinition of 'int x'" for the following: struct Bar { Bar(int, int, int); }; int x = 1; Bar bar(int(x), int(x), int{x}); // #1 cp_parser_parameter_declaration_list does

[pushed] c++: optimize reshape_init

2022-05-04 Thread Jason Merrill via Gcc-patches
If the index of a constructor_elt is a FIELD_DECL, the CONSTRUCTOR is already reshaped, so we can save time and memory by returning immediately. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * decl.cc (reshape_init): Shortcut already-reshaped init.

Re: [PATCH] c++: ICE during aggr CTAD for member tmpl [PR105476]

2022-05-04 Thread Jason Merrill via Gcc-patches
On 5/4/22 10:09, Patrick Palka wrote: Here we're crashing from maybe_aggr_guide ultimately because processing_template_decl isn't set when partially instantiating the guide's parameter list. This causes us to prematurely force completion of the dependent type Visitor_functior, which fails and

Re: [PATCH v4] c++: add color to function decl printing

2022-05-04 Thread Jason Merrill via Gcc-patches
On 1/14/22 22:56, Jason Merrill wrote: On 1/14/22 16:49, David Malcolm wrote: On Mon, 2021-12-13 at 09:58 -0500, Jason Merrill via Gcc-patches wrote: On 12/13/21 06:02, Jonathan Wakely wrote: On Sun, 12 Dec 2021 at 05:39, Jason Merrill mailto:ja...@redhat.com>> wrote:   >   >

[pushed] c++: use %D more

2022-05-04 Thread Jason Merrill via Gcc-patches
There's no reason to call cxx_printable_name_translate here instead of using %D in the format string. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * error.c (cp_print_error_function): Use %qD. (function_category): Use %qD. --- gcc/cp/error.cc | 29

Re: [PATCH] c++: parse error with >= in template argument list [PR105436]

2022-05-04 Thread Jason Merrill via Gcc-patches
On 5/4/22 11:15, Marek Polacek wrote: On Tue, May 03, 2022 at 04:46:11PM -0400, Jason Merrill wrote: On 5/3/22 16:43, Jakub Jelinek wrote: On Tue, May 03, 2022 at 04:26:51PM -0400, Jason Merrill wrote: On 5/2/22 12:19, Marek Polacek wrote: This patch fixes an oversight whereby we treated >=

[pushed] c++: Remove cdtor_label

2022-05-04 Thread Jason Merrill via Gcc-patches
Jakub pointed out that cdtor_label is unnecessary, we should get all the desired semantics with a normal return. Tested x86_64-pc-linux-gnu and arm-eabi//arm-sim, applying to trunk. gcc/cp/ChangeLog: * cp-tree.h (struct language_function): Remove x_cdtor_label. (cdtor_label,

Re: [PATCH v2] c++: ICE with temporary of class type in DMI [PR100252]

2022-05-03 Thread Jason Merrill via Gcc-patches
On 4/27/22 16:30, Marek Polacek wrote: On Wed, Apr 27, 2022 at 11:00:46AM -0400, Patrick Palka wrote: On Tue, 26 Apr 2022, Marek Polacek wrote: Consider struct A { int x; int y = x; }; struct B { int x = 0; int y = A{x}.y; // #1 }; where for #1 we end up

Re: [PATCH] c++: Don't emit deprecated warnings or unavailable errors on lambda declarations

2022-05-03 Thread Jason Merrill via Gcc-patches
On 5/2/22 07:11, Jakub Jelinek wrote: Hi! On the following testcase, we emit deprecated warnings or unavailable errors even on merge declarations of those lambdas (the dg-bogus directives), while IMHO we should emit them only when something actually calls those lambdas. The following patch

Re: [PATCH] c++: parse error with >= in template argument list [PR105436]

2022-05-03 Thread Jason Merrill via Gcc-patches
On 5/3/22 16:43, Jakub Jelinek wrote: On Tue, May 03, 2022 at 04:26:51PM -0400, Jason Merrill wrote: On 5/2/22 12:19, Marek Polacek wrote: This patch fixes an oversight whereby we treated >= as the end of a template argument. This causes problems in C++14, because in

Re: [PATCH] c++: wrong parse with functors [PR64679]

2022-05-03 Thread Jason Merrill via Gcc-patches
On 5/2/22 12:18, Marek Polacek wrote: Consider struct F { F(int) {} F operator()(int) const { return *this; } }; and F(i)(0)(0); where we're supposed to first call the constructor and then invoke the operator() twice. However, we parse this as an init-declarator: "(i)"

Re: [PATCH] c++: parse error with >= in template argument list [PR105436]

2022-05-03 Thread Jason Merrill via Gcc-patches
On 5/2/22 12:19, Marek Polacek wrote: This patch fixes an oversight whereby we treated >= as the end of a template argument. This causes problems in C++14, because in cp_parser_template_argument we go different ways for C++14 and C++17: /* It must be a non-type argument. In C++17 any

Re: [PATCH] c++: partial spec constraint checking context [PR105220]

2022-05-03 Thread Jason Merrill via Gcc-patches
On 5/2/22 14:50, Patrick Palka wrote: Currently when checking the constraints of a class template, we do so in the context of the template, not the specialized type. This is the best we can do for a primary template since the specialized type is valid only if the primary template's constraints

Re: [PATCH] c++: make finish non_static_data_member SFINAE friendly [PR105351]

2022-05-03 Thread Jason Merrill via Gcc-patches
On 5/3/22 13:40, Patrick Palka wrote: Here, since finish_non_static_data_member isn't SFINAE friendly, we incorrectly emit an error during overload resolution: sfinae33.C: In substitution of ‘template A f() [with T = B]’: sfinae33.C:11:7: required from here sfinae33.C:5:31: error: invalid use

[pushed] c++: improve template-id location

2022-05-02 Thread Jason Merrill via Gcc-patches
On PR102629 I noticed that we were giving the entire lambda as the location for this template-id. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * pt.cc (tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Copy location. (do_auto_deduction): Use expr location.

[pushed] c++: also note name used in enclosing class

2022-05-02 Thread Jason Merrill via Gcc-patches
While looking at PR96645 I noticed that while we were diagnosing names changing meaning in the full class context, we weren't doing this for lookups in nested class bodies. Note that this breaks current range-v3; I've submitted a pull request to fix its violation of the rule. Tested

[pushed] c++: reorganize friend template matching [PR91618]

2022-04-29 Thread Jason Merrill via Gcc-patches
The the different calling of check_explicit_specialization for class and namespace scope friends bothered me, so this patch combines them. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/91618 PR c++/96604 gcc/cp/ChangeLog: * friend.cc (do_friend): Call

[pushed] c++: alias CTAD and member alias templates [PR104470]

2022-04-29 Thread Jason Merrill via Gcc-patches
In this testcase, we were trying to substitute into variant>::__accepted_type, but failed to look it up because variant> doesn't exist. In other cases we already rewrite such things into a dependent reference; we need to do that for alias templates as well. This caused some testsuite regressions

[pushed] c++: lambda capture dependent type [PR82980]

2022-04-29 Thread Jason Merrill via Gcc-patches
The stage 4 patch limited direct propagation of dependent type to capture field/proxy to the "current instantiation", but many more types should be suitable as well. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * lambda.cc (type_deducible_expression_p): Allow more

Re: [PATCH RFA] c-family: attribute ((aligned, mode)) [PR100545]

2022-04-29 Thread Jason Merrill via Gcc-patches
On 4/27/22 19:48, Jason Merrill wrote: On 4/27/22 13:02, Joseph Myers wrote: On Wed, 27 Apr 2022, Jason Merrill via Gcc-patches wrote: +  if (typedef_variant_p (type)) +    { +  /* Set up the typedef all over again.  */ This seems wrong when the typedef is just being used in another

Re: [PATCH] c++: pedwarn for empty unnamed enum in decl [PR67048]

2022-04-29 Thread Jason Merrill via Gcc-patches
On 4/29/22 10:12, Marek Polacek wrote: [dcl.dcl]/5 says that enum { }; is ill-formed, and since r197742 we issue a pedwarn. However, the pedwarn also fires for enum { } x; which is well-formed. So only warn when {} is followed by a ;. This should be correct since you can't have

Re: [PATCH] Use CASE_CONVERT in a few more cases

2022-04-29 Thread Jason Merrill via Gcc-patches
On 4/29/22 05:37, Richard Biener wrote: This uses CASE_CONVERT more which eases eventual removal of NOP_EXPR. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK for trunk? Jason, from the experiment this is from I know that the C++ FE distinguishes between CONVERT_EXPR and NOP_EXPR at

[pushed] c++: check completeness after auto deduction [PR80351]

2022-04-29 Thread Jason Merrill via Gcc-patches
Normally we check for incomplete type in start_decl, but that obviously doesn't work for auto variables. Thanks to Pokechu22 for the analysis and testcases: "When cp_finish_decl calls cp_apply_type_quals_to_decl on a const auto or constexpr auto variable, the type might not be complete the first

[pushed] c++: using in diagnostics [PR102987]

2022-04-29 Thread Jason Merrill via Gcc-patches
The decl pretty-printing code wasn't looking at the flags parameter, so we were printing 'using' in the middle of an expression. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102987 gcc/cp/ChangeLog: * error.cc (dump_decl) [USING_DECL]: Respect flags.

[pushed] c++: dump alias-declaration scope

2022-04-29 Thread Jason Merrill via Gcc-patches
An alias can't be declared with a qualified-id in actual code, but in diagnostics we want to know which scope it belongs to, and I think a nested-name-specifier is the best way to provide that. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * error.cc (dump_decl):

[pushed] c++: traits, array of unknown bound of incomplete

2022-04-28 Thread Jason Merrill via Gcc-patches
My r161129 changed check_trait_type to reject arrays of unknown bound of incomplete type, but I can't find a rationale for that, and now think it's wrong: the standard just requires that the type be "complete, cv void, or an array of unknown bound." I imagine that allowing arrays of unknown bound

[pushed] c++: typeid and instantiation [PR102651]

2022-04-28 Thread Jason Merrill via Gcc-patches
PR49387 was a problem with initially asking for a typeid for a class template specialization before it was complete, and later actually filling in the descriptor when the class was complete, and thus disagreeing on the form of the descriptor. I fixed that by forcing the class to be complete, but

Re: [PATCH] c++, coroutines: Avoid expanding within templates [PR103868]

2022-04-28 Thread Jason Merrill via Gcc-patches
On 4/28/22 04:24, Iain Sandoe wrote: Hi Jason, On 20 Apr 2022, at 04:45, Jason Merrill wrote: On 4/18/22 15:49, Eric Gallager via Gcc-patches wrote: On Mon, Apr 18, 2022 at 10:01 AM Iain Sandoe via Gcc-patches wrote: From: Nathan Sidwell This is a forward-port of a patch by Nathan

Re: [PATCH] c++, coroutines: Make sure our temporaries are in a bind expr [PR105287]

2022-04-28 Thread Jason Merrill via Gcc-patches
On 4/28/22 04:28, Iain Sandoe wrote: Hi Jason, On 20 Apr 2022, at 03:14, Jason Merrill wrote: On 4/18/22 10:02, Iain Sandoe wrote: There are a few cases where we can generate a temporary that does not need to be added to the coroutine frame (i.e. these are genuinely ephemeral). The intent

Re: [PATCH] c++: global-namespace-qualified var after class def [PR90107]

2022-04-27 Thread Jason Merrill via Gcc-patches
On 4/27/22 18:45, Marek Polacek wrote: Here we wrongly reject the definition of "::N::a" struct A; namespace N { extern A a; } struct A {} ::N::a; because our code to diagnose a missing ; after a class definition doesn't realize that :: can follow a class definition.

Re: [PATCH RFA] c-family: attribute ((aligned, mode)) [PR100545]

2022-04-27 Thread Jason Merrill via Gcc-patches
On 4/27/22 13:02, Joseph Myers wrote: On Wed, 27 Apr 2022, Jason Merrill via Gcc-patches wrote: + if (typedef_variant_p (type)) + { + /* Set up the typedef all over again. */ This seems wrong when the typedef is just being used in another declaration with the mode

Re: [PATCH] c++: enum in generic lambda at global scope [PR105398]

2022-04-27 Thread Jason Merrill via Gcc-patches
On 4/27/22 13:00, Marek Polacek wrote: On Wed, Apr 27, 2022 at 11:47:02AM -0400, Jason Merrill wrote: On 4/27/22 08:59, Marek Polacek wrote: On Wed, Apr 27, 2022 at 08:24:54AM -0400, Patrick Palka wrote: On Tue, 26 Apr 2022, Marek Polacek via Gcc-patches wrote: We crash compiling this test

Re: [PATCH] c++: enum in generic lambda at global scope [PR105398]

2022-04-27 Thread Jason Merrill via Gcc-patches
On 4/27/22 08:59, Marek Polacek wrote: On Wed, Apr 27, 2022 at 08:24:54AM -0400, Patrick Palka wrote: On Tue, 26 Apr 2022, Marek Polacek via Gcc-patches wrote: We crash compiling this test since r11-7993 which changed lookup_template_class_1 so that we only call tsubst_enum when

[PATCH RFA] c-family: attribute ((aligned, mode)) [PR100545]

2022-04-27 Thread Jason Merrill via Gcc-patches
The problem here was that handle_mode_attribute clobbered the changes of any previous attribute, only copying type qualifiers to the new type. And common_handle_aligned_attribute had previously set up the typedef, so when we later called set_underlying_type it saw DECL_ORIGINAL_TYPE set and just

[pushed] c++: pack init-capture of unresolved overload [PR102629]

2022-04-26 Thread Jason Merrill via Gcc-patches
Here we were failing to diagnose that the initializer for the capture pack is an unresolved overload. It turns out that the reason we didn't recognize the deduction failure in do_auto_deduction was that the individual 'auto' in the expansion of the capture pack was still marked as a parameter

Re: [PATCH] c++: decltype of non-dependent call of class type [PR105386]

2022-04-26 Thread Jason Merrill via Gcc-patches
On 4/26/22 09:45, Patrick Palka wrote: We need to pass tf_decltype when instantiating a non-dependent decltype operand, like tsubst does in the dependent case, so that we avoid materializing a temporary for a prvalue operand. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK

[pushed] c++: generic lambda fn parm pack [PR104624]

2022-04-25 Thread Jason Merrill via Gcc-patches
Parameter packs from the enclosing context can be used unexpanded in a lambda that is itself part of a pack expansion, but not packs that are part of the lambda itself. We already check for capture packs; we also need to check for function parameter packs of the lambda call operator. Tested

Re: [PATCH] c++: partial ordering with dependent NTTP type [PR105289]

2022-04-25 Thread Jason Merrill via Gcc-patches
On 4/25/22 14:10, Patrick Palka wrote: On Mon, 25 Apr 2022, Jason Merrill wrote: On 4/22/22 15:27, Patrick Palka wrote: On Fri, 22 Apr 2022, Patrick Palka wrote: Here ever since r11-6483-ge2e2f3f2c9400f we're rejecting and crashing (respectively) on two testcases that we used to accept in

Re: [PATCH] c++: crash with requires-expr and -Wsequence-point [PR105304]

2022-04-25 Thread Jason Merrill via Gcc-patches
On 4/22/22 14:36, Patrick Palka wrote: Here we're crashing from verify_sequence_points for this requires-expr condition because it contains a templated CAST_EXPR with empty operand, and verify_tree doesn't ignore this empty operand only because the manual tail recursion that it perform for unary

Re: [PATCH] c++: __builtin_shufflevector with value-dep expr [PR105353]

2022-04-25 Thread Jason Merrill via Gcc-patches
On 4/22/22 19:57, Marek Polacek wrote: Here we issue an error from c_build_shufflevector while parsing a template because it got a TEMPLATE_PARM_INDEX, but this function expects INTEGER_CSTs (except the first two arguments). It checks if any of the arguments are type-dependent, if so, we leave

Re: [PATCH] c++: partial ordering with dependent NTTP type [PR105289]

2022-04-25 Thread Jason Merrill via Gcc-patches
On 4/22/22 15:27, Patrick Palka wrote: On Fri, 22 Apr 2022, Patrick Palka wrote: Here ever since r11-6483-ge2e2f3f2c9400f we're rejecting and crashing (respectively) on two testcases that we used to accept in C++17 mode. Both testcases declare partial specializations for which the primary

Re: [PATCH v2] c++: wrong error with constexpr COMPOUND_EXPR [PR105321]

2022-04-21 Thread Jason Merrill via Gcc-patches
Yes, also ok with that change. On Thu, Apr 21, 2022, 10:22 AM Jakub Jelinek wrote: > On Thu, Apr 21, 2022 at 09:20:48AM -0400, Marek Polacek via Gcc-patches > wrote: > > --- a/gcc/cp/constexpr.cc > > +++ b/gcc/cp/constexpr.cc > > @@ -4566,19 +4566,18 @@ cxx_eval_bit_cast (const constexpr_ctx

Re: [PATCH v2] c++: wrong error with constexpr COMPOUND_EXPR [PR105321]

2022-04-21 Thread Jason Merrill via Gcc-patches
Ok. On Thu, Apr 21, 2022, 9:20 AM Marek Polacek wrote: > On Thu, Apr 21, 2022 at 08:56:23AM -0400, Jason Merrill wrote: > > On 4/20/22 18:40, Marek Polacek wrote: > > > Here we issue a bogus error for the first assert in the test. Therein > > > we have > > > > > > = (void)

Re: [PATCH] c++: wrong error with constexpr COMPOUND_EXPR [PR105321]

2022-04-21 Thread Jason Merrill via Gcc-patches
On 4/20/22 18:40, Marek Polacek wrote: Here we issue a bogus error for the first assert in the test. Therein we have = (void) (VIEW_CONVERT_EXPR(yes) || handle_error ());, VIEW_CONVERT_EXPR(value); which has a COMPOUND_EXPR, so we get to cxx_eval_constant_expression . The problem here is

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

2022-04-21 Thread Jason Merrill via Gcc-patches
On 4/18/22 18:09, 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 branch (in accordance with the letter

Re: [PATCH] c++, coroutines: Avoid expanding within templates [PR103868]

2022-04-19 Thread Jason Merrill via Gcc-patches
On 4/18/22 15:49, Eric Gallager via Gcc-patches wrote: On Mon, Apr 18, 2022 at 10:01 AM Iain Sandoe via Gcc-patches wrote: From: Nathan Sidwell This is a forward-port of a patch by Nathan (against 10.x) which fixes an open PR. We are ICEing because we ended up tsubst_copying something that

Re: [PATCH] c++, coroutines: Improve check for throwing final await [PR104051].

2022-04-19 Thread Jason Merrill via Gcc-patches
On 4/18/22 11:34, Iain Sandoe wrote: We check that the final_suspend () method returns a sane type (i.e. a class or structure) but, unfortunately, that check has to be later than the one for a throwing case. If the user returns some nonsensical type from the method, we need to handle that in

Re: [PATCH] c++, coroutines: Account for overloaded promise return_value() [PR105301].

2022-04-19 Thread Jason Merrill via Gcc-patches
On 4/18/22 10:03, Iain Sandoe wrote: Whether it was intended or not, it is possible to define a coroutine promise with multiple return_value() methods [which need not even have the same type]. We were not accounting for this possibility in the check to see whether both return_value and

Re: [PATCH] c++, coroutines: Make sure our temporaries are in a bind expr [PR105287]

2022-04-19 Thread Jason Merrill via Gcc-patches
On 4/18/22 10:02, Iain Sandoe wrote: There are a few cases where we can generate a temporary that does not need to be added to the coroutine frame (i.e. these are genuinely ephemeral). The intent was that unnamed temporaries should not be 'promoted' to coroutine frame entries. However there

Re: [PATCH] c++: Fix up CONSTRUCTOR_PLACEHOLDER_BOUNDARY handling [PR105256]

2022-04-19 Thread Jason Merrill via Gcc-patches
On Tue, Apr 19, 2022, 6:53 AM Jakub Jelinek wrote: > On Mon, Apr 18, 2022 at 09:57:12AM -0400, Patrick Palka wrote: > > > Hmm, Patrick made a similar change and then reverted it for PR90996. > > > But it makes sense to me; when we replace placeholders, it's > appropriate > > > to look at the

Re: [PATCH] c++: Fix up CONSTRUCTOR_PLACEHOLDER_BOUNDARY handling [PR105256]

2022-04-17 Thread Jason Merrill via Gcc-patches
On 4/15/22 07:22, Jakub Jelinek wrote: Hi! The CONSTRUCTOR_PLACEHOLDER_BOUNDARY bit is supposed to separate PLACEHOLDER_EXPRs that should be replaced by one object or subobjects of it (variable, TARGET_EXPR slot, ...) from other PLACEHOLDER_EXPRs that should be replaced by different objects or

Re: [PATCH v2] c, c++: attribute format on a ctor with a vbase [PR101833, PR47634]

2022-04-14 Thread Jason Merrill via Gcc-patches
On 4/13/22 19:17, Marek Polacek wrote: On Tue, Apr 12, 2022 at 04:01:14PM -0400, Jason Merrill wrote: On 4/12/22 14:38, Marek Polacek wrote: On Mon, Apr 11, 2022 at 04:39:22PM -0400, Jason Merrill wrote: On 4/8/22 15:21, Marek Polacek wrote: On Wed, Apr 06, 2022 at 04:55:54PM -0400, Jason

Re: [PATCH] c++: wrong error with variadic concept [PR105268]

2022-04-14 Thread Jason Merrill via Gcc-patches
On 4/14/22 16:24, Marek Polacek wrote: Here we issue a wrong error for the template>> void g(); line in the testcase. I surmise that's because we mistakenly parse C_many as a placeholder-type-specifier, and things go wrong from there. We are in a default argument so we should reject

[pushed] c++: unsigned int32_t enum promotion [PR102804]

2022-04-14 Thread Jason Merrill via Gcc-patches
There's been an extension for a long time to allow applying 'unsigned' to an int typedef, but that was confusing the integer promotion code. Fixed by forgetting about the typedef in that case. I'm going to make this an unconditional pedwarn in stage 1. Tested x86_64-pc-linux-gnu, applying to

[pushed] c++: using in diagnostics [PR102987]

2022-04-14 Thread Jason Merrill via Gcc-patches
The expression pretty-printing code crashed on a location wrapper with no type, and didn't know what to do with a USING_DECL. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102987 gcc/cp/ChangeLog: * error.cc (dump_expr): Handle USING_DECL. [VIEW_CONVERT_EXPR]:

[pushed] c++: constexpr trivial -fno-elide-ctors [PR104646]

2022-04-14 Thread Jason Merrill via Gcc-patches
The constexpr constructor checking code got confused by the expansion of a trivial copy constructor; we don't need to do that checking for defaulted ctors, anyway. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/104646 gcc/cp/ChangeLog: * constexpr.cc

[pushed] c++: lambda and the current instantiation [PR82980]

2022-04-14 Thread Jason Merrill via Gcc-patches
When a captured variable is type-dependent, we've expressed the type of the capture field and proxy with a decltype variant. But if the type is "the current instantiation", we need to be able to see that so that we can do lookup inside it just like we could with the captured variable itself. I

[pushed] c++: alignment of local typedef in template [PR65211]

2022-04-13 Thread Jason Merrill via Gcc-patches
Because common_handle_aligned_attribute only applies the alignment to the TREE_TYPE of a typedef, not the DECL_ORIGINAL_TYPE, we need to copy it explicitly in tsubst. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/65211 gcc/cp/ChangeLog: * pt.cc (tsubst_decl)

[pushed] c++: local fn and generic lambda [PR97219]

2022-04-13 Thread Jason Merrill via Gcc-patches
When instantiating the op() for a generic lambda, we can no longer do name lookup inside function scopes enclosing the lambda, so we need to remember the lookup result from processing the definition of the lambda. So the code in finish_call_expr to throw away the lookup result and instead look it

[pushed] c++: template conversion op [PR101698]

2022-04-13 Thread Jason Merrill via Gcc-patches
Asking for conversion to a dependent type also makes a BASELINK dependent. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/101698 gcc/cp/ChangeLog: * pt.cc (tsubst_baselink): Also check dependent optype. gcc/testsuite/ChangeLog: * g++.dg/template/conv19.C: New

[pushed] c++: NRV and ref-extended temps [PR101442]

2022-04-13 Thread Jason Merrill via Gcc-patches
This issue goes back to r83221, where the cleanup for extended ref temps changed from being unconditional to being tied to the declaration they formed part of the initializer for. The named return value optimization changes the cleanup for the NRV variable to only run on the EH path; we don't

[pushed] c++: empty base constexpr -fno-elide-ctors [PR105245]

2022-04-13 Thread Jason Merrill via Gcc-patches
The patch for 100111 extended our handling of empty base elision to the case where the derived class has no other fields, but we still need to make sure that there's some initializer for the derived object. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/105245 PR

Re: [PATCH] c++: Treat alignas align_expr and aligned attribute's operand as manifestly constant evaluation [PR105233]

2022-04-13 Thread Jason Merrill via Gcc-patches
On 4/13/22 04:11, Jakub Jelinek wrote: Hi! The following testcase fails, because we only constant evaluate the alignas argument as non-manifestly constant-evaluated and as __builtin_is_constant_evaluated appears, we make it non-constant (the reason is that we often try to evaluate some

Re: [PATCH] c++: ambiguous call not diagnosed after DR2352 [PR97296]

2022-04-12 Thread Jason Merrill via Gcc-patches
On 4/12/22 18:50, Marek Polacek wrote: DR 2352 changed the definitions of reference-related (so that it uses "similar type" instead of "same type") and of reference-compatible (use a standard conversion sequence). That means that reference-related is now more broad, which means that we will be

[pushed] c++: local function versioning [PR104669]

2022-04-12 Thread Jason Merrill via Gcc-patches
There were two problems with this testcase: we weren't copying the target attribute from the second declaration to the global alias for the first one (duplicate_decls hunk), and then we were treating the third one as matching the earlier one even though both are versioned (decls_match hunk). The

[pushed] c++: non-array new alignment [PR102071]

2022-04-12 Thread Jason Merrill via Gcc-patches
While considering the PR102071 patch for backporting, I noticed that I was considering the alignment of the array new cookie even when there isn't one because we aren't allocating an array. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102071 gcc/cp/ChangeLog: * init.cc

Re: [PATCH] c++: NON_DEPENDENT_EXPR is not potentially constant [PR104507]

2022-04-12 Thread Jason Merrill via Gcc-patches
On 4/12/22 15:48, Patrick Palka wrote: On Wed, Feb 16, 2022 at 2:47 PM Patrick Palka wrote: On Tue, 15 Feb 2022, Jason Merrill wrote: On 2/15/22 17:00, Patrick Palka wrote: On Tue, 15 Feb 2022, Jason Merrill wrote: On 2/15/22 15:13, Patrick Palka wrote: On Tue, 15 Feb 2022, Patrick

Re: [PATCH] c++: requires-expr in pack expansion using pack [PR103105]

2022-04-12 Thread Jason Merrill via Gcc-patches
On 4/12/22 14:44, Patrick Palka wrote: On Tue, Apr 12, 2022 at 12:33 PM Jason Merrill wrote: On 4/12/22 12:17, Patrick Palka wrote: Here after dependent substitution of {Ts...} into the alias 'wrap', since we never partially instantiate a requires-expr, we end up with a requires-expr whose

Re: [PATCH] c, c++: attribute format on a ctor with a vbase [PR101833, PR47634]

2022-04-12 Thread Jason Merrill via Gcc-patches
On 4/12/22 14:38, Marek Polacek wrote: On Mon, Apr 11, 2022 at 04:39:22PM -0400, Jason Merrill wrote: On 4/8/22 15:21, Marek Polacek wrote: On Wed, Apr 06, 2022 at 04:55:54PM -0400, Jason Merrill wrote: On 4/1/22 15:14, Marek Polacek wrote: Attribute format takes three arguments: archetype,

Re: [PATCH] c++: requires-expr in pack expansion using pack [PR103105]

2022-04-12 Thread Jason Merrill via Gcc-patches
On 4/12/22 12:17, Patrick Palka wrote: Here after dependent substitution of {Ts...} into the alias 'wrap', since we never partially instantiate a requires-expr, we end up with a requires-expr whose REQUIRES_EXPR_EXTRA_ARGS contains an ARGUMENT_PACK_SELECT (which just resolves to the parameter

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

2022-04-12 Thread Jason Merrill via Gcc-patches
On 3/24/22 17:06, Jason Merrill wrote: On 3/22/22 16:59, Marek Polacek via Gcc-patches wrote: 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 (&)[]),

[pushed] c++: rodata and defaulted ctor [PR104142]

2022-04-11 Thread Jason Merrill via Gcc-patches
Trivial initialization shouldn't bump a variable out of .rodata; if the result of build_aggr_init is an empty STATEMENT_LIST, throw it away. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/104142 gcc/cp/ChangeLog: * decl.cc (check_initializer): Check TREE_SIDE_EFFECTS.

[pushed] c++: using operator= [PR105223]

2022-04-11 Thread Jason Merrill via Gcc-patches
In a template class A we normally add an implicit using A::operator= as a placeholder for the implicitly declared operator whose signature we don't know yet. In my patch for PR92918 I stopped doing that if the class has an explicit operator=, but that was wrong; an operator= taking an unrelated

[pushed] c++: operator new lookup [PR98249]

2022-04-11 Thread Jason Merrill via Gcc-patches
The standard says, as we quote in the comment just above, that if we don't find operator new in the allocated type, it should be looked up in the global scope. This is specifically ::, not just any namespace, and we already give an error for an operator new declared in any other namespace.

Re: [PATCH] c, c++: attribute format on a ctor with a vbase [PR101833, PR47634]

2022-04-11 Thread Jason Merrill via Gcc-patches
On 4/8/22 15:21, Marek Polacek wrote: On Wed, Apr 06, 2022 at 04:55:54PM -0400, Jason Merrill wrote: On 4/1/22 15:14, Marek Polacek wrote: Attribute format takes three arguments: archetype, string-index, and first-to-check. The last two specify the position in the function parameter list.

Re: [PATCH] c++: tolerate cdtors returning this in constexpr

2022-04-08 Thread Jason Merrill via Gcc-patches
On 4/7/22 18:25, Alexandre Oliva wrote: Hello, Jason, On Apr 6, 2022, Jason Merrill wrote: On 4/6/22 15:36, Alexandre Oliva wrote: Please adjust your patch subject lines for the new guidelines adopted as part of the git transition: https://gcc.gnu.org/contribute.html#patches Oh, wow, I

Re: [PATCH] c++: set loc on call even if result is discarded

2022-04-08 Thread Jason Merrill via Gcc-patches
On 4/7/22 18:48, Alexandre Oliva wrote: On Apr 6, 2022, Jason Merrill wrote: On 4/6/22 15:37, Alexandre Oliva wrote: Need to adjust this subject line, as well. *nod*, thanks * tree.cc (protected_set_expr_location): Propagate locus to call wrapped in cast-to-void. I'm reluctant to put

[pushed] c++: constexpr non-trivial aggregate init [PR105191]

2022-04-08 Thread Jason Merrill via Gcc-patches
My patch for PR92385 made us use VEC_INIT_EXPR for aggregate initialization of an array where some elements are not explicitly initialized. Constexpr handling of that was treating initialization from {} as equivalent to value-initialization, which is problematic for classes with default member

[pushed] c++: friend implicit template instantiation [PR91618]

2022-04-08 Thread Jason Merrill via Gcc-patches
This rule that for a friend with a qualified name we try to find a matching template was already in C++98, but it seems we never implemented it, and nobody reported it until 2019. This patch sets DECL_IMPLICIT_INSTANTIATION to signal to check_explicit_specialization that we want to find a

[pushed] c++: conversion with trailing return type [PR101051]

2022-04-06 Thread Jason Merrill via Gcc-patches
We've had a diagnostic for this, but since r10-6571 added an assert to splice_late_return_type, we need to diagnose before we call it. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/101051 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Reject conversion with trailing

[pushed] c++: nested generic lambda in DMI [PR101717]

2022-04-06 Thread Jason Merrill via Gcc-patches
We were already checking COMPLETE_TYPE_P to recognize instantiation of a generic lambda, but didn't consider that we might be nested in a non-generic lambda. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/101717 gcc/cp/ChangeLog: * lambda.cc (lambda_expr_this_capture):

[pushed] c++: vector compound literal [PR105187]

2022-04-06 Thread Jason Merrill via Gcc-patches
My cleanup in r12-296 cleared TREE_HAS_CONSTRUCTOR on digested class initializers, but we leave it set for vectors, since we can't wrap them in TARGET_EXPR. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/105187 gcc/cp/ChangeLog: * typeck2.cc (store_init_value): Allow

Re: tolerate cdtors returning this in constexpr

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/6/22 15:45, Marek Polacek via Gcc-patches wrote: On Wed, Apr 06, 2022 at 04:36:49PM -0300, Alexandre Oliva via Gcc-patches wrote: On targets that return this from cdtors, cxx_eval_call_expression may flag flowing off the end of a dtor. That's preempted for ctors, and avoided entirely

Re: set loc on call even if result is discarded

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/6/22 15:37, Alexandre Oliva wrote: Need to adjust this subject line, as well. This patch fixes a divergence in line numbers in diagnostics and, presumably, debug information, between targets whose cdtors return this and those that don't. The problem was visible in

Re: tolerate cdtors returning this in constexpr

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/6/22 15:36, Alexandre Oliva wrote: Please adjust your patch subject lines for the new guidelines adopted as part of the git transition: https://gcc.gnu.org/contribute.html#patches e.g. [PATCH] c++: tolerate cdtors returning this in constexpr [PRn] On targets that return this from

Re: [PATCH] c, c++: attribute format on a ctor with a vbase [PR101833, PR47634]

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/1/22 15:14, Marek Polacek wrote: Attribute format takes three arguments: archetype, string-index, and first-to-check. The last two specify the position in the function parameter list. r63030 clarified that "Since non-static C++ methods have an implicit this argument, the arguments of such

Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/6/22 11:26, Jakub Jelinek wrote: On Wed, Apr 06, 2022 at 11:18:32AM -0400, Jason Merrill wrote: Why not check at the beginning of the function? You just pinged this patch, but I haven't seen a response to this question. I thought the

[pushed] c++: -Wunused-value and array init [PR104702]

2022-04-06 Thread Jason Merrill via Gcc-patches
Here, because of problems with the new warning-control code and expressions that change location, the suppress_warning on the INDIRECT_REF didn't work. Those problems still need to be worked out, but it's simple to avoid needing to use suppress_warning in the first place by using a reference

Re: [PATCH] c++: respect complain for -Wctad-maybe-unsupported [PR105143]

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/6/22 11:11, Patrick Palka wrote: We were attempting to issue a -Wctad-maybe-unsupported warning even when complain=tf_none, which led to a crash in the first testcase below and a bogus error during SFINAE in the second testcase. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this

Re: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]

2022-04-06 Thread Jason Merrill via Gcc-patches
On 3/25/22 14:08, Jason Merrill wrote: On 3/25/22 12:34, Jakub Jelinek wrote: Hi! cplus_decl_attributes can be called with attributes equal to error_mark_node, there are some spots in the function that test it or decl_attributes it calls starts with:    if (TREE_TYPE (*node) == error_mark_node

Re: [PATCH] c++: Handle __builtin_clear_padding on non-trivially-copyable types [PR102586]

2022-04-06 Thread Jason Merrill via Gcc-patches
On 4/6/22 10:41, Jakub Jelinek wrote: On Fri, Feb 11, 2022 at 07:55:50PM +0100, Jakub Jelinek via Gcc-patches wrote: Something like the https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c16 will still be needed with adjusted testcase from

[pushed] c++: -Wshadow=compatible-local type vs var [PR100608]

2022-04-06 Thread Jason Merrill via Gcc-patches
The patch for PR92024 changed -Wshadow=compatible-local to warn if either new or old decl was a type, but the rationale only talked about the case where both are types. If only one is, they aren't compatible. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/100608

[PATCH RFA(pointer-query)] c++: -Wplacement-new and anon union member [PR100370]

2022-04-06 Thread Jason Merrill via Gcc-patches
This bug was an object/value confusion; we are interested in the size of *b.ip, but instead the code was calculating the size of b.ip itself. This seems to be because compute_objsize will compute the size of whatever object it can find in the argument: if you pass it a VAR_DECL, it gives you the

<    6   7   8   9   10   11   12   13   14   15   >