[pushed] c++: alias template equivalence and CTAD [PR103852]

2022-04-05 Thread Jason Merrill via Gcc-patches
I had been thinking about DR1286 "equivalence" as meaning generally interchangeable, but looking back at the proposed resolution in the context of this PR, I see that it's just about use as a template argument. So let's give a pedwarn if we look through a renaming alias. Tested

[pushed] c++: elaborated-type-spec in requires-expr [PR101677]

2022-04-05 Thread Jason Merrill via Gcc-patches
We were failing to declare class S in the global namespace because we were treating the requires-expression parameter scope as a normal block scope, so the implicit declaration went there. It seems to me that the requires parameter scope is more like a function parameter scope (not least in the

[pushed] c++: repeated friend template [PR101894]

2022-04-04 Thread Jason Merrill via Gcc-patches
Since olddecl isn't a definition, it doesn't get DECL_FRIEND_CONTEXT, so we need to copy it from newdecl when we merge the declarations. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/101894 gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Copy DECL_FRIEND_CONTEXT.

[pushed] c++: alias-tmpl equivalence and default targs [PR103852]

2022-04-04 Thread Jason Merrill via Gcc-patches
The suggested resolution for CWG1286, which we implemented, ignores default template arguments, but this PR is an example of why that doesn't make sense: the templates aren't functionally equivalent. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/103852 DR 1286

Re: [PATCH] c++: Fix ICE due to shared BLOCK node in coroutine generation [PR103328]

2022-04-01 Thread Jason Merrill via Gcc-patches
On 3/30/22 09:06, Benno Evers via Gcc-patches wrote: From: Benno Evers When finishing a function that is a coroutine, the function is transformed into a "ramp" function, and the original user-provided function body gets moved into a newly created "actor" function. In this case

Re: [PATCH] c++: deduction for dependent class type of NTTP [PR105110]

2022-04-01 Thread Jason Merrill via Gcc-patches
On 3/30/22 17:51, Patrick Palka wrote: Here deduction for the P/A pair V/a spuriously fails with types ‘A’ and ‘const A’ have incompatible cv-qualifiers because the argument type is const, whereas the parameter type is non-const. Since the type of an NTTP is always cv-unqualified, it seems

Re: [PATCH] c-family: Tweak -Woverflow diagnostic

2022-04-01 Thread Jason Merrill via Gcc-patches
On 3/30/22 18:28, Marek Polacek wrote: When g++ emits warning: overflow in conversion from 'int' to 'char' changes value from '300' to '','' for code like "char c = 300;" it might raise a few eyebrows. With this warning we're not interested in the ASCII representation of the char, only the

Re: [PATCH] c++: implicit guides should inherit class constraints [PR104873]

2022-04-01 Thread Jason Merrill via Gcc-patches
On 4/1/22 11:17, Patrick Palka wrote: An implicit guide already inherits the (rewritten) constraints of the constructor. Thus it seems natural that the guide must also inherit the constraints of the class template, since a constructor's constraints might assume the class's constraints are

[pushed] c++: parse trivial DMI immediately [PR96645]

2022-03-30 Thread Jason Merrill via Gcc-patches
The recent change to reject __is_constructible for nested classes with DMI is breaking some code loudly that was previously only silently broken. Let's allow simple cases by immediately parsing DMI that do no name lookup; then being in complete class scope makes no difference. Tested

Re: [PATCH] c++: ICE with failed __is_constructible constraint [PR100474]

2022-03-30 Thread Jason Merrill via Gcc-patches
On 3/30/22 08:56, Patrick Palka wrote: On Tue, 29 Mar 2022, Jason Merrill wrote: On 3/29/22 15:22, Patrick Palka wrote: Here we're crashing when diagnosing a failed __is_constructible constraint because diagnose_atomic_constraint don't know how to diagnose a trait that diagnose_trait_expr

Re: [PATCH] c++: call complete_type after performing auto deduction [PR80351]

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/29/22 02:02, Pokechu22 wrote: On Thu, Mar 24, 2022 at 1:53 PM Jason Merrill wrote: Thanks! For future reference, the patch doesn't apply easily because gmail wrapped lines; for sending patches via gmail you'll need to use attachments. Or you can use another MUA, or git send-email. This

Re: [PATCH] c-family: ICE with -Wconversion and A ?: B [PR101030]

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/29/22 16:59, Marek Polacek wrote: On Tue, Mar 29, 2022 at 04:53:21PM -0400, Marek Polacek via Gcc-patches wrote: This patch fixes a crash in conversion_warning on a null expression. It is null because the testcase uses the GNU A ?: B extension. We could also use op0 instead of op1 in this

Re: [PATCH] c-family: ICE with -Wconversion and A ?: B [PR101030]

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/29/22 16:53, Marek Polacek wrote: This patch fixes a crash in conversion_warning on a null expression. It is null because the testcase uses the GNU A ?: B extension. We could also use op0 instead of op1 in this case, but it doesn't seem to be necessary. I wonder why we don't represent

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

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/25/22 18:16, Marek Polacek wrote: 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

Re: [PATCH v3] c++: warn on undefined casts from Base to Derived ref/ptr [PR96765]

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/27/22 08:37, Zhao Wei Liew wrote: On Fri, 25 Mar 2022 at 05:58, Jason Merrill wrote: + if (current_function_decl + && (DECL_CONSTRUCTOR_P (current_function_decl) + || DECL_DESTRUCTOR_P (current_function_decl)) + && TREE_CODE (expr) == NOP_EXPR +

Re: [PATCH] c++: Fox template-introduction tentative parsing in class bodies clear colon_corrects_to_scope_p [PR105061]

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/29/22 04:05, Jakub Jelinek wrote: Hi! The concepts support (in particular template introductions from concepts TS) broke the following testcase, valid unnamed bitfields with dependent types (or even just typedefs) were diagnosed as typos (: instead of correct ::) in template introduction

Re: [PATCH] c++: ICE with failed __is_constructible constraint [PR100474]

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/29/22 15:22, Patrick Palka wrote: Here we're crashing when diagnosing a failed __is_constructible constraint because diagnose_atomic_constraint don't know how to diagnose a trait that diagnose_trait_expr doesn't specifically handle. This patch fixes this by falling through to the default

Re: [PATCH] testsuite: Allow setting gpp_std_list in configuration files

2022-03-29 Thread Jason Merrill via Gcc-patches
On 3/29/22 08:43, Jonathan Wakely wrote: Tested powerpc64le-linux, OK for trunk? OK. -- >8 -- This allows the gpp_std_list variable to be set in ~/.dejagnurc instead of using the GXX_TESTSUITE_STDS environment variable. This is consistent with how other defaults such as tool_timeout can be

Re: [PATCH] c++: reject concept w/ multiple tparm lists [PR105067]

2022-03-28 Thread Jason Merrill via Gcc-patches
On 3/28/22 09:28, Patrick Palka wrote: We weren't rejecting a concept declared with multiple template parameter lists. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? OK. PR c++/105067 gcc/cp/ChangeLog: * pt.cc (finish_concept_definition):

Re: [PATCH] c++: ICE during constrained template friend matching [PR105064]

2022-03-28 Thread Jason Merrill via Gcc-patches
On 3/28/22 09:29, Patrick Palka wrote: Here during declaration matching for the two constrained template friends, we crash from maybe_substitute_reqs_for because the second friend doesn't yet have DECL_TEMPLATE_INFO set (we're being called indirectly from push_template_decl). As far as I can

[pushed] c++: hash table ICE with variadic alias [PR105003]

2022-03-28 Thread Jason Merrill via Gcc-patches
For PR104008 we thought it might be enough to keep strip_typedefs from removing this alias template specialization, but this PR demonstrates that other parts of the compiler also need to know to consider it dependent. So, this patch changes complex_alias_template_p to no longer consider template

[pushed] c++: low -faligned-new [PR102071]

2022-03-28 Thread Jason Merrill via Gcc-patches
This test ICEd after the constexpr new patch (r10-3661) because alloc_call had a NOP_EXPR around it; fixed by moving the NOP_EXPR to alloc_expr. And the PR pointed out that the size_t cookie might need more alignment, so I fix that as well. Tested x86_64-pc-linux-gnu, applying to trunk.

[pushed] c++: visibility of local extern [PR103291]

2022-03-28 Thread Jason Merrill via Gcc-patches
When setting up the hidden namespace-scope decl for a local extern, we also need to set its visibility. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/103291 gcc/cp/ChangeLog: * name-lookup.cc (push_local_extern_decl_alias): Call determine_visibility.

[pushed] c++: CTAD and member alias template [PR102123]

2022-03-28 Thread Jason Merrill via Gcc-patches
When building a deduction guide from the Test constructor, we need to rewrite the use of _dummy into a dependent reference, i.e. Test::template _dummy. We were using SCOPE_REF for both type and non-type templates; we need to use UNBOUND_CLASS_TEMPLATE for type templates. Tested

[pushed] c++: member alias declaration [PR103968]

2022-03-28 Thread Jason Merrill via Gcc-patches
Here, we were wrongly thinking that (const Options&)Widget::c_options is not value-dependent because neither the type nor the (value of) c_options are dependent, but since we're binding it to a reference we also need to consider that it has a value-dependent address. Tested x86_64-pc-linux-gnu,

[pushed] c++: CTAD and member function references [PR103943]

2022-03-28 Thread Jason Merrill via Gcc-patches
More quirks of rewriting member references to dependent references for CTAD. A reference to a member of dependent scope is definitely dependent. And since r11-7044, tsubst_baselink builds a SCOPE_REF, so tsubst_qualified_id should just use it. Tested x86_64-pc-linux-gnu, applying to trunk.

[pushed] c++: missing aggregate base ctor [PR102045]

2022-03-28 Thread Jason Merrill via Gcc-patches
When make_base_init_ok changes a call to a complete constructor into a call to a base constructor, we were never marking the base ctor as used, so it didn't get emitted. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102045 gcc/cp/ChangeLog: * call.cc

[pushed] c++: mangling union{1} in template [PR104847]

2022-03-28 Thread Jason Merrill via Gcc-patches
My implementation of union non-type template arguments in r11-2016 broke braced casts of union type, because they are still in syntactic (undigested) form. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/104847 gcc/cp/ChangeLog: * mangle.cc (write_expression): Don't write

[pushed] c++: ICE with alias in pack expansion [PR103769]

2022-03-28 Thread Jason Merrill via Gcc-patches
This was breaking because when we stripped the 't' typedef in s...> to be s, the TYPE_MAIN_VARIANT of "Args..." was still "t...", because type pack expansions are treated as types. Fixed by using the right function to copy a "type". Tested x86_64-pc-linux-gnu, applying to trunk. PR

Re: [PATCH RFC] Fix ICE due to shared BLOCK node in coroutine generation [PR103328]

2022-03-26 Thread Jason Merrill via Gcc-patches
On 3/17/22 07:37, Benno Evers via Gcc-patches wrote: The coroutine transformation moves the original function body into a newly created actor function, but the block of the `current_binding_level` still points into the original function, causing the block to be shared between the two functions

Re: [PATCH] c++: Fix up __builtin_{bit_cast,convertvector} parsing

2022-03-25 Thread Jason Merrill via Gcc-patches
On 3/25/22 11:58, Jakub Jelinek wrote: Hi! Jonathan reported on IRC that we don't parse __builtin_bit_cast (type, val).field etc. The problem is that for these 2 builtins we return from cp_parser_postfix_expression instead of setting postfix_expression to the cp_build_* value and falling

Re: [PATCH] c++: ICE when building builtin operator->* set [PR103455]

2022-03-25 Thread Jason Merrill via Gcc-patches
On 3/25/22 14:09, Patrick Palka wrote: When constructing the builtin operator->* candidate set according to the available conversion functions for each operand type, we end up considering a candidate with C1=T (a TEMPLATE_TYPE_PARM) and C2=F, during which we crash from lookup_base because

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

2022-03-25 Thread Jason Merrill via Gcc-patches
On 3/25/22 12:07, Patrick Palka 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: constexpr-105050.C:8:3: error:

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

2022-03-25 Thread Jason Merrill via Gcc-patches
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 || attributes == error_mark_node)

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

2022-03-25 Thread Jason Merrill via Gcc-patches
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: On 3/24/22 11:49, Marek Polacek wrote: I started looking into this PR because in GCC 4.9

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

2022-03-25 Thread Jason Merrill via Gcc-patches
On 3/17/22 06:35, Jonathan Wakely via Gcc-patches wrote: On 15/03/22 14:36 -0600, Martin Sebor wrote: On 3/15/22 10:40, Siddhesh Poyarekar wrote: On 15/03/2022 21:09, Martin Sebor wrote: The strncmp function takes arrays as arguments (not necessarily strings).? The main purpose of the

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

2022-03-24 Thread Jason Merrill via Gcc-patches
On 3/24/22 17:53, Marek Polacek wrote: 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

Re: [PATCH v7] c++: Add diagnostic when operator= is used as truth cond [PR25689]

2022-03-24 Thread Jason Merrill via Gcc-patches
On 3/13/22 19:43, Zhao Wei Liew wrote: On Sat, 12 Mar 2022 at 06:15, Jason Merrill wrote: It looks good, but unfortunately regresses some other warning tests, such as Wnonnull5.C. Please remember to run the regression tests before sending a patch (https://gcc.gnu.org/contribute.html#testing).

Re: [PATCH v2] c++/96765: warn when casting Base* to Derived* in Base ctor/dtor

2022-03-24 Thread Jason Merrill via Gcc-patches
On 3/17/22 01:51, Zhao Wei Liew wrote: Thanks for the review. I've tested and uploaded a new patch v2 with the requested changes. On Thu, 17 Mar 2022 at 09:20, Jason Merrill wrote: On 3/14/22 02:36, Zhao Wei Liew via Gcc-patches wrote: This patch adds a warning when casting "this" to

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

2022-03-24 Thread Jason Merrill via Gcc-patches
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 detect the invalid struct alignas(void) S{}; but I broke it in r210262. It's

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

2022-03-24 Thread Jason Merrill via Gcc-patches
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 (&)[]), which can still be distinguished by the

Re: [PATCH] c++: call complete_type after performing auto deduction [PR80351]

2022-03-24 Thread Jason Merrill via Gcc-patches
On 3/23/22 21:01, Pokechu22 via Gcc-patches wrote: 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 time (this happened when auto deduces to an initializer_list). cp_apply_type_quals_to_decl removes the

[pushed] c++: delayed parse DMI [PR96645]

2022-03-24 Thread Jason Merrill via Gcc-patches
With the changes for PR81359 and PR88368 to make get_nsdmi errors be treated as substitution failure, we have the problem that if we check std::is_default_constructible for a complete class that still has unparsed default member initializers, we get an answer (false) that will be wrong once the

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

2022-03-24 Thread Jason Merrill via Gcc-patches
On 3/24/22 13:03, Marek Polacek wrote: 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

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

2022-03-24 Thread Jason Merrill via Gcc-patches
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 code in C++: [dcl.align]/3: "An alignment-specifier of the form alignas(type-id) has the same

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

2022-03-24 Thread Jason Merrill via Gcc-patches
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 be stored, and that revealed a crash where a template code (here,

Re: [PATCH] c++: missing SFINAE for consteval calls [PR104620]

2022-03-24 Thread Jason Merrill via Gcc-patches
On 3/24/22 10:32, Patrick Palka wrote: Here we weren't respecting SFINAE when evaluating a substituted call to a consteval function, which caused us to reject the new testcase below. This patch fixes this by making build_over_call use the SFINAE-friendly version of cxx_constant_value. This

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

2022-03-24 Thread Jason Merrill via Gcc-patches
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 where it hits gcc_unreachable (). The history of

Re: [PATCH] c++: extern thread_local declarations in constexpr [PR104994]

2022-03-23 Thread Jason Merrill via Gcc-patches
On 3/22/22 03:35, Jakub Jelinek wrote: Hi! C++14 to C++20 apparently should allow extern thread_local declarations in constexpr functions, however useless they are there (because accessing such vars is not valid in a constant expression, perhaps sizeof/decltype). P2242 changed that for C++23 to

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

2022-03-23 Thread Jason Merrill via Gcc-patches
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 was introduced in r181478, but it did the wrong thing, whereupon it was turned into

Re: [PATCH] c++: alias template arguments are evaluated [PR101906]

2022-03-23 Thread Jason Merrill via Gcc-patches
On 3/22/22 14:31, Patrick Palka wrote: On Tue, 22 Mar 2022, Patrick Palka wrote: Here we're neglecting to clear cp_unevaluated_operand when substituting into the arguments of the alias template-id skip<(T(), 0), T> with T=A, which means cp_unevaluated_operand remains set during mark_used for

Re: [pushed] c++: designated init and aggregate members [PR102337]

2022-03-23 Thread Jason Merrill via Gcc-patches
On 3/22/22 10:19, Patrick Palka wrote: On Mon, 21 Mar 2022, Jason Merrill via Gcc-patches wrote: Our C++20 designated initializer handling was broken with members of class type; we would find the relevant member and then try to find a member of the member with the same name. Or we would

Re: [pushed] c++: using from enclosing class template [PR105006]

2022-03-23 Thread Jason Merrill via Gcc-patches
On 3/23/22 10:29, Patrick Palka wrote: I wonder if it'd be worthwhile to also test dependent_type_p (scope) here here to avoid iterating over the lookup set when it can't possibly contain a dependent using-decl. Good thought: From b1005f60c17d693e9fbc38a9481b3cd896d26785 Mon Sep 17 00:00:00

[pushed] c++: using from enclosing class template [PR105006]

2022-03-23 Thread Jason Merrill via Gcc-patches
Here, DECL_DEPENDENT_P was false for the second using because Row is "the current instantiation", so lookup succeeds. But since Row itself has a dependent using-decl for operator(), the set of functions imported by the second using is dependent, so we should set the flag. Tested

[pushed] c++: initialized array of vla [PR58646]

2022-03-21 Thread Jason Merrill via Gcc-patches
We went into build_vec_init because we're dealing with a VLA, but then build_vec_init thought it was safe to just build an INIT_EXPR because the outer dimension is constant. Nope. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * init.cc (build_vec_init): Check for vla

[pushed] c++: designated init and aggregate members [PR102337]

2022-03-21 Thread Jason Merrill via Gcc-patches
Our C++20 designated initializer handling was broken with members of class type; we would find the relevant member and then try to find a member of the member with the same name. Or we would sometimes ignore the designator entirely. The former problem is fixed by the change to

[pushed] c++: designator and anon struct [PR101767]

2022-03-21 Thread Jason Merrill via Gcc-patches
We found .x in the anonymous struct, but then didn't find .y there; we should decide that means we're done with the struct rather than that the code is wrong. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/101767 gcc/cp/ChangeLog: * decl.cc (reshape_init_class): Back out

Re: [PATCH] Fix PR 101515 (ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128)

2022-03-18 Thread Jason Merrill via Gcc-patches
On 3/18/22 14:47, Jakub Jelinek wrote: On Fri, Mar 18, 2022 at 02:27:30PM -0400, Jason Merrill wrote: That is also correct C++ expression, but user probably has no idea what is present at offset 32 into the variable. Of course if there is a type match and not any kind of type punning, it will

Re: [PATCH] Fix PR 101515 (ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128)

2022-03-18 Thread Jason Merrill via Gcc-patches
On 3/18/22 14:20, Jakub Jelinek wrote: On Fri, Mar 18, 2022 at 01:35:53PM -0400, Jason Merrill wrote: On 3/15/22 12:06, Jakub Jelinek wrote: On Tue, Mar 15, 2022 at 11:57:22AM -0400, Jason Merrill wrote: The intent of r11-6729 is that it prints something that helps user to figure out what

[pushed] c++: using lookup within class defn [PR104476]

2022-03-18 Thread Jason Merrill via Gcc-patches
The problem in both PR92918 and PR104476 is overloading of base member functions brought in by 'using' with direct member functions during parsing of the class body. To this point they've had a troublesome coexistence which was resolved by set_class_bindings when the class is complete, but we

Re: [PATCH] Fix PR 101515 (ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128)

2022-03-18 Thread Jason Merrill via Gcc-patches
On 3/15/22 12:06, Jakub Jelinek wrote: On Tue, Mar 15, 2022 at 11:57:22AM -0400, Jason Merrill wrote: The intent of r11-6729 is that it prints something that helps user to figure out what exactly is being accessed. When we find a unique non-static data member that is being accessed, even when

Re: [PATCH] c++, v2: Fix up constexpr evaluation of new with zero sized types [PR104568]

2022-03-18 Thread Jason Merrill via Gcc-patches
On 3/16/22 12:55, Jakub Jelinek wrote: On Tue, Mar 15, 2022 at 04:19:05PM -0400, Jason Merrill wrote: But if you strongly prefer it that way, I can do that. Note, probably not 3 new args but 4, depends on whether we could turn all those cases where the tree arg0 = CALL_EXPR_ARG (oldop, 0); is

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

2022-03-18 Thread Jason Merrill via Gcc-patches
On 3/16/22 17:18, Marek Polacek wrote: 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

Re: [PATCH] c++/96765: warn when casting "this" to Derived* in Base ctor/dtor

2022-03-16 Thread Jason Merrill via Gcc-patches
On 3/14/22 02:36, Zhao Wei Liew via Gcc-patches wrote: This patch adds a warning when casting "this" to Derived* in the Base class constructor and destructor. I've added the warning under the -Wextra flag as I can't find a more appropriate flag for it. It's generally best to add a new warning

Re: [PATCH] c++: further lookup_member simplification

2022-03-15 Thread Jason Merrill via Gcc-patches
On 3/15/22 13:18, Patrick Palka wrote: As a followup to r12-7656-gffe9c0a0d3564a, this minor patch condenses the handling of ambiguity and access w.r.t. the value of 'protect' so that it more clearly matches the function comment. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look

Re: [PATCH] c++: fold calls to std::move/forward [PR96780]

2022-03-15 Thread Jason Merrill via Gcc-patches
On 3/15/22 13:09, Patrick Palka wrote: On Tue, 15 Mar 2022, Jason Merrill wrote: On 3/15/22 10:03, Patrick Palka wrote: On Mon, 14 Mar 2022, Jason Merrill wrote: On 3/14/22 13:13, Patrick Palka wrote: On Fri, 11 Mar 2022, Jason Merrill wrote: On 3/10/22 11:27, Patrick Palka wrote: On

Re: [PATCH] c++: Fix up constexpr evaluation of new with zero sized types [PR104568]

2022-03-15 Thread Jason Merrill via Gcc-patches
On 3/15/22 07:44, Jakub Jelinek wrote: On Fri, Mar 11, 2022 at 11:28:09PM -0500, Jason Merrill wrote: @@ -7264,9 +7265,66 @@ cxx_eval_constant_expression (const cons DECL_NAME (var) = (DECL_NAME (var) == heap_uninit_identifier ? heap_identifier :

Re: [PATCH] Fix PR 101515 (ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128)

2022-03-15 Thread Jason Merrill via Gcc-patches
On 3/15/22 08:32, Jakub Jelinek wrote: On Fri, Feb 11, 2022 at 12:27:49PM -0500, Jason Merrill wrote: Yes, that's what the above code would correctly do if TYPE were the pointer-to-method type. It's wrong for this case because TYPE is unrelated to TREE_TYPE (field). I think the problem is

Re: [PATCH] c++: fold calls to std::move/forward [PR96780]

2022-03-15 Thread Jason Merrill via Gcc-patches
On 3/15/22 10:03, Patrick Palka wrote: On Mon, 14 Mar 2022, Jason Merrill wrote: On 3/14/22 13:13, Patrick Palka wrote: On Fri, 11 Mar 2022, Jason Merrill wrote: On 3/10/22 11:27, Patrick Palka wrote: On Wed, 9 Mar 2022, Jason Merrill wrote: On 3/1/22 18:08, Patrick Palka wrote: A

Re: [PATCH] c++: Fix up cp_parser_skip_to_pragma_eol [PR104623]

2022-03-14 Thread Jason Merrill via Gcc-patches
On 3/12/22 14:22, Jakub Jelinek wrote: Hi! We ICE on the following testcase, because we tentatively parse it multiple times and the erroneous attribute syntax results in cp_parser_skip_to_end_of_statement, which when seeing CPP_PRAGMA (can be any deferred one, OpenMP/OpenACC/ivdep etc.) it

Re: [PATCH] c++: fold calls to std::move/forward [PR96780]

2022-03-14 Thread Jason Merrill via Gcc-patches
On 3/14/22 13:13, Patrick Palka wrote: On Fri, 11 Mar 2022, Jason Merrill wrote: On 3/10/22 11:27, Patrick Palka wrote: On Wed, 9 Mar 2022, Jason Merrill wrote: On 3/1/22 18:08, Patrick Palka wrote: A well-formed call to std::move/forward is equivalent to a cast, but the former being a

Re: [PATCH] c++: extraneous access error with ambiguous lookup [PR103177]

2022-03-14 Thread Jason Merrill via Gcc-patches
On 3/14/22 13:24, Patrick Palka wrote: When a lookup is ambiguous, lookup_member still attempts to check access of the first member found before diagnosing the ambiguity and erroring out, which may cause us to issue an extraneous access error in case of ambiguous lookup as in the testcase below

Re: [PATCH] c++: Reject __builtin_clear_padding on non-trivially-copyable types with one exception [PR102586]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 2/11/22 14:55, Jakub Jelinek wrote: Hi! As mentioned by Jason in the PR, non-trivially-copyable types (or non-POD for purposes of layout?) types can be base classes of derived classes in which the padding in those non-trivially-copyable types can be redused for some real data members or even

Re: [PATCH] c++: Fix up constexpr evaluation of new with zero sized types [PR104568]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 2/21/22 04:25, Jakub Jelinek wrote: Hi! The new expression constant expression evaluation right now tries to deduce how many elts the array it uses for the heap or heap [] vars should have (or how many elts should its trailing array have if it has cookie at the start). As new is lowered at

Re: [PATCH] c++: fold calls to std::move/forward [PR96780]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 3/10/22 11:27, Patrick Palka wrote: On Wed, 9 Mar 2022, Jason Merrill wrote: On 3/1/22 18:08, Patrick Palka wrote: A well-formed call to std::move/forward is equivalent to a cast, but the former being a function call means it comes with bloated debug info, which persists even after the

Re: [PATCH] c++: naming a dependently-scoped template for CTAD [PR104641]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 3/10/22 12:41, Patrick Palka wrote: On Wed, 9 Mar 2022, Jason Merrill wrote: On 3/9/22 10:39, Patrick Palka wrote: On Tue, 8 Mar 2022, Jason Merrill wrote: On 3/2/22 14:32, Patrick Palka wrote: In order to be able to perform CTAD for a dependently-scoped template such as A::B in the

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

2022-03-11 Thread Jason Merrill via Gcc-patches
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*. It happens because we're performing build_vec_init while processing a

Re: [PATCH] c++: Fix ICE with bad conversion shortcutting [PR104622]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 3/10/22 15:30, Patrick Palka wrote: When shortcutting bad conversions during overload resolution, we assume argument conversions get computed in sequential order and that therefore we just need to inspect the last conversion in order to determine if _any_ conversion is missing. But this

Re: [PATCH] c++: return-type-req in constraint using only outer tparms [PR104527]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 3/10/22 16:57, Patrick Palka wrote: On Thu, 10 Mar 2022, Jason Merrill wrote: On 2/16/22 15:56, Patrick Palka wrote: On Tue, 15 Feb 2022, Jason Merrill wrote: On 2/14/22 11:32, Patrick Palka wrote: Here the template context for the atomic constraint has two levels of template

Re: [PATCH] c++: Fix ICE with non-constant satisfaction [PR98644]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 3/11/22 11:46, Patrick Palka wrote: On Thu, 10 Mar 2022, Jason Merrill wrote: On 3/1/22 00:10, Patrick Palka wrote: On Tue, 19 Jan 2021, Jason Merrill wrote: On 1/13/21 12:05 PM, Patrick Palka wrote: In the below testcase, the expression of the atomic constraint after substitution is

Re: [PATCH v7] c++: Add diagnostic when operator= is used as truth cond [PR25689]

2022-03-11 Thread Jason Merrill via Gcc-patches
On 2/17/22 23:30, Zhao Wei Liew wrote: On Fri, 18 Feb 2022 at 08:32, Zhao Wei Liew wrote: +/* Test non-empty class */ +void f2(B b1, B b2) +{ + if (b1 = 0); /* { dg-warning "suggest parentheses" } */ + if (b1 = 0.); /* { dg-warning "suggest parentheses" } */ + if (b1 = b2); /* { dg-warning

Re: [PATCH] c++: Fix ICE with non-constant satisfaction [PR98644]

2022-03-10 Thread Jason Merrill via Gcc-patches
On 3/1/22 00:10, Patrick Palka wrote: On Tue, 19 Jan 2021, Jason Merrill wrote: On 1/13/21 12:05 PM, Patrick Palka wrote: In the below testcase, the expression of the atomic constraint after substitution is (int *) NON_LVALUE_EXPR <1> != 0B which is not a C++ constant expression, but its

Re: [PATCH] c++: improve location of fold expressions

2022-03-10 Thread Jason Merrill via Gcc-patches
On 3/1/22 00:14, Patrick Palka wrote: This improves diagnostic quality for unsatisfied atomic constraints that consist of a fold expression, e.g. in concepts/diagnostics3.C: .../diagnostic3.C:10:22: note: the expression ‘(foo && ...) [with Ts = {int, char}]’ evaluated to ‘false’ 10 |

Re: [PATCH] c++: return-type-req in constraint using only outer tparms [PR104527]

2022-03-10 Thread Jason Merrill via Gcc-patches
On 2/16/22 15:56, Patrick Palka wrote: On Tue, 15 Feb 2022, Jason Merrill wrote: On 2/14/22 11:32, Patrick Palka wrote: Here the template context for the atomic constraint has two levels of template arguments, but since it depends only on the innermost argument T we use a single-level

Re: [PATCH] call mark_dfs_back_edges() before testing EDGE_DFS_BACK [PR104761]

2022-03-10 Thread Jason Merrill via Gcc-patches
On 3/2/22 19:15, Martin Sebor wrote: The -Wdangling-pointer code tests the EDGE_DFS_BACK but the pass never calls the mark_dfs_back_edges() function that initializes the bit (I didn't know about it).  As a result the bit is not set when expected, which can cause false positives under the right

Re: [PATCH] c++: allow variadic operator[] for C++23 [PR103460]

2022-03-10 Thread Jason Merrill via Gcc-patches
On 3/10/22 04:34, Jakub Jelinek wrote: Hi! wg21.link/p2128 removed "with exactly one parameter" from over.sub section. grok_op_properties has for that the last 2 lines in: case OVL_OP_FLAG_BINARY: if (arity != 2) { if (operator_code == ARRAY_REF && cxx_dialect

Re: [PATCH] PR c++/84964: Middle-end patch to expand_call for ICE after sorry.

2022-03-10 Thread Jason Merrill via Gcc-patches
On 2/28/22 03:52, Roger Sayle wrote: This patch resolves PR c++/84964 which is an ICE in the middle-end after emitting a "sorry, unimplemented" message, and is a regression from earlier releases of GCC. This issue is that after encountering a function call requiring an unreasonable amount of

Re: [PATCH] c++: PR c++/95999: Improved error recovery in enumeration lists.

2022-03-09 Thread Jason Merrill via Gcc-patches
On 2/21/22 08:17, Roger Sayle wrote: This patch resolves PR c++/95999 which is an ICE-after-error regression in the g++ front-end. When parsing an enumerator list, the C++ parser assumes that cp_parser_constant_expression always returns either an INTEGER_CST or error_mark_node, but in testcase

Re: [C++ PATCH] PR c++/96442: Another improved error recovery in enumerations.

2022-03-09 Thread Jason Merrill via Gcc-patches
On 2/22/22 08:02, Roger Sayle wrote: This patch resolves PR c++/96442, another ICE-after-error regression. In this case, invalid code attempts to use a non-integral type as the underlying type for an enumeration (a record_type in the example given in the bugzilla PR), for which the parser emits

Re: [PATCH] PR c++/39751: ICE-on-invalid parsing regression.

2022-03-09 Thread Jason Merrill via Gcc-patches
On 2/26/22 19:55, Roger Sayle wrote: This is a fix for PR c++/39751 which is an ICE-on-invalid regression in the C++ parser after encountering the end of file. The one line change is to check that the tokens cached in DECL_PENDING_INLINE_INFO haven't been purged before processing them in

Re: [PATCH] c++: naming a dependently-scoped template for CTAD [PR104641]

2022-03-09 Thread Jason Merrill via Gcc-patches
On 3/9/22 10:39, Patrick Palka wrote: On Tue, 8 Mar 2022, Jason Merrill wrote: On 3/2/22 14:32, Patrick Palka wrote: In order to be able to perform CTAD for a dependently-scoped template such as A::B in the testcase below, we need to permit a typename-specifier to resolve to a template as per

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

2022-03-09 Thread Jason Merrill via Gcc-patches
On 3/9/22 11:22, Marek Polacek wrote: 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

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

2022-03-09 Thread Jason Merrill via Gcc-patches
On 3/9/22 14:09, Marek Polacek wrote: 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

Re: [C++ PATCH] PR c++/96437: ICE-on-invalid-code error recovery.

2022-03-09 Thread Jason Merrill via Gcc-patches
On 3/9/22 14:35, Roger Sayle wrote: Hi Jason, Very many thanks for your reviews/approvals of these ICE-on-invalid-code fixes. + if (TREE_VALUE (new_parm) != error_mark_node) +DECL_VIRTUAL_P (TREE_VALUE (new_parm)) = true; Hmm, I wonder about returning early if there was an error, but

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

2022-03-09 Thread Jason Merrill via Gcc-patches
On 3/1/22 17:12, Marek Polacek wrote: 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

Re: [PATCH] c++: fold calls to std::move/forward [PR96780]

2022-03-09 Thread Jason Merrill via Gcc-patches
On 3/1/22 18:08, Patrick Palka wrote: A well-formed call to std::move/forward is equivalent to a cast, but the former being a function call means it comes with bloated debug info, which persists even after the call has been inlined away, for an operation that is never interesting to debug. This

Re: [PATCH] c, c++, c-family: -Wshift-negative-value and -Wshift-overflow* tweaks for -fwrapv and C++20+ [PR104711]

2022-03-08 Thread Jason Merrill via Gcc-patches
On 3/2/22 05:22, Jakub Jelinek wrote: Hi! As mentioned in the PR, different standards have different definition on what is an UB left shift. They all agree on out of bounds (including negative) shift count. The rules used by ubsan are: C99-C2x ((unsigned) x >> (uprecm1 - y)) != 0 then UB

Re: [PATCH] c++: naming a dependently-scoped template for CTAD [PR104641]

2022-03-08 Thread Jason Merrill via Gcc-patches
On 3/2/22 14:32, Patrick Palka wrote: In order to be able to perform CTAD for a dependently-scoped template such as A::B in the testcase below, we need to permit a typename-specifier to resolve to a template as per [dcl.type.simple]/2, at least when it appears in a CTAD-enabled context. This

Re: [PATCH] c++: detecting copy-init context during CTAD [PR102137]

2022-03-08 Thread Jason Merrill via Gcc-patches
On 3/8/22 17:17, Patrick Palka wrote: On Tue, 8 Mar 2022, Jason Merrill wrote: On 3/8/22 14:38, Patrick Palka wrote: On Tue, 8 Mar 2022, Jason Merrill wrote: On 3/8/22 11:36, Patrick Palka wrote: On Mon, 7 Mar 2022, Jason Merrill wrote: On 3/7/22 10:47, Patrick Palka wrote: On Fri, 4

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

2022-03-08 Thread Jason Merrill via Gcc-patches
On 3/8/22 17:14, Marek Polacek wrote: 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

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