aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
AgeCommit message (Collapse)AuthorFilesLines
2025-05-25c++: dump_template_bindings tweakJason Merrill1-6/+7
in r12-1100 we stopped printing template bindings like T = T. The check for this relied on TREE_CHAIN of a TEMPLATE_TYPE_PARM holding the declaration of that type-parameter. This should be written as TYPE_STUB_DECL. In addition, TYPE_STUB_DECL is only set on the TYPE_MAIN_VARIANT, so we need to check that as well. Which is also desirable because volatile T is visibly distinct from T. gcc/cp/ChangeLog: * error.cc (dump_template_bindings): Correct skipping of redundant bindings.
2025-05-24Daily bump.GCC Administrator1-0/+16
2025-05-24c++/modules: Fix merge of TLS init functions [PR120363]Nathaniel Shead1-1/+2
The PR notes that we missed setting DECL_CONTEXT on the TLS init function; we missed this initially because this function is not created in header units, only named modules. I also noticed that 'DECL_CONTEXT (fn) = DECL_CONTEXT (var)' was incorrect: for class members, this ends up having the modules merging machinery treat the decl as a member function, which breaks when attempting to dedup against an existing completed class type. Instead we can just use the global_namespace as the context, because the name of the function is already mangled appropriately so that we'll match the correct duplicates. PR c++/120363 gcc/cp/ChangeLog: * decl2.cc (get_tls_init_fn): Set context as global_namespace. (get_tls_wrapper_fn): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/pr113292_a.H: Move to... * g++.dg/modules/tls-1_a.H: ...here. * g++.dg/modules/pr113292_b.C: Move to... * g++.dg/modules/tls-1_b.C: ...here. * g++.dg/modules/pr113292_c.C: Move to... * g++.dg/modules/tls-1_c.C: ...here. * g++.dg/modules/tls-2_a.C: New test. * g++.dg/modules/tls-2_b.C: New test. * g++.dg/modules/tls-2_c.C: New test. * g++.dg/modules/tls-3.h: New test. * g++.dg/modules/tls-3_a.H: New test. * g++.dg/modules/tls-3_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-24c++/modules: Fix stream-in of member using-decls [PR120414]Nathaniel Shead1-1/+2
When streaming in a reference to a data member, we have an oversight where we did not consider USING_DECLs, despite otherwise handling them here the same as fields. This patch corrects that mistake. PR c++/120414 gcc/cp/ChangeLog: * module.cc (trees_in::tree_node): Allow reading a USING_DECL when streaming tt_data_member. gcc/testsuite/ChangeLog: * g++.dg/modules/using-31_a.C: New test. * g++.dg/modules/using-31_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-23c++: drop push_tinst_level in manglingJason Merrill1-19/+3
I wondered why we needed to push/pop_tinst_level in mangle_decl_string. And apparently we don't need to anymore. gcc/cp/ChangeLog: * mangle.cc (mangle_decl_string): Don't push_tinst_level.
2025-05-23Daily bump.GCC Administrator1-0/+5
2025-05-22c++: constexpr always_inline [PR120935]Jason Merrill1-1/+3
In cp_fold we do speculative constant evaluation of constexpr calls when inlining is enabled. Let's also do it for always_inline functions. PR c++/120935 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold): Check always_inline. gcc/testsuite/ChangeLog: * g++.dg/opt/always_inline2.C: New test. * g++.dg/debug/dwarf2/pubnames-2.C: Suppress -fimplicit-constexpr. * g++.dg/debug/dwarf2/pubnames-3.C: Likewise.
2025-05-22Daily bump.GCC Administrator1-0/+25
2025-05-21c++, coroutines: Clean up the ramp cleanups.Iain Sandoe1-137/+62
This replaces the cleanup try-catch block in the ramp with a series of eh-only cleanup statements. gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Replace ramp cleanup try-catch block with eh-only cleanup statements. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-21c++, coroutines: Use decltype(auto) for the g_r_o.Iain Sandoe1-4/+8
The revised wording for coroutines, uses decltype(auto) for the type of the get return object, which preserves references. It is quite reasonable for a coroutine body implementation to complete before control is returned to the ramp - and in that case we would be creating the ramp return object from an already- deleted promise object. Jason observes that this is a terrible situation and we should seek a resolution to it via core. Since the test added here explicitly performs the unsafe action dscribed above we expect it to fail (until a resolution is found). gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Use decltype(auto) to determine the type of the temporary get_return_object. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr115908.C: Count promise construction and destruction. Run the test and XFAIL it. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-21c++, coroutines: Address CWG2563 return value init [PR119916].Iain Sandoe1-85/+41
This addresses the clarification that, when the get_return_object is of a different type from the ramp return, any necessary conversions should be performed on the return expression (so that they typically occur after the function body has started execution). PR c++/119916 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::wrap_original_function_body): Do not initialise initial_await_resume_called here... (cp_coroutine_transform::build_ramp_function): ... but here. When the coroutine is not void, initialize a GRO object from promise.get_return_object(). Use this as the argument to the return expression. Use a regular cleanup for the GRO, since it is ramp-local. gcc/testsuite/ChangeLog: * g++.dg/coroutines/torture/special-termination-00-sync-completion.C: Amend for CWG2563 expected behaviour. * g++.dg/coroutines/torture/special-termination-01-self-destruct.C: Likewise. * g++.dg/coroutines/torture/pr119916.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-21Daily bump.GCC Administrator1-0/+17
2025-05-20c++/modules: Ensure vtables are emitted when needed [PR120349]Nathaniel Shead1-2/+6
I missed a testcase in r16-688-gc875748cdc468e for whether a GM vtable should be emitted in an importer when it has no non-inline key function. Before that patch the code worked because always we marked all vtables as DECL_EXTERNAL, which then meant that reading the definition marked them as DECL_NOT_REALLY_EXTERN. This patch restores the old behaviour so that vtables are marked DECL_EXTERNAL (and hence DECL_NOT_REALLY_EXTERN). PR c++/120349 gcc/cp/ChangeLog: * module.cc (trees_out::core_bools): Always mark vtables as DECL_EXTERNAL. gcc/testsuite/ChangeLog: * g++.dg/modules/vtt-3_a.C: New test. * g++.dg/modules/vtt-3_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-20c++/modules: Fix ICE on merge of instantiation with partial spec [PR120013]Nathaniel Shead1-11/+30
When we import a pending instantiation that matches an existing partial specialisation, we don't find the slot in the entity map because for partial specialisations we register the TEMPLATE_DECL but for normal implicit instantiations we instead register the inner TYPE_DECL. Because the DECL_MODULE_ENTITY_P flag is set we correctly realise that it is in the entity map, but ICE when attempting to use that slot in partition handling. This patch fixes the issue by detecting this case and instead looking for the slot for the TEMPLATE_DECL. It doesn't matter that we never add a slot for the inner decl because we're about to discard it anyway. PR c++/120013 gcc/cp/ChangeLog: * module.cc (trees_in::install_entity): Handle re-registering the inner TYPE_DECL of a partial specialisation. gcc/testsuite/ChangeLog: * g++.dg/modules/partial-8.h: New test. * g++.dg/modules/partial-8_a.C: New test. * g++.dg/modules/partial-8_b.C: New test. * g++.dg/modules/partial-8_c.C: New test. * g++.dg/modules/partial-8_d.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-20c++/modules: Always mark tinfo vars as TREE_ADDRESSABLE [PR120350]Nathaniel Shead1-0/+1
We need to mark type info decls as addressable if we take them by reference; this is done by walking the declaration during parsing and marking the decl as needed. However, with modules we don't stream tinfo decls directly; rather we stream just their name and type and reconstruct them in the importer directly. This means that any addressable flags are not propagated, and we error because TREE_ADDRESSABLE is not set despite taking its address. But tinfo decls should always have TREE_ADDRESSABLE set, as any attempt to use the tinfo decl will go through build_address anyway. So this patch fixes the issue by eagerly marking the constructed decl as TREE_ADDRESSABLE so that modules gets this flag correctly set as well. PR c++/120350 gcc/cp/ChangeLog: * rtti.cc (get_tinfo_decl_direct): Mark TREE_ADDRESSABLE. gcc/testsuite/ChangeLog: * g++.dg/modules/tinfo-3_a.H: New test. * g++.dg/modules/tinfo-3_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-17Daily bump.GCC Administrator1-0/+21
2025-05-16Further simplify the stdlib inline foldingVille Voutilainen1-2/+1
gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold): Do the conversion unconditionally, even for same-type cases. gcc/ChangeLog: * doc/invoke.texi: Add to_underlying to -ffold-simple-inlines.
2025-05-16c++, coroutines: Allow NVRO in more cases for ramp functions.Iain Sandoe1-0/+6
The constraints of the c++ coroutines specification require the ramp to construct a return object early in the function. This will be returned at some later time. This is implemented as NVRO but requires that copying be well-formed even though it will be elided. Special-case ramp functions to allow this. gcc/cp/ChangeLog: * typeck.cc (check_return_expr): Suppress conversions for NVRO in coroutine ramp functions. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-16c++: Set the outer brace marker for missed cases.Iain Sandoe1-5/+3
In some cases, a function might be declared as FUNCTION_NEEDS_BODY_BLOCK but all the content is contained within that block. However, poplevel is currently assuming that such cases would always contain subblocks. In the case that we do have a body block, but there are no subblocks then st the outer brace marker on the body block. This situation occurs for at least coroutine lambda ramp functions and empty constructors. gcc/cp/ChangeLog: * decl.cc (poplevel): Set BLOCK_OUTER_CURLY_BRACE_P on the body block for functions with no subblocks. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-16c++/modules: Clean up importer_interfaceNathaniel Shead1-32/+18
This patch removes some no longer needed special casing in linkage determination, and makes the distinction between "always_emit" and "internal" for better future-proofing. gcc/cp/ChangeLog: * module.cc (importer_interface): Adjust flags. (get_importer_interface): Rename flags. (trees_out::core_bools): Clean up special casing. (trees_out::write_function_def): Rename flag. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-16Daily bump.GCC Administrator1-0/+18
2025-05-15c++: unifying specializations of non-primary tmpls [PR120161]Patrick Palka1-3/+3
Here unification of P=Wrap<int>::type, A=Wrap<long>::type wrongly succeeds ever since r14-4112 which made the RECORD_TYPE case of unify no longer recurse into template arguments for non-primary templates (since they're a non-deduced context) and so the int/long mismatch that makes the two types distinct goes unnoticed. In the case of (comparing specializations of) a non-primary template, unify should still go on to compare the types directly before returning success. PR c++/120161 gcc/cp/ChangeLog: * pt.cc (unify) <case RECORD_TYPE>: When comparing specializations of a non-primary template, still perform a type comparison. gcc/testsuite/ChangeLog: * g++.dg/template/unify13.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-15c++: -fimplicit-constexpr and modulesJason Merrill1-8/+18
Import didn't like differences in DECL_DECLARED_CONSTEXPR_P due to implicit constexpr, breaking several g++.dg/modules tests; we should handle that along with DECL_MAYBE_DELETED. For which we need to stream the bit. gcc/cp/ChangeLog: * module.cc (trees_out::lang_decl_bools): Stream implicit_constexpr. (trees_in::lang_decl_bools): Likewise. (trees_in::is_matching_decl): Check it.
2025-05-15c++: one more PR99599 tweakJason Merrill1-2/+2
Patrick pointed out that if the parm/arg types aren't complete yet at this point, it would affect the type_has_converting_constructor and TYPE_HAS_CONVERSION tests. I don't have a testcase, but it makes sense for safety. PR c++/99599 gcc/cp/ChangeLog: * pt.cc (conversion_may_instantiate_p): Make sure classes are complete.
2025-05-15Daily bump.GCC Administrator1-0/+36
2025-05-14Remove a sanity check comment now that the sanity check has been removedVille Voutilainen1-2/+0
gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold): Remove a remnant comment.
2025-05-14c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit ↵Nathaniel Shead2-3/+7
instantiations [PR120125] The attached testcase ICEs in maybe_thunk_body because we haven't created a node in the cgraph for an imported explicit instantiation yet. We in fact really shouldn't be emitting calls at all, since an imported explicit instantiation always exists in the TU we imported it from. So this patch adjusts DECL_NOT_REALLY_EXTERN handling to account for this. PR c++/120125 gcc/cp/ChangeLog: * module.cc (trees_out::write_function_def): Only set DECL_NOT_REALLY_EXTERN if the importer might need to emit it. * optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph node created. gcc/testsuite/ChangeLog: * g++.dg/modules/clone-4_a.C: New test. * g++.dg/modules/clone-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-14c++: Fix OpenMP support with C++20 modules [PR119864]Nathaniel Shead1-7/+7
In r15-2799-gf1bfba3a9b3f31, a new kind of global constructor was added. Unfortunately this broke C++20 modules, as both the host and target constructors were given the same mangled name. This patch ensures that only the host constructor gets the module name mangling for now, and stops forcing the creation of the target constructor even when no such initialization is required. PR c++/119864 gcc/cp/ChangeLog: * decl2.cc (start_objects): Only use module initialized for host. (c_parse_final_cleanups): Don't always create an OMP offload init function in modules. gcc/testsuite/ChangeLog: * g++.dg/modules/openmp-1.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-14c++/modules: Revert "Remove unnecessary lazy_load_pendings"Nathaniel Shead1-0/+3
This reverts commit r16-63-g241157eb0858b3. It turns out that the 'lazy_load_pendings' is necessary if we haven't seen a binding for the given template name at all in the current TU, as it is also used to find template instantiations with the given name. gcc/cp/ChangeLog: * name-lookup.cc (lookup_imported_hidden_friend): Add back lazy_load_pendings with comment. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-19_a.C: New test. * g++.dg/modules/tpl-friend-19_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2025-05-14Add std::to_underlying to the set of stdlib functions that are always foldedVille Voutilainen1-8/+5
gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold): Add to_underlying. gcc/testsuite/ChangeLog: * g++.dg/opt/pr96780_cpp23.C: New. libstdc++-v3/ChangeLog: * include/std/utility (to_underlying): Add the __always_inline__ attribute. Signed-off-by: Ville Voutilainen <ville.voutilainen@gmail.com>
2025-05-13c++: Allow -Wvirtual-move-assign to be more easily ignoredOwen Avery1-1/+3
This patch makes it easier to selectively disable -Wvirtual-move-assign by allowing diagnostic pragmas on base class move assignment operators to suppress such warnings. gcc/cp/ChangeLog: * method.cc (synthesized_method_walk): Check whether -Wvirtual-move-assign is enabled at the location of a base class's move assignment operator. gcc/testsuite/ChangeLog: * g++.dg/warn/ignore-virtual-move-assign.C: New test. Co-authored-by: Jason Merrill <jason@redhat.com> Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-05-13Daily bump.GCC Administrator1-0/+5
2025-05-12c+: -Wabi false positive [PR120012]Jason Merrill1-2/+4
The warning compares the position of a field depending on whether or not the previous base/field is considered a POD for layout, but failed to consider whether the previous base/field is empty; layout of an empty base doesn't consider PODness. PR c++/120012 gcc/cp/ChangeLog: * class.cc (check_non_pod_aggregate): Check is_empty_class. gcc/testsuite/ChangeLog: * g++.dg/abi/base-defaulted2.C: New test.
2025-05-11Daily bump.GCC Administrator1-0/+5
2025-05-09c++: recursive instantiation diagnostic [PR120204]Jason Merrill1-4/+12
Here tsubst_baselink was returning error_mark_node silently despite tf_error; we need to actually give an error. PR c++/120204 gcc/cp/ChangeLog: * pt.cc (tsubst_baselink): Always error if lookup fails. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-recursion3.C: New test.
2025-05-10Daily bump.GCC Administrator1-0/+12
2025-05-09c++: visibility of instantiated template friendsJason Merrill1-1/+3
In 20_util/variant/visit_member.cc, instantiation of the variant friend declaration of __get for variant<test01()::X> was being marked as internal because that variant specialization is itself internal. And therefore check_module_override didn't try to merge it with the non-exported namespace-scope declaration of __get. But the template parms of variant are not part of the friend template's identity, so they should not affect its visibility. If they are substituted into the friend declaration, we'll handle that when looking at the declaration itself. This change no longer seems necessary to fix the testcase, but does still seem correct. We definitely still get here during tsubst_friend_function. gcc/cp/ChangeLog: * decl2.cc (determine_visibility): Ignore args for friend templates.
2025-05-09c++: CWG2369 workaround and ... [PR120185]Jason Merrill2-1/+4
My r16-479 adjustment to the PR99599 workaround broke on a class with a varargs constructor. It also occurred to me that we don't need to do non-dep conversion checking in two phases when concepts aren't supported. PR c++/99599 PR c++/120185 gcc/cp/ChangeLog: * class.cc (type_has_converting_constructor): Handle null parm. * pt.cc (fn_type_unification): Skip early non-dep checking if no concepts. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-nondep6.C: New test.
2025-05-09Daily bump.GCC Administrator1-0/+7
2025-05-08c++: adjust PR99599/CWG2369 workaroundJason Merrill3-29/+53
This tweak to CWG2369 has gotten more discussion lately in CWG, including in P3606. In those discussions, it occurred to me that having the check depend on whether a class has been instantiated yet is unstable, that it should only check for user-defined conversions. Also, one commenter was surprised that adding an explicitly-declared default constructor to a class changed things, so this patch also changes the aggregate check to more narrowly checking for one-argument constructors other than the copy/move constructors. As a result, this early filter resembles how LOOKUP_DEFAULTED rejects any candidate that would need a UDC: in both cases we want to avoid considering arbitrary UDCs. But here, rather than rejecting, we want the early filter to let the candidate past without considering the conversion. PR c++/99599 gcc/cp/ChangeLog: * cp-tree.h (type_has_converting_constructor): Declare. * class.cc (type_has_converting_constructor): New. * pt.cc (conversion_may_instantiate_p): Don't check completeness. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-recursive-sat4.C: Adjust again. * g++.dg/cpp2a/concepts-nondep5.C: New test.
2025-05-06Daily bump.GCC Administrator1-0/+5
2025-05-05c++: Remove obsolete prototypeSimon Martin1-1/+0
I noticed while investigating PR c++/119437 that r8-2724-g88b811bd290630 removed parsing_default_capturing_generic_lambda_in_template but not its prototype in cp-tree.h. This patch fixes this. gcc/cp/ChangeLog: * cp-tree.h (parsing_default_capturing_generic_lambda_in_template): Remove obsolete prototype.
2025-05-03Daily bump.GCC Administrator1-0/+19
2025-05-02c++: CTAD and constexpr ctor [PR115207]Jason Merrill1-0/+3
Here we failed to constant-evaluate the A<int> constructor because DECL_SIZE wasn't set on 'a' yet, so compare_address thinks we can't be sure it isn't at the same address as 'i'. Normally DECL_SIZE is set by build_decl calling layout_decl, but that doesn't happen here because we don't have a type yet. So we need to layout_decl again after deduction. PR c++/115207 gcc/cp/ChangeLog: * decl.cc (cp_finish_decl): Call layout_decl after CTAD. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction118.C: New test.
2025-05-02c++: C++17/20 class layout divergence [PR120012]Jason Merrill2-12/+50
C++20 made a class with only explicitly defaulted constructors no longer aggregate, and this wrongly affected whether the class is considered "POD for layout purposes" under the ABI. Conveniently, we already have check_non_pod_aggregate to diagnose cases where this makes a difference, due to PR103681 around a C++14 aggregate change. PR c++/120012 gcc/cp/ChangeLog: * cp-tree.h (struct lang_type): Add non_aggregate_pod. (CLASSTYPE_NON_AGGREGATE_POD): New. * class.cc (check_bases_and_members): Set it. (check_non_pod_aggregate): Diagnose it. gcc/ChangeLog: * doc/invoke.texi: Document C++20 aggregate fix. * common.opt: Likewise. gcc/testsuite/ChangeLog: * g++.dg/abi/base-defaulted1.C: New test. * g++.dg/abi/base-defaulted1a.C: New test.
2025-05-02++: Small build_vec_init improvement [PR117827]Jakub Jelinek1-1/+2
As discussed in the https://gcc.gnu.org/pipermail/gcc-patches/2025-January/674492.html thread, the following patch attempts to improve build_vec_init generated code. E.g. on g++.dg/eh/aggregate1.C test the patch has differences like: D.2988 = &D.2950->e1; D.2989 = D.2988; D.2990 = 1; try { goto <D.2996>; <D.2997>: A::A (D.2989); D.2990 = D.2990 + -1; D.2989 = D.2989 + 1; <D.2996>: if (D.2990 >= 0) goto <D.2997>; else goto <D.2995>; <D.2995>: retval.4 = D.2988; _13 = &D.2950->e2; A::A (_13); - D.2990 = 1; + D.2988 = 0B; D.2951 = D.2951 + -1; } catch { { struct A * D.2991; if (D.2988 != 0B) goto <D.3028>; else goto <D.3029>; <D.3028>: _11 = 1 - D.2990; _12 = (sizetype) _11; D.2991 = D.2988 + _12; <D.3030>: if (D.2991 == D.2988) goto <D.3031>; else goto <D.3032>; <D.3032>: D.2991 = D.2991 + 18446744073709551615; A::~A (D.2991); goto <D.3030>; <D.3031>: goto <D.3033>; <D.3029>: <D.3033>: } } in 3 spots. As you can see, both setting D.2990 (i.e. iterator) to maxindex and setting D.2988 (i.e. rval) to nullptr have the same effect of not actually destructing anything anymore in the cleanup, the advantage of clearing rval is that setting something to zero is often less expensive than potentially huge maxindex and that the cleanup tests that value first. 2025-05-02 Jakub Jelinek <jakub@redhat.com> PR c++/117827 * init.cc (build_vec_init): Push to *cleanup_flags clearing of rval instead of setting of iterator to maxindex.
2025-05-02Daily bump.GCC Administrator1-0/+27
2025-05-01c++: poor diag w/ non-constexpr dtor called from constexpr ctorPatrick Palka1-8/+5
When diagnosing a non-constexpr constructor call during constexpr evaluation, explain_invalid_constexpr_fn was passing the genericized body to require_potential_constant_expression rather than the saved non-genericized one. This meant for the below testcase (reduced from PR libstdc++/119282) in which B::B() is deemed non-constexpr due to the local variable having a non-constexpr destructor we would then issue the cryptic diagnostic: constexpr-nonlit19.C:17:16: error: non-constant condition for static assertion 17 | static_assert(f()); | ~^~ constexpr-nonlit19.C:17:16: in ‘constexpr’ expansion of ‘f()’ constexpr-nonlit19.C:13:5: error: ‘constexpr B::B()’ called in a constant expression 13 | B b; | ^ constexpr-nonlit19.C:6:13: note: ‘constexpr B::B()’ is not usable as a ‘constexpr’ function because: 6 | constexpr B() { | ^ constexpr-nonlit19.C:8:5: error: ‘goto’ is not a constant expression 8 | for (int i = 0; i < 10; i++) { } | ^~~ This patch makes us pass the non-genericized body to require_potential_constant_expression, and so we now emit: ... constexpr-nonlit19.C:6:13: note: ‘constexpr B::B()’ is not usable as a ‘constexpr’ function because: 6 | constexpr B() { | ^ constexpr-nonlit19.C:9:3: error: call to non-‘constexpr’ function ‘A::~A()’ 9 | } | ^ constexpr-nonlit19.C:3:12: note: ‘A::~A()’ declared here 3 | struct A { ~A() { } }; | ^ gcc/cp/ChangeLog: * constexpr.cc (explain_invalid_constexpr_fn): In the DECL_CONSTRUCTOR_P branch pass the non-genericized body to require_potential_constant_expression. gcc/testsuite/ChangeLog: * g++.dg/cpp23/constexpr-nonlit19.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-01c++: more overeager use of deleted function before ADL [PR119034]Patrick Palka2-7/+9
The PR68942 fix used the tf_conv flag to disable mark_used when substituting a FUNCTION_DECL callee of an ADL-enabled call. In this slightly more elaborate testcase, we end up prematurely calling mark_used anyway on the FUNCTION_DECL directly from the CALL_EXPR case of tsubst_expr during partial instantiation, leading to a bogus "use of deleted function" error. This patch fixes the general problem in a more robust way by ensuring the callee of an ADL-enabled call is wrapped in an OVERLOAD, so that tsubst_expr leaves it alone. PR c++/119034 PR c++/68942 gcc/cp/ChangeLog: * pt.cc (tsubst_expr) <case CALL_EXPR>: Revert PR68942 fix. * semantics.cc (finish_call_expr): Ensure the callee of an ADL-enabled call is wrapped in an OVERLOAD. gcc/testsuite/ChangeLog: * g++.dg/template/koenig13.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-01c++: avoid weird #line paths in std-name-hint.hJason Merrill2-489/+489
etags was getting confused by the #line pathnames in std-name-hint.h that don't match my directory layout; let's avoid encoding information about a particular developer's $(srcdir) in the generated file. gcc/cp/ChangeLog: * Make-lang.in: Don't pass the full path to gperf. * std-name-hint.h: Regenerate.