Re: [PATCH] c++: adc_unify deduction with constrained auto [PR99365]

2021-03-04 Thread Patrick Palka via Gcc-patches
On Thu, 4 Mar 2021, Patrick Palka wrote: > My recent r11-7454 changed the way do_auto_deduction handles constrained > placeholders during template argument deduction (context == adc_unify) > when processing_template_decl != 0. > > Before the patch, when processing_template_dec

Re: [PATCH] c++: adc_unify deduction with constrained auto [PR99365]

2021-03-04 Thread Patrick Palka via Gcc-patches
On Thu, 4 Mar 2021, Jason Merrill wrote: > On 3/4/21 11:32 AM, Patrick Palka wrote: > > On Thu, 4 Mar 2021, Patrick Palka wrote: > > > > > My recent r11-7454 changed the way do_auto_deduction handles constrained > > > placeholders during template argumen

Re: [PATCH] c++: adc_unify deduction with constrained auto [PR99365]

2021-03-04 Thread Patrick Palka via Gcc-patches
On Thu, 4 Mar 2021, Patrick Palka wrote: > On Thu, 4 Mar 2021, Jason Merrill wrote: > > > On 3/4/21 11:32 AM, Patrick Palka wrote: > > > On Thu, 4 Mar 2021, Patrick Palka wrote: > > > > > > > My recent r11-7454 changed the way do_auto_deduction handl

Re: [PATCH] c++: adc_unify deduction with constrained auto [PR99365]

2021-03-04 Thread Patrick Palka via Gcc-patches
On Thu, 4 Mar 2021, Patrick Palka wrote: > On Thu, 4 Mar 2021, Patrick Palka wrote: > > > On Thu, 4 Mar 2021, Jason Merrill wrote: > > > > > On 3/4/21 11:32 AM, Patrick Palka wrote: > > > > On Thu, 4 Mar 2021, Patrick Palka wrote: > > >

[PATCH] c++: Fix tsubsting member variable template-id [PR96330]

2021-03-05 Thread Patrick Palka via Gcc-patches
This makes tsubst_copy appropriately handle a variable template-id, which in turn fixes tsubsting a COMPONENT_REF whose member operand is known at parse time to be a variable template-id, as in the initialization of 'x' in the first testcase. Previously, we rejected this testcase with the error "f

[PATCH] c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

2021-03-05 Thread Patrick Palka via Gcc-patches
Here, during cxx_eval_increment_expression (with lval=false) of ++__first where __first is &"mystr"[0], we correctly update __first to &"mystr"[1] but we end up returning &"mystr"[0] + 1 instead of &"mystr"[1]. This unreduced return value inhibits other pointer arithmetic folding during later cons

Re: [PATCH] c++: adc_unify deduction with constrained auto [PR99365]

2021-03-05 Thread Patrick Palka via Gcc-patches
On Fri, 5 Mar 2021, Jason Merrill wrote: > On 3/4/21 9:55 PM, Patrick Palka wrote: > > On Thu, 4 Mar 2021, Patrick Palka wrote: > > > > > On Thu, 4 Mar 2021, Patrick Palka wrote: > > > > > > > On Thu, 4 Mar 2021, Jason Merrill wrote: > > >

Re: [PATCH] c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

2021-03-05 Thread Patrick Palka via Gcc-patches
On Fri, 5 Mar 2021, Jason Merrill wrote: > On 3/5/21 1:05 PM, Patrick Palka wrote: > > Here, during cxx_eval_increment_expression (with lval=false) of > > ++__first where __first is &"mystr"[0], we correctly update __first > > to &"mystr"[1] b

[PATCH] c++: constexpr std::construct_at on empty field [PR101663]

2021-08-03 Thread Patrick Palka via Gcc-patches
Here during constexpr evaluation of std::construct_at(&a._M_value) we find ourselves in cxx_eval_store_expression where the target object is 'a._M_value' and the initializer is {}. Since _M_value is an empty [[no_unique_address]] member we don't create a sub-CONSTRUCTOR for it, so we end up in

[PATCH] c++: parameterized requires-expr as default argument [PR101725]

2021-08-03 Thread Patrick Palka via Gcc-patches
Here we're rejecting the default template argument requires (T t) { x(t); } because we consider the 't' in the requirement to be a local variable (according to local_variable_p), and we generally forbid local variables from appearing inside template arguments. We can perhaps fix this by giving

[PATCH] c++: most vexing parse and braced CTAD [PR89062]

2021-08-09 Thread Patrick Palka via Gcc-patches
Here grokdeclarator is emitting the error error: class template placeholder ‘Foo’ not permitted in this context during the tentative (and ultimately futile) parse of 'x' as a function declaration. This happens because when parsing 'Foo{1}', cp_parser_parameter_declaration yields an parameter d

[PATCH] c++: recognize class-scope non-template dguides [PR79501]

2021-08-09 Thread Patrick Palka via Gcc-patches
It looks like we still don't recognize class-scope non-template deduction guides even after r12-2260. This is because deduction guides are handled in cp_parser_init_declarator after calling cp_parser_declarator, but in the class-scope non-template case we call cp_parser_declarator directly from c

Re: [PATCH] c++: Improve memory usage of subsumption [PR100828]

2021-08-09 Thread Patrick Palka via Gcc-patches
On Wed, Jul 28, 2021 at 4:42 PM Jason Merrill wrote: > > On 7/19/21 6:05 PM, Patrick Palka wrote: > > Constraint subsumption is implemented in two steps. The first step > > computes the disjunctive (or conjunctive) normal form of one of the > > constraints, and the second

Re: [PATCH] c++: Improve memory usage of subsumption [PR100828]

2021-08-11 Thread Patrick Palka via Gcc-patches
On Wed, 11 Aug 2021, Jason Merrill wrote: > On 8/9/21 5:07 PM, Patrick Palka wrote: > > On Wed, Jul 28, 2021 at 4:42 PM Jason Merrill wrote: > > > > > > On 7/19/21 6:05 PM, Patrick Palka wrote: > > > > Constraint subsumption is implemented in two step

Re: [PATCH] c++: recognize class-scope non-template dguides [PR79501]

2021-08-11 Thread Patrick Palka via Gcc-patches
On Wed, 11 Aug 2021, Jason Merrill wrote: > On 8/9/21 1:16 PM, Patrick Palka wrote: > > It looks like we still don't recognize class-scope non-template > > deduction guides even after r12-2260. This is because deduction guides > > are handled in cp_parser_ini

[PATCH] c++: aggregate CTAD and brace elision [PR101344]

2021-08-16 Thread Patrick Palka via Gcc-patches
During aggregate CTAD, collect_ctor_idx_types always recurses into a sub-CONSTRUCTOR, regardless of whether the corresponding pair of braces was elided in the original initializer. This causes us to reject some completely-braced forms of aggregate CTAD as in the first testcase below, because colle

[PATCH] c++: ignore explicit dguides during NTTP CTAD [PR101883]

2021-08-16 Thread Patrick Palka via Gcc-patches
Since (template) argument passing is a copy-initialization context, we mustn't consider explicit deduction guides when deducing a CTAD placeholder type of an NTTP. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? PR c++/101883 gcc/cp/ChangeLog:

Re: [PATCH] c++: aggregate CTAD and brace elision [PR101344]

2021-08-16 Thread Patrick Palka via Gcc-patches
On Mon, 16 Aug 2021, Marek Polacek wrote: > On Mon, Aug 16, 2021 at 03:06:08PM -0400, Patrick Palka via Gcc-patches wrote: > > During aggregate CTAD, collect_ctor_idx_types always recurses into a > > sub-CONSTRUCTOR, regardless of whether the corresponding pair of braces > &

[PATCH] c++: check arity before deduction w/ explicit targs [PR12672]

2021-08-30 Thread Patrick Palka via Gcc-patches
During overload resolution, when the arity of a function template clearly disagrees with the arity of the call, no specialization of the function template could yield a viable candidate. The deduction routine type_unification_real already notices this situation, but not before it substitutes expli

[PATCH] c++: shortcut bad convs during overload resolution [PR101904]

2021-08-30 Thread Patrick Palka via Gcc-patches
In the context of overload resolution we have the notion of a "bad" argument conversion, which is a conversion that "would be a permitted with a bending of the language standards", and we handle such bad conversions specially. In particular, we rank a bad conversion as better than no conversion bu

[PATCH] c++: parameter pack inside constexpr if [PR101764]

2021-08-30 Thread Patrick Palka via Gcc-patches
Here when partially substituting into the pack expansion, substitution into the constexpr if yields a still-dependent tree, so tsubst_expr returns an IF_STMT with an unsubstituted IF_COND and with IF_STMT_EXTRA_ARGS added to. Hence after partial substitution the pack expansion pattern still refers

Re: [PATCH] c++: premature analysis of requires-expression [PR96410]

2020-09-16 Thread Patrick Palka via Gcc-patches
On Thu, 13 Aug 2020, Jason Merrill wrote: > On 8/13/20 11:21 AM, Patrick Palka wrote: > > On Mon, 10 Aug 2020, Jason Merrill wrote: > > > > > On 8/10/20 2:18 PM, Patrick Palka wrote: > > > > On Mon, 10 Aug 2020, Patrick Palka wrote: > > > > >

Re: [PATCH] c++: premature analysis of requires-expression [PR96410]

2020-09-16 Thread Patrick Palka via Gcc-patches
On Wed, 16 Sep 2020, Jason Merrill wrote: > On 9/16/20 1:34 PM, Patrick Palka wrote: > > On Thu, 13 Aug 2020, Jason Merrill wrote: > > > > > On 8/13/20 11:21 AM, Patrick Palka wrote: > > > > On Mon, 10 Aug 2020, Jason Merrill wrote: > > > > &

[PATCH] c++: std::is_constant_evaluated inside a constraint [PR97051]

2020-09-17 Thread Patrick Palka via Gcc-patches
According to [expr.const]/14, the result of substitution into an atomic constraint is manifestly constant-evaluated; this patch adjusts the call to maybe_constant_value in satisfy_atom to that effect. Tested on x86_64-pc-linux-gnu, and also tested on the cmcstl2 and range-v3 libraries. Does this

Re: [PATCH] c-family: Macro support in -Wmisleading-indentation [PR80076]

2020-09-17 Thread Patrick Palka via Gcc-patches
On Thu, 10 Sep 2020, Patrick Palka wrote: > On Thu, 10 Sep 2020, David Malcolm wrote: > > > On Tue, 2020-07-28 at 20:22 -0400, Patrick Palka wrote: > > > On Tue, 28 Jul 2020, David Malcolm wrote: > > > > > > > On Tue, 2020-07-28 at 15:50 -0400, Pa

[PATCH] c++: Fix self-mapping in map_arguments [PR96531, PR97103]

2020-09-18 Thread Patrick Palka via Gcc-patches
With r10-8077 we stopped passing the argified current_template_parms to normalize_constraint_expression from finish_nested_requirement, and instead tweaked map_arguments to perform a self-mapping of parameters when args is NULL. We're currently not handling parameter packs and BOUND_TEMPLATE_TEMPL

Re: [PATCH] c++: Fix self-mapping in map_arguments [PR96531, PR97103]

2020-09-18 Thread Patrick Palka via Gcc-patches
On Fri, 18 Sep 2020, Jason Merrill wrote: > On 9/18/20 4:07 PM, Patrick Palka wrote: > > With r10-8077 we stopped passing the argified current_template_parms to > > normalize_constraint_expression from finish_nested_requirement, and > > instead tweaked map_arguments to perf

Re: [PATCH] c++: Fix self-mapping in map_arguments [PR96531, PR97103]

2020-09-18 Thread Patrick Palka via Gcc-patches
On Fri, 18 Sep 2020, Patrick Palka wrote: > On Fri, 18 Sep 2020, Jason Merrill wrote: > > > On 9/18/20 4:07 PM, Patrick Palka wrote: > > > With r10-8077 we stopped passing the argified current_template_parms to > > > normalize_constraint_expression from

[PATCH] libstdc++: Fix division by zero in std::sample

2020-09-18 Thread Patrick Palka via Gcc-patches
This fixes a division by zero in the selection-sampling std::__search overload when the input range is empty (and hence __unsampled_sz is 0). Tested on x86_64-pc-linux-gnu. libstdc++-v3/ChangeLog: * include/bits/stl_algo.h (__sample): Exit early when the input range is empty.

[PATCH] libstdc++: Mark some more algorithms constexpr for C++20

2020-09-18 Thread Patrick Palka via Gcc-patches
As per P0202. Tested on x86_64-pc-linux-gnu. libstdc++-v3/ChangeLog: * include/bits/stl_algo.h (for_each_n): Mark constexpr for C++20. (search): Likewise for the overload that takes a searcher. * testsuite/25_algorithms/for_each/constexpr.cc: Test constexpr std::f

[PATCH] c++: Return only in-scope tparms in keep_template_parm [PR95310]

2020-09-19 Thread Patrick Palka via Gcc-patches
In the testcase below, the dependent specializations iter_reference_t and iter_reference_t share the same tree due to specialization caching. So when find_template_parameters walks through the requires-expression (as part of normalization), it sees and includes the out-of-scope template parameter

Re: [PATCH] libstdc++: Fix division by zero in std::sample

2020-09-21 Thread Patrick Palka via Gcc-patches
On Fri, 18 Sep 2020, Patrick Palka wrote: > This fixes a division by zero in the selection-sampling std::__search Whoops, this line say std::__sample, not std::__search. > overload when the input range is empty (and hence __unsampled_sz is 0). > > Tested on x86_64-pc-linux-gnu.

[PATCH] libstdc++: Remove overzealous static_asserts from std::span

2020-09-21 Thread Patrick Palka via Gcc-patches
For a span with empty static extent, we currently model the preconditions of front(), back(), and operator[] as if they were mandates, by using a static_assert to verify that extent != 0. This causes us to incorrectly reject valid programs that instantiate these member functions but never call the

Re: [PATCH] libstdc++: Remove overzealous static_asserts from std::span

2020-09-21 Thread Patrick Palka via Gcc-patches
On Mon, 21 Sep 2020, Patrick Palka wrote: > For a span with empty static extent, we currently model the > preconditions of front(), back(), and operator[] as if they were > mandates, by using a static_assert to verify that extent != 0. This > causes us to incorrectly reject valid p

Re: [PATCH] c++: Return only in-scope tparms in keep_template_parm [PR95310]

2020-09-22 Thread Patrick Palka via Gcc-patches
On Mon, 21 Sep 2020, Jason Merrill wrote: > On 9/19/20 3:49 PM, Patrick Palka wrote: > > In the testcase below, the dependent specializations iter_reference_t > > and iter_reference_t share the same tree due to specialization > > caching. So when find_template_paramet

Re: [PATCH] c++: Return only in-scope tparms in keep_template_parm [PR95310]

2020-09-22 Thread Patrick Palka via Gcc-patches
On Tue, 22 Sep 2020, Patrick Palka wrote: > On Mon, 21 Sep 2020, Jason Merrill wrote: > > > On 9/19/20 3:49 PM, Patrick Palka wrote: > > > In the testcase below, the dependent specializations iter_reference_t > > > and iter_reference_t share the same tree due to spe

[COMMITTED] c++: Add test for PR96652

2020-09-22 Thread Patrick Palka via Gcc-patches
Fixed by r11-3361. gcc/testsuite/ChangeLog: PR c++/96652 * g++.dg/cpp0x/decltype-96652.C: New test. --- gcc/testsuite/g++.dg/cpp0x/decltype-96652.C | 14 ++ 1 file changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype-96652.C diff --git a/

[PATCH] libstdc++: Specialize ranges::__detail::__box for semiregular types

2020-09-24 Thread Patrick Palka via Gcc-patches
The class template semiregular-box defined in [range.semi.wrap] is used by a number of views to accomodate non-semiregular subobjects while ensuring that the overall view remains semiregular. It provides a stand-in default constructor, copy assignment operator and move assignment operator whenever

[PATCH] c++: Incomplete parameter mappings during normalization

2020-09-25 Thread Patrick Palka via Gcc-patches
In the testcase concepts7.C below, we currently reject the call to f1 but we accept the call to f2, even though their associated constraints are functionally equivalent. The reason satisfaction differs for (!!C is due to normalization: the former is already an atom, and the latter is not. Normali

[PATCH 2/4] libstdc++: Reduce the size of a subrange with empty sentinel type

2020-09-27 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * include/bits/ranges_util.h (subrange::_M_end): Give it [[no_unique_adcress]]. * testsuite/std/ranges/subrange/sizeof.cc: New test. --- libstdc++-v3/include/bits/ranges_util.h | 2 +- .../testsuite/std/ranges/subrange/sizeof.cc | 28 ++

[PATCH 1/4] libstdc++: Reduce the size of an unbounded iota_view

2020-09-27 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * include/std/ranges (iota_view::_M_bound): Give it [[no_unique_address]]. * testsuite/std/ranges/iota/iota_view.cc: Check that an unbounded iota_view has minimal size. --- libstdc++-v3/include/std/ranges | 2 +- libstdc+

[PATCH 3/4] libstdc++: Add test that tracks range adaptors' sizes

2020-09-27 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * testsuite/std/ranges/adaptors/sizeof.cc: New test. --- .../testsuite/std/ranges/adaptors/sizeof.cc | 49 +++ 1 file changed, 49 insertions(+) create mode 100644 libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc diff --git a/libstdc++-v3/tes

[PATCH 4/4] libstdc++: Rearrange some range adaptors' data members

2020-09-27 Thread Patrick Palka via Gcc-patches
Since the standard range adaptors are specified to derive from the empty class view_base, making their first data member store the underlying view is suboptimal, for if the underlying view also derives from view_base then the two view_base subobjects will be adjacent, thus preventing the compiler f

Re: [PATCH 4/4] libstdc++: Rearrange some range adaptors' data members

2020-09-28 Thread Patrick Palka via Gcc-patches
On Mon, 28 Sep 2020, Jonathan Wakely wrote: > On 28/09/20 00:48 -0400, Patrick Palka via Libstdc++ wrote: > > Since the standard range adaptors are specified to derive from the empty > > class view_base, making their first data member store the underlying > > view is s

Re: [PATCH] c++: Incomplete parameter mappings during normalization

2020-09-28 Thread Patrick Palka via Gcc-patches
On Mon, 28 Sep 2020, Jason Merrill wrote: > On 9/25/20 4:44 PM, Patrick Palka wrote: > > In the testcase concepts7.C below, we currently reject the call to f1 > > but we accept the call to f2, even though their associated constraints > > are functionally equivalent. > &g

[PATCH] c++: Set the constraints of a class type sooner [PR96229]

2020-09-29 Thread Patrick Palka via Gcc-patches
In the testcase below, during processing (at parse time) of Y's base class X, convert_template_argument calls is_compatible_template_arg to check if the template argument Y is no more constrained than the parameter P. But at this point we haven't yet set Y's constraints, so get_normalized_constrai

[PATCH] c++: ICE in dependent_type_p with constrained auto [PR97052]

2020-09-29 Thread Patrick Palka via Gcc-patches
This patch fixes an "unguarded" call to coerce_template_parms in build_standard_check: processing_template_decl could be zero if we we get here during processing of the first 'auto' parameter of an abbreviated function template. In the testcase below, this leads to an ICE when coerce_template_parm

[PATCH] libstdc++: Make ranges::construct_at constexpr-friendly [PR95788]

2020-09-30 Thread Patrick Palka via Gcc-patches
This rewrites ranges::construct_at in terms of std::construct_at so that we can piggy back on the compiler's existing support for recognizing placement new within std::construct_at during constexpr evaluation instead of having to additionally teach the compiler about ranges::construct_at. While we

[PATCH] libstdc++: Add missing P0896 changes to

2020-10-01 Thread Patrick Palka via Gcc-patches
I noticed that the following changes from this paper were not yet implemented. OK to commit after testing on x86_64-pc-linux-gnu finishes successfully? libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (reverse_iterator::iter_move): Define for C++20 as per P0896. (rev

[PATCH] c++: Distinguish btw. alignof and __alignof__ in cp_tree_equal [PR97273]

2020-10-04 Thread Patrick Palka via Gcc-patches
cp_tree_equal currently considers alignof the same as __alignof__, but these operators are semantically different ever since r8-7957. In the testcase below, this causes the second static_assert to fail on targets where alignof(double) != __alignof__(double) because the specialization cache (which

Re: [PATCH] c++: ICE in dependent_type_p with constrained auto [PR97052]

2020-10-05 Thread Patrick Palka via Gcc-patches
On Wed, 30 Sep 2020, Jason Merrill wrote: > On 9/29/20 5:01 PM, Patrick Palka wrote: > > This patch fixes an "unguarded" call to coerce_template_parms in > > build_standard_check: processing_template_decl could be zero if we > > we get here during processing of t

Re: [PATCH] c++: ICE in dependent_type_p with constrained auto [PR97052]

2020-10-07 Thread Patrick Palka via Gcc-patches
On Tue, 6 Oct 2020, Jason Merrill wrote: > On 10/5/20 4:30 PM, Patrick Palka wrote: > > On Wed, 30 Sep 2020, Jason Merrill wrote: > > > > > On 9/29/20 5:01 PM, Patrick Palka wrote: > > > > This patch fixes an "unguarded" call to coerce_

Re: [PATCH] c++: Set the constraints of a class type sooner [PR96229]

2020-10-07 Thread Patrick Palka via Gcc-patches
On Tue, 29 Sep 2020, Patrick Palka wrote: > In the testcase below, during processing (at parse time) of Y's base > class X, convert_template_argument calls is_compatible_template_arg > to check if the template argument Y is no more constrained than the > parameter P. But at this

Re: [PATCH] libstdc++: Make ranges::construct_at constexpr-friendly [PR95788]

2020-10-07 Thread Patrick Palka via Gcc-patches
On Wed, 30 Sep 2020, Patrick Palka wrote: > This rewrites ranges::construct_at in terms of std::construct_at so > that we can piggy back on the compiler's existing support for > recognizing placement new within std::construct_at during constexpr > evaluation instead of havin

[PATCH] c++: Handle RANGE_EXPR indexes in init_subob_ctx [PR97328]

2020-10-08 Thread Patrick Palka via Gcc-patches
In the testcase below, we're ICEing during constexpr evaluation of the CONSTRUCTOR {.data={{}, [1 ... 7]={}}} of type 'vector'. The apparently unique thing about this CONSTRUCTOR is that it has a RANGE_EXPR index whose corresponding sub-aggregate initializer doesn't satisfy reduced_constant_expres

[PATCH] c++: some missing-SFINAE fixes

2022-09-13 Thread Patrick Palka via Gcc-patches
It looks like we aren't respecting SFINAE for: * an invalid/non-constant conditional explicit-specifier * a non-constant conditional noexcept-specifier * a non-constant argument to __integer_pack This patch fixes these issues in the usual way, by passing complain and propagating error_mark_

Re: [PATCH] c++: some missing-SFINAE fixes

2022-09-13 Thread Patrick Palka via Gcc-patches
On Tue, 13 Sep 2022, Jason Merrill wrote: > On 9/13/22 07:45, Patrick Palka wrote: > > It looks like we aren't respecting SFINAE for: > > > >* an invalid/non-constant conditional explicit-specifier > >* a non-constant conditional noexcept-specifier >

[committed] c++: remove single-parameter version of mark_used

2022-09-13 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, committed to trunk as obvious. gcc/cp/ChangeLog: * cp-tree.h (mark_used): Remove single-parameter overload. Add default argument to the two-parameter overload. * decl2.cc (mark_used): Likewise. --- gcc/cp/cp-tree.h | 4 ++-- gcc/cp/decl2.cc

[PATCH] libstdc++: Implement ranges::chunk_by_view from P2443R1

2022-09-14 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, does this look OK for trunk? libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (__adjacent_find_fn, adjacent_find): Move to ... * include/bits/ranges_util.h: ... here. * include/std/ranges (chunk_by_view): Define. (chunk_by

[PATCH] c++: constraint matching, TEMPLATE_ID_EXPR, current inst

2022-09-15 Thread Patrick Palka via Gcc-patches
Here we're crashing during constraint matching for the instantiated hidden friends due to two issues with dependent substitution into a TEMPLATE_ID_EXPR naming a template from the current instantiation (as performed from maybe_substitute_reqs_for for C<3> with T=T): * tsubst_copy substitutes int

[PATCH] c++: 'mutable' within constexpr [PR92505]

2022-09-15 Thread Patrick Palka via Gcc-patches
This patch permits accessing 'mutable' members of local objects during constexpr evaluation (which other compilers seem to accept in C++14 mode, while we reject), while continuing to reject it for global objects (as in the last line of cpp0x/constexpr-mutable1.C, which other compilers also reject).

[PATCH] c++: modules ICE with typename friend declaration

2022-09-15 Thread Patrick Palka via Gcc-patches
A couple of xtreme-header-* modules tests began ICEing in C++23 mode ever since r13-2650-g5d84a4418aa962 introduced into the dependently scoped friend declaration friend /* typename */ _OuterIter::value_type; ultimately because the streaming code assumes a TYPE_P friend must be a class type, b

Re: [PATCH] c++: constraint matching, TEMPLATE_ID_EXPR, current inst

2022-09-16 Thread Patrick Palka via Gcc-patches
On Fri, 16 Sep 2022, Jason Merrill wrote: > On 9/15/22 11:58, Patrick Palka wrote: > > Here we're crashing during constraint matching for the instantiated > > hidden friends due to two issues with dependent substitution into a > > TEMPLATE_ID_EXPR naming a template from

Re: [PATCH] c++: constraint matching, TEMPLATE_ID_EXPR, current inst

2022-09-16 Thread Patrick Palka via Gcc-patches
On Fri, 16 Sep 2022, Patrick Palka wrote: > On Fri, 16 Sep 2022, Jason Merrill wrote: > > > On 9/15/22 11:58, Patrick Palka wrote: > > > Here we're crashing during constraint matching for the instantiated > > > hidden friends due to two issues

Re: [PATCH] c++: modules ICE with typename friend declaration

2022-09-16 Thread Patrick Palka via Gcc-patches
uct C { static_assert(A::value == 42); }; -- 2.38.0.rc0 > > nathan > > On Thu, Sep 15, 2022, 22:16 Patrick Palka wrote: > A couple of xtreme-header-* modules tests began ICEing in C++23 mode > ever since r13-2650-g5d84a4418aa962 introduced into the > depend

Re: [PATCH] c++: constraint matching, TEMPLATE_ID_EXPR, current inst

2022-09-17 Thread Patrick Palka via Gcc-patches
On Sat, 17 Sep 2022, Jason Merrill wrote: > On 9/16/22 10:59, Patrick Palka wrote: > > On Fri, 16 Sep 2022, Jason Merrill wrote: > > > > > On 9/15/22 11:58, Patrick Palka wrote: > > > > Here we're crashing during constraint matching for the instantiated

[PATCH] c++: stream PACK_EXPANSION_EXTRA_ARGS [PR106761]

2022-09-19 Thread Patrick Palka via Gcc-patches
It looks like some xtreme-header-* tests are failing after the libstdc++ change r13-2158-g02f6b405f0e9dc ultimately because we're neglecting to stream PACK_EXPANSION_EXTRA_ARGS, which leads to false equivalences of different partial instantiations of _TupleConstraints::__constructible. Tested on x

Re: [PATCH] c++: stream PACK_EXPANSION_EXTRA_ARGS [PR106761]

2022-09-20 Thread Patrick Palka via Gcc-patches
On Tue, 20 Sep 2022, Nathan Sidwell wrote: > On 9/19/22 09:52, Patrick Palka wrote: > > It looks like some xtreme-header-* tests are failing after the libstdc++ > > change r13-2158-g02f6b405f0e9dc ultimately because we're neglecting > > to stream PACK_EXPANSION_EXTRA_

[PATCH 1/2] c++: modules and non-dependent auto deduction

2022-09-20 Thread Patrick Palka via Gcc-patches
The modules streaming code seems to rely on the invariant that a TEMPLATE_DECL and its DECL_TEMPLATE_RESULT have the same TREE_TYPE. But for a templated VAR_DECL with deduced non-dependent type, the two TREE_TYPEs end up diverging: cp_finish_decl deduces the type of the initializer ahead of time an

[PATCH 2/2] c++: xtreme-header modules tests cleanups

2022-09-20 Thread Patrick Palka via Gcc-patches
This adds some recently implemented C++20/23 library headers to the xtreme-header tests as appropriate. Also, it looks like we can safely re-add and remove the NO_ASSOCIATED_LAMBDA workaround. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/testsuite/ChangeLog: * g++.dg

[PATCH] c++ modules: partial variable template specializations [PR106826]

2022-09-21 Thread Patrick Palka via Gcc-patches
With partial variable template specializations, it looks like we stream the VAR_DECL (i.e. the DECL_TEMPLATE_RESULT of the corresponding TEMPLATE_DECL) since process_partial_specialization adds it to the specializations table, but end up never streaming the corresponding TEMPLATE_DECL itself that a

[PATCH] c++ modules: ICE with class NTTP argument [PR100616]

2022-09-22 Thread Patrick Palka via Gcc-patches
When streaming in the artificial VAR_DECL synthesized for a class NTTP argument, we end up crashing from complete_vars because the call to maybe_register_incomplete_var from add_module_namespace_decl for this VAR_DECL pushes an unexpected NULL_TREE type onto the incomplete_vars vector. This patch

Re: [PATCH] c++ modules: ICE with class NTTP argument [PR100616]

2022-09-23 Thread Patrick Palka via Gcc-patches
On Thu, 22 Sep 2022, Nathan Sidwell wrote: > On 9/22/22 14:25, Patrick Palka wrote: > > > index 80467c19254..722b64793ed 100644 > > --- a/gcc/cp/decl.cc > > +++ b/gcc/cp/decl.cc > > @@ -18235,9 +18235,11 @@ maybe_register_incomplete_var (tree var) > > {

[PATCH] c++ modules: variable template partial spec fixes [PR107033]

2022-09-26 Thread Patrick Palka via Gcc-patches
In r13-2775-g32d8123cd6ce87 I overlooked that we need to adjust the call to add_mergeable_specialization in the MK_partial case to correctly handle variable template partial specializations (it currently assumes we're always dealing with one for a class template). This fixes an ICE when converting

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

2022-09-26 Thread Patrick Palka via Gcc-patches
On Mon, 26 Sep 2022, Marek Polacek via Gcc-patches wrote: > Jon reported that evaluating __is_convertible in this test leads to > instantiating char_traits::eq, which is invalid (because we > are trying to call a member function on a char) and so we fail to > compile the test. __is_convertible do

Re: [PATCH] c++ modules: ICE with class NTTP argument [PR100616]

2022-09-26 Thread Patrick Palka via Gcc-patches
On Mon, 26 Sep 2022, Nathan Sidwell wrote: > On 9/26/22 10:08, Nathan Sidwell wrote: > > On 9/23/22 09:32, Patrick Palka wrote: > > > > > Judging by the two commits that introduced/modified this part of > > > maybe_register_incomplete_var, r196852 and r214333, I

Re: [PATCH] c++ modules: ICE with class NTTP argument [PR100616]

2022-09-26 Thread Patrick Palka via Gcc-patches
On Mon, 26 Sep 2022, Patrick Palka wrote: > On Mon, 26 Sep 2022, Nathan Sidwell wrote: > > > On 9/26/22 10:08, Nathan Sidwell wrote: > > > On 9/23/22 09:32, Patrick Palka wrote: > > > > > > > Judging by the two commits that introduced/modified this par

[PATCH 1/2] c++: introduce TRAIT_TYPE alongside TRAIT_EXPR

2022-09-27 Thread Patrick Palka via Gcc-patches
We already have generic support for predicate-like traits that yield a boolean via TRAIT_EXPR, but we lack the same support for transform-like traits that yield a type. Such support would be useful for implementing efficient built-ins for std::decay and std::remove_cvref and other conceptually sim

[PATCH 2/2] c++: implement __remove_cv, __remove_reference and __remove_cvref

2022-09-27 Thread Patrick Palka via Gcc-patches
This uses TRAIT_TYPE from the previous patch to implement efficient built-ins for std::remove_cv, std::remove_reference and std::remove_cvref. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/c-family/ChangeLog: * c-common.cc (c_common_reswords): Add __

Re: [PATCH] c++ modules: ICE with class NTTP argument [PR100616]

2022-09-28 Thread Patrick Palka via Gcc-patches
On Tue, 27 Sep 2022, Nathan Sidwell wrote: > On 9/26/22 15:05, Patrick Palka wrote: > > On Mon, 26 Sep 2022, Patrick Palka wrote: > > > > > On Mon, 26 Sep 2022, Nathan Sidwell wrote: > > > > > > > On 9/26/22 10:08, Nathan Sidwell wrote: &g

Re: [PATCH 1/2] c++: introduce TRAIT_TYPE alongside TRAIT_EXPR

2022-09-28 Thread Patrick Palka via Gcc-patches
On Tue, 27 Sep 2022, Jason Merrill wrote: > On 9/27/22 15:50, Patrick Palka wrote: > > We already have generic support for predicate-like traits that yield a > > boolean via TRAIT_EXPR, but we lack the same support for transform-like > > traits that yield a type. Such suppor

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

2022-09-29 Thread Patrick Palka via Gcc-patches
Adding a new builtin trait currently involves some boilerplate (as can be seen in r13-2956-g9ca147154074a0) of defining corresponding RID_ and CPTK_ enumerators and adding them to various switch statements across many files. The exact switch statements we need to change is determined by whether th

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

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

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

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

Re: c++: import/export NTTP objects

2022-09-29 Thread Patrick Palka via Gcc-patches
On Thu, 29 Sep 2022, Nathan Sidwell wrote: > > This adds smarts to the module machinery to handle NTTP object > VAR_DECLs. Like typeinfo objects, these must be ignored in the symbol > table, streamed specially and recreated on stream in. > > Patrick, thanks for the testcase, I don't know how to

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

2022-09-30 Thread Patrick Palka via Gcc-patches
On Thu, 29 Sep 2022, Jason Merrill wrote: > On 9/29/22 11:05, Patrick Palka wrote: > > Adding a new builtin trait currently involves some boilerplate (as can > > be seen in r13-2956-g9ca147154074a0) of defining corresponding RID_ and > > CPTK_ enumerators and adding t

Re: C++ ABI

2022-09-30 Thread Patrick Palka via Gcc-patches
On Fri, 30 Sep 2022, Nathan Sidwell wrote: > Hi, > I've discovered some mangling problems with lambdas. (a) divergence from > clang and (b) manglings that incorrectly demangle. With #a I'm not yet sure > who is correct. for #b g++ is definitely wrong. > > From the docs, it doesn't appear to ha

[PATCH] c++: make some cp_trait_kind switch statements exhaustive

2022-09-30 Thread Patrick Palka via Gcc-patches
This replaces the unreachable default case in some cp_trait_kind switches with an exhaustive listing of the _unexpected_ trait codes, so that when adding a new trait we'll get a -Wswitch diagnostic if we forget to handle the trait code in one of these switches. Bootstrappend and regtested on x86_6

Re: [PATCH] c++: make some cp_trait_kind switch statements exhaustive

2022-09-30 Thread Patrick Palka via Gcc-patches
On Fri, 30 Sep 2022, Patrick Palka wrote: > This replaces the unreachable default case in some cp_trait_kind > switches with an exhaustive listing of the _unexpected_ trait codes, > so that when adding a new trait we'll get a -Wswitch diagnostic if we > forget to handle the tra

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

2022-10-03 Thread Patrick Palka via Gcc-patches
On Fri, 30 Sep 2022, Jason Merrill wrote: > On 9/30/22 11:14, Patrick Palka wrote: > > On Thu, 29 Sep 2022, Jason Merrill wrote: > > > > > On 9/29/22 11:05, Patrick Palka wrote: > > > > Adding a new builtin trait currently involves some boilerplate

[PATCH] c++: install cp-trait.def as part of plugin headers [PR107136]

2022-10-03 Thread Patrick Palka via Gcc-patches
This is apparently needed since we include cp-trait.def from cp-tree.h (in order to define the cp_trait_kind enum), as with operators.def. Tested on x86_64-pc-linux-gnu by doing make install and verifying cp-trait.def appears in $prefix/lib/gcc/x86_64-pc-linux-gnu/13.0.0/plugin/include/cp/ Doe

[PATCH] libstdc++: Implement ranges::join_with_view from P2441R2

2022-10-03 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, does this look OK for trunk? FWIW using variant<_PatternIter, _InnerIter> in the implementation means we need to include from , which increases the preprocessed size of by 3% (51.5k vs 53k). I suppose that's an acceptable cost? libstdc++-v3/ChangeLog: *

Re: [PATCH] libstdc++: Implement ranges::join_with_view from P2441R2

2022-10-04 Thread Patrick Palka via Gcc-patches
On Tue, 4 Oct 2022, Jonathan Wakely wrote: > On Tue, 4 Oct 2022 at 02:11, Patrick Palka via Libstdc++ > wrote: > > > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? FWIW using > > OK, thanks. Thanks a lot, patch committed. > > > variant

[PATCH] c++ modules: lazy loading from within template [PR99377]

2022-10-04 Thread Patrick Palka via Gcc-patches
Here when lazily loading the binding for f at parse time from the template g, processing_template_decl is set and thus the call to note_vague_linkage_fn from module_state::read_cluster has no effect, and we never push f onto deferred_fns and end up never emitting its definition. ISTM the behavior

Re: [PATCH] c++ modules: lazy loading from within template [PR99377]

2022-10-05 Thread Patrick Palka via Gcc-patches
On Tue, 4 Oct 2022, Patrick Palka wrote: > Here when lazily loading the binding for f at parse time from the > template g, processing_template_decl is set and thus the call to > note_vague_linkage_fn from module_state::read_cluster has no effect, > and we never push f onto deferred_fn

Re: [PATCH] c++: Define built-in for std::tuple_element [PR100157]

2022-10-05 Thread Patrick Palka via Gcc-patches
On Thu, 7 Jul 2022, Jonathan Wakely via Gcc-patches wrote: > This adds a new built-in to replace the recursive class template > instantiations done by traits such as std::tuple_element and > std::variant_alternative. The purpose is to select the Nth type from a > list of types, e.g. __builtin_type

[PATCH] c++: remove optimize_specialization_lookup_p

2022-10-05 Thread Patrick Palka via Gcc-patches
Roughly speaking, optimize_specialization_lookup_p returns true for a non-template member function of a class template, e.g. template struct A { int f(); }; The idea behind the optimization in question seems to be that if we want to look up the specialization A::f [with T=int], then we can just

[PATCH] c++ modules: static var in inline function [PR104433]

2022-10-06 Thread Patrick Palka via Gcc-patches
The below testcase fails to link with the error undefined reference to `f()::y' ultimately because during stream out for the static VAR_DECL y we override DECL_EXTERNAL to true, which later during IPA confuses symbol_table::remove_unreachable_nodes into thinking it's safe to not emit the symbol

[PATCH] c++ modules: ICE with bitfield member in class template

2022-10-07 Thread Patrick Palka via Gcc-patches
According to grokbitfield, DECL_BITFIELD_REPRESENTATIVE may "temporarily" contain the width of the bitfield until we layout the class type (after which it'll contain a FIELD_DECL). But for a class template, it'll always be the width since we don't/can't layout dependent types. Tested on x86_64-pc

Re: [PATCH] c++ modules: ICE with bitfield member in class template

2022-10-07 Thread Patrick Palka via Gcc-patches
On Fri, 7 Oct 2022, Nathan Sidwell wrote: > On 10/7/22 11:09, Patrick Palka wrote: > > According to grokbitfield, DECL_BITFIELD_REPRESENTATIVE may "temporarily" > > contain the width of the bitfield until we layout the class type (after > > which it'll con

<    10   11   12   13   14   15   16   17   18   19   >