aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-20Daily bump.GCC Administrator1-0/+21
2024-01-19c++: requires and using-decl [PR113498]Jason Merrill1-2/+28
get_template_info was crashing because it assumed that any decl with DECL_LANG_SPECIFIC could use DECL_TEMPLATE_INFO. It's more complicated than that. PR c++/113498 gcc/cp/ChangeLog: * pt.cc (decl_template_info): New fn. (get_template_info): Use it. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-using4.C: New test.
2024-01-19c++: alias template argument conversion [PR112632]Jason Merrill3-16/+41
We've had a problem with lost conversions to template parameter types for a while now; looking at this PR, it occurred to me that the problem is really with alias (and concept) templates, since we do substitution of dependent arguments into them in a way that we don't for other templates. And fixing that specific problem is a lot simpler than adding IMPLICIT_CONV_EXPR around all dependent template arguments the way I gave up on for 111357. The other part of the fix was changing tsubst_expr to actually call convert_nontype_argument instead of assuming it will eventually happen. I waffled about stripping the forced conversion when !force_conv vs. skipping them in iterative_hash_template_arg and template_args_equal (like we already do for some other conversions) and decided to go with the former, but that isn't a strong preference if it turns out to be somehow problematic. PR c++/112632 PR c++/112594 PR c++/111357 PR c++/104594 PR c++/67898 gcc/cp/ChangeLog: * cp-tree.h (IMPLICIT_CONV_EXPR_FORCED): New. * pt.cc (expand_integer_pack): Remove 111357 workaround. (maybe_convert_nontype_argument): Add force parm. (convert_template_argument): Handle alias template args specially. (tsubst_expr): Don't ignore IMPLICIT_CONV_EXPR_NONTYPE_ARG. * error.cc (dump_expr) [CASE_CONVERT]: Handle null optype. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-nontype1.C: New test. * g++.dg/cpp2a/concepts-narrowing1.C: New test. * g++.dg/cpp2a/nontype-class63.C: New test. * g++.dg/cpp2a/nontype-class63a.C: New test.
2024-01-19Daily bump.GCC Administrator1-0/+6
2024-01-18c++: ICE when xobj is not the first parm [PR113389]Marek Polacek1-0/+1
In grokdeclarator/cdk_function the comment says that the find_xobj_parm lambda clears TREE_PURPOSE so that we can correctly detect an xobj that is not the first parameter. That's all good, but we should also clear the TREE_PURPOSE once we've given the error, otherwise we crash later in check_default_argument because the 'this' TREE_PURPOSE lacks a type. PR c++/113389 gcc/cp/ChangeLog: * decl.cc (grokdeclarator) <case cdk_function>: Set TREE_PURPOSE to NULL_TREE when emitting an error. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics10.C: New test.
2024-01-18Daily bump.GCC Administrator1-0/+13
2024-01-18c++: Prevent overwriting arguments when merging duplicates [PR112588]Nathaniel Shead1-2/+0
When merging duplicate instantiations of function templates, currently read_function_def overwrites the arguments with that of the existing duplicate. This is problematic, however, since this means that the PARM_DECLs in the body of the function definition no longer match with the PARM_DECLs in the argument list, which causes issues when it comes to generating RTL. There doesn't seem to be any reason to do this replacement, so this patch removes that logic. PR c++/112588 gcc/cp/ChangeLog: * module.cc (trees_in::read_function_def): Don't overwrite arguments. gcc/testsuite/ChangeLog: * g++.dg/modules/merge-16.h: New test. * g++.dg/modules/merge-16_a.C: New test. * g++.dg/modules/merge-16_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-17c++: address of class NTTP object as targ [PR113242]Patrick Palka1-1/+3
invalid_tparm_referent_p was rejecting using the address of a class NTTP object as a template argument, but this should be fine. PR c++/113242 PR c++/99493 gcc/cp/ChangeLog: * pt.cc (invalid_tparm_referent_p) <case ADDR_EXPR>: Suppress DECL_ARTIFICIAL rejection test for class NTTP objects. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class61.C: New test. * g++.dg/cpp2a/nontype-class62.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-01-17Daily bump.GCC Administrator1-0/+37
2024-01-17c++: Support thread_local statics in header modules [PR113292]Nathaniel Shead2-4/+28
Currently, thread_locals in header modules cause ICEs. This patch makes the required changes for them to work successfully. This requires additionally writing the DECL_TLS_MODEL for thread-local variables to the module interface, and the TLS wrapper function needs to have its DECL_BEFRIENDING_CLASSES written too as this is used to retrieve what VAR_DECL it's a wrapper for when emitting a definition at end of TU processing. PR c++/113292 gcc/cp/ChangeLog: * decl2.cc (get_tls_wrapper_fn): Set DECL_CONTEXT. (c_parse_final_cleanups): Suppress warning for no definition of TLS wrapper functions in header modules. * module.cc (trees_out::lang_decl_vals): Write wrapped variable for TLS wrapper functions. (trees_in::lang_decl_vals): Read it. (trees_out::decl_value): Write TLS model for thread-local vars. (trees_in::decl_value): Read it for new decls. Remember to emit definitions of TLS wrapper functions later. gcc/testsuite/ChangeLog: * g++.dg/modules/pr113292_a.H: New test. * g++.dg/modules/pr113292_b.C: New test. * g++.dg/modules/pr113292_c.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-17c++: Fix ENABLE_SCOPE_CHECKING printingNathaniel Shead2-4/+14
The lists of scope kinds used by ENABLE_SCOPE_CHECKING don't seem to have been updated in a long while, causing ICEs and confusing output. This patch brings the list into line. Additionally, the comment on 'explicit_spec_p' says that the flag is only valid if kind is 'sk_template_parms', so we rewrite the condition to be more obviously correct here. gcc/cp/ChangeLog: * name-lookup.h (enum scope_kind): Add 'sk_count'. * name-lookup.cc (cp_binding_level_descriptor): Add missing scope kinds. Add assertion that the list is up to date. Fix handling of explicit_spec_p. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-16c++: fix xobj diagnostic messagesMarek Polacek1-3/+3
Diagnostics should start with a lower-case letter. gcc/cp/ChangeLog: * decl.cc (grokdeclarator) <case cdk_function>: Tweak diagnostic messages.
2024-01-16c++: fix ICE with xobj in destructor [PR113340]Marek Polacek1-0/+1
Here we crash in maybe_retrofit_in_chrg on an invalid dtor with explicit this. Such member functions do not get converted to METHOD_TYPE. If a dtor gets parameters, we reset arg_types to void_list_node in grokdeclarator. This results in m_r_in_c receiving: void <T8d> (void) and crashing on parms = DECL_CHAIN (DECL_ARGUMENTS (fn)); This patch avoids the ICE by resetting is_xobj_member_function after emitting the error. Then m_r_in_c gets void S::<T40b> (struct S *) which does not cause a crash. PR c++/113340 gcc/cp/ChangeLog: * decl.cc (grokdeclarator) <case cdk_function>: Clear is_xobj_member_function in case of an error. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics9.C: New test.
2024-01-16c++: reject packs on xobj params [PR113307]waffl3x1-1/+20
Reject and diagnose xobj parameters declared as parameter packs. PR c++/113307 gcc/cp/ChangeLog: * parser.cc (cp_parser_parameter_declaration): Reject packs on xobj params. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics3.C: Add test for rejection of packs. Signed-off-by: Waffl3x <waffl3x@protonmail.com>
2024-01-16Daily bump.GCC Administrator1-0/+24
2024-01-15c++: ICE with auto in template arg [PR110065]Marek Polacek1-2/+10
Here we started crashing with r14-1659 because that removed the auto checking in cp_parser_template_type_arg which seemed like dead code. But the attached test shows that the code can still be reached because cp_parser_type_id_1 checks auto only when auto_is_implicit_function_template_parm_p is on. Then I noticed that we're still crashing in C++20, and that ICE started with r12-4772. So I changed the reemerged check to use flag_concepts_ts rather than flag_concepts on the basis that check_auto_in_tmpl_args also checks flag_concepts_ts. PR c++/110065 gcc/cp/ChangeLog: * parser.cc (cp_parser_template_type_arg): Add auto checking. gcc/testsuite/ChangeLog: * g++.dg/concepts/auto8.C: New test. * g++.dg/concepts/auto8a.C: New test.
2024-01-15c++: access of class-scope partial specPatrick Palka2-3/+2
Since partial specializations can't be named directly, their access when declared at class scope is irrelevant, so we shouldn't have to set their TREE_PRIVATE / TREE_PROTECTED in maybe_new_partial_specialization (which is used only for constrained partial specializations anyway). This code was added by r10-4833-gcce3c9db9e6ffa for PR92078, but it seems better to just disable the access consistency check for partial specializations, which lets us accept the below testcase. gcc/cp/ChangeLog: * parser.cc (cp_parser_check_access_in_redeclaration): Don't check access for a partial or explicit specialization. * pt.cc (maybe_new_partial_specialization): Don't set TREE_PRIVATE or TREE_PROTECTED on the newly created partial specialization. gcc/testsuite/ChangeLog: * g++.dg/template/partial-specialization14.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-01-15c++: explicit inst w/ similar constrained partial specs [PR104634]Patrick Palka1-0/+1
Here we neglect to emit the definitions of A<double>::f2 and A<double*>::f4 despite the explicit instantiations ultimately because TREE_PUBLIC isn't set on the corresponding partial specializations, whose declarations are created from maybe_new_partial_specialization which is responsible for disambiguating them from the first and third partial specializations (which have the same class-head but different constraints). This makes grokfndecl in turn clear TREE_PUBLIC for f2 and f4 as if they have internal linkage. This patch fixes this by setting TREE_PUBLIC appropriately for such partial specializations. PR c++/104634 gcc/cp/ChangeLog: * pt.cc (maybe_new_partial_specialization): Propagate TREE_PUBLIC to the newly created partial specialization. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-explicit-inst6.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-01-15c++: non-dep array list-init w/ non-triv dtor [PR109899]Patrick Palka1-1/+2
The get_target_expr call added in r12-7069-g119cea98f66476 causes us for the below testcase to call build_vec_delete in a template context, which builds a templated destructor call and checks expr_noexcept_p for it, which ICEs because the call has templated form. Much of the work of build_vec_delete however is code generation and thus will just get discarded in a template context, and that includes the code guarded by expr_noexcept_p. So this patch narrowly fixes this ICE by eliding the expr_noexcept_p call when in a template context. PR c++/109899 gcc/cp/ChangeLog: * init.cc (build_vec_delete_1): Assume expr_noexcept_p returns false in a template context. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-array21.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-01-14Daily bump.GCC Administrator1-0/+6
2024-01-13c++, demangle: Implement ↵Jakub Jelinek1-0/+3
https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal The following patch attempts to implement what apparently clang++ implemented for explicit object member function mangling, but nobody actually proposed in patch form in https://github.com/itanium-cxx-abi/cxx-abi/issues/148 2024-01-13 Jakub Jelinek <jakub@redhat.com> gcc/cp/ * mangle.cc (write_nested_name): Mangle explicit object member functions with H as per https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal. gcc/testsuite/ * g++.dg/abi/mangle79.C: New test. include/ * demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. libiberty/ * cp-demangle.c (FNQUAL_COMPONENT_CASE): Add case for DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. (d_dump): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. (d_nested_name): Parse H after N in nested name. (d_count_templates_scopes): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. (d_print_mod): Likewise. (d_print_function_type): Likewise. * testsuite/demangle-expected: Add tests for explicit object member functions.
2024-01-13Daily bump.GCC Administrator1-0/+19
2024-01-12c++: __class_type_info and modules [PR113038]Jason Merrill1-3/+13
Doing a dynamic_cast in both TUs broke because we were declaring a new __class_type_info in _b that conflicted with the one imported in the global module from _a. It seems clear to me that any new class declaration in the global module should merge with an imported definition, but for GCC 14 let's just fix this for the specific case of __class_type_info. PR c++/113038 gcc/cp/ChangeLog: * name-lookup.cc (lookup_elaborated_type): Look for bindings in the global namespace in the ABI namespace. gcc/testsuite/ChangeLog: * g++.dg/modules/pr106304_b.C: Add dynamic_cast.
2024-01-12c++: cand_parms_match and reversed candidatesJason Merrill3-40/+69
When considering whether the candidate parameters match, according to the language we're considering the synthesized reversed candidate, so we should compare the parameters in swapped order. In this situation it doesn't make sense to consider whether object parameters correspond, since we're comparing an object parameter to a non-object parameter, so I generalized xobj_iobj_parameters_correspond accordingly. As I refine cand_parms_match, more behaviors need to differ between its original use to compare the original templates for two candidates, and the later use to decide whether to compare constraints. So now there's a parameter to select between the semantics. gcc/cp/ChangeLog: * call.cc (reversed_match): New. (enum class pmatch): New enum. (cand_parms_match): Add match_kind parm. (object_parms_correspond): Add fn parms. (joust): Adjust. * class.cc (xobj_iobj_parameters_correspond): Rename to... (iobj_parm_corresponds_to): ...this. Take the other type instead of a second function. (object_parms_correspond): Adjust. * cp-tree.h (iobj_parm_corresponds_to): Declare. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-memfun4.C: Change expected reversed handling.
2024-01-12Daily bump.GCC Administrator1-0/+13
2024-01-11c++: corresponding object parms [PR113191]Jason Merrill4-91/+131
As discussed, our handling of corresponding object parameters needed to handle the using-declaration case better. And I took the opportunity to share code between the add_method and cand_parms_match uses. This patch specifically doesn't compare reversed parameters, but a follow-up patch will. PR c++/113191 gcc/cp/ChangeLog: * class.cc (xobj_iobj_parameters_correspond): Add context parm. (object_parms_correspond): Factor out of... (add_method): ...here. * method.cc (defaulted_late_check): Use it. * call.cc (class_of_implicit_object): New. (object_parms_correspond): Overload taking two candidates. (cand_parms_match): Use it. (joust): Check reversed before comparing constraints. * cp-tree.h (object_parms_correspond): Declare. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-memfun4.C: New test.
2024-01-11Daily bump.GCC Administrator1-0/+4
2024-01-10c++ frontend: initialize ivdep valueTamar Christina1-1/+1
Should control enter the switch from one of the cases other than the IVDEP one then the variable remains uninitialized. This fixes it by initializing it to false. gcc/cp/ChangeLog: * parser.cc (cp_parser_pragma): Initialize to false.
2024-01-10Daily bump.GCC Administrator1-0/+189
2024-01-09c++: adjust accessor fixits for explicit object parmJason Merrill4-7/+30
In a couple of places in the xobj patch I noticed that is_this_parameter probably wanted to change to is_object_parameter; this implements that and does the additional adjustments needed to make the accessor fixits handle xobj parms. gcc/cp/ChangeLog: * semantics.cc (is_object_parameter): New. * cp-tree.h (is_object_parameter): Declare. * call.cc (maybe_warn_class_memaccess): Use it. * search.cc (field_access_p): Use it. (class_of_object_parm): New. (field_accessor_p): Adjust for explicit object parms. gcc/testsuite/ChangeLog: * g++.dg/torture/accessor-fixits-9-xobj.C: New test.
2024-01-09c++: explicit object cleanupsJason Merrill3-46/+25
The FIXME in xobj_iobj_parameters_correspond was due to expecting TYPE_MAIN_VARIANT to be the same for all equivalent types, which is not the case. And I adjusted some comments that I disagree with; the iobj parameter adjustment only applies to overload resolution, we can handle that in cand_parms_match (and I have WIP for that). gcc/cp/ChangeLog: * call.cc (build_over_call): Refactor handle_arg lambda. * class.cc (xobj_iobj_parameters_correspond): Fix FIXME. * method.cc (defaulted_late_check): Adjust comments.
2024-01-09c++: P0847R7 (deducing this) - CWG2586 [PR102609]waffl3x2-8/+75
This adds support for defaulted comparison operators and copy/move assignment operators, as well as allowing user defined xobj copy/move assignment operators. It turns out defaulted comparison operators already worked though, so this just adds a test for them. Defaulted comparison operators were not so nice and required a bit of a hack. Should work fine though! The diagnostics leave something to be desired, and there are some things that could be improved with more extensive design changes. There are a few notes left indicating where I think we could make improvements. Aside from some small bugs, with this commit xobj member functions should be feature complete. PR c++/102609 gcc/cp/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - CWG2586. * decl.cc (copy_fn_p): Accept xobj copy assignment functions. (move_signature_fn_p): Accept xobj move assignment functions. * method.cc (do_build_copy_assign): Handle defaulted xobj member functions. (defaulted_late_check): Comment. (defaultable_fn_check): Comment. gcc/testsuite/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - CWG2586. * g++.dg/cpp23/explicit-obj-basic6.C: New test. * g++.dg/cpp23/explicit-obj-default1.C: New test. * g++.dg/cpp23/explicit-obj-default2.C: New test. Signed-off-by: Waffl3x <waffl3x@protonmail.com>
2024-01-09c++: P0847R7 (deducing this) - xobj lambdas. [PR102609]waffl3x4-14/+158
This implements support for xobj lambdas. There are extensive tests included, but not exhaustive. Dependent lambdas should work and have been tested lightly, but we need more exhaustive tests for them. PR c++/102609 gcc/cp/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - xobj lambdas. * lambda.cc (build_capture_proxy): Don't fold direct object types. * parser.cc (cp_parser_lambda_declarator_opt): Handle xobj lambdas, diagnostics. Comments also updated. * pt.cc (tsubst_function_decl): Handle xobj lambdas. Check object type of xobj lambda call operator, diagnose incorrect types. (tsubst_lambda_expr): Update comment. * semantics.cc (finish_decltype_type): Also consider by-value object parameter qualifications. gcc/testsuite/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - xobj lambdas. * g++.dg/cpp23/explicit-obj-diagnostics8.C: New test. * g++.dg/cpp23/explicit-obj-lambda1.C: New test. * g++.dg/cpp23/explicit-obj-lambda10.C: New test. * g++.dg/cpp23/explicit-obj-lambda11.C: New test. * g++.dg/cpp23/explicit-obj-lambda12.C: New test. * g++.dg/cpp23/explicit-obj-lambda13.C: New test. * g++.dg/cpp23/explicit-obj-lambda2.C: New test. * g++.dg/cpp23/explicit-obj-lambda3.C: New test. * g++.dg/cpp23/explicit-obj-lambda4.C: New test. * g++.dg/cpp23/explicit-obj-lambda5.C: New test. * g++.dg/cpp23/explicit-obj-lambda6.C: New test. * g++.dg/cpp23/explicit-obj-lambda7.C: New test. * g++.dg/cpp23/explicit-obj-lambda8.C: New test. * g++.dg/cpp23/explicit-obj-lambda9.C: New test. Signed-off-by: Waffl3x <waffl3x@protonmail.com>
2024-01-09c++: P0847R7 (deducing this) - diagnostics. [PR102609]waffl3x8-50/+294
Diagnostics for xobj member functions. Also includes some diagnostics for xobj lambdas which are not implemented here. CWG2554 is also implemented here, we explicitly error when an xobj member function overrides a virtual function. PR c++/102609 gcc/c-family/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - diagnostics. * c-cppbuiltin.cc (c_cpp_builtins): Define __cpp_explicit_this_parameter=202110L feature test macro. gcc/cp/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - diagnostics. * class.cc (resolve_address_of_overloaded_function): Diagnostics. * cp-tree.h (TFF_XOBJ_FUNC): Define. * decl.cc (grokfndecl): Diagnostics. (grokdeclarator): Diagnostics. * error.cc (dump_aggr_type): Pass TFF_XOBJ_FUNC. (dump_lambda_function): Formatting for xobj lambda. (dump_function_decl): Pass TFF_XOBJ_FUNC. (dump_parameters): Formatting for xobj member functions. (function_category): Formatting for xobj member functions. * parser.cc (cp_parser_decl_specifier_seq): Diagnostics. (cp_parser_parameter_declaration): Diagnostics. * search.cc (look_for_overrides_here): Make xobj member functions override. (look_for_overrides_r): Reject an overriding xobj member function and diagnose it. * semantics.cc (finish_this_expr): Diagnostics. * typeck.cc (cp_build_addr_expr_1): Diagnostics. gcc/testsuite/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - diagnostics. * g++.dg/cpp23/feat-cxx2b.C: Test existance and value of __cpp_explicit_this_parameter feature test macro. * g++.dg/cpp26/feat-cxx26.C: Likewise. * g++.dg/cpp23/explicit-obj-cxx-dialect-A.C: New test. * g++.dg/cpp23/explicit-obj-cxx-dialect-B.C: New test. * g++.dg/cpp23/explicit-obj-cxx-dialect-C.C: New test. * g++.dg/cpp23/explicit-obj-cxx-dialect-D.C: New test. * g++.dg/cpp23/explicit-obj-cxx-dialect-E.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics1.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics2.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics3.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics4.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics5.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics6.C: New test. * g++.dg/cpp23/explicit-obj-diagnostics7.C: New test. Signed-off-by: Waffl3x <waffl3x@protonmail.com>
2024-01-09c++: P0847R7 (deducing this) - initial functionality. [PR102609]waffl3x7-97/+423
This implements the initial functionality for P0847R7. CWG2789 is implemented, but instead of "same type" for the object parameters we take correspondence into account instead. Without this alteration, the behavior here would be slightly different than the behavior with constrained member function templates, which I believe would be undesirable. There are a few outstanding issues related to xobj member functions overloading iobj member functions that are introduced by using declarations. Unfortunately, fixing this will be a little more involved and will have to be pushed back until later. Most diagnostics have been split out into another patch to improve its clarity and allow all the strictly functional changes to be more distinct. Explicit object lambdas and CWG2586 are addressed in a follow up patch. PR c++/102609 gcc/cp/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - initial functionality. * class.cc (xobj_iobj_parameters_correspond): New function, checks for corresponding object parameters between xobj and iobj member functions. (add_method): Handle object parameters of xobj member functions, use xobj_iobj_parameters_correspond. * call.cc (build_over_call): Refactor, handle xobj member functions. (cand_parms_match): Handle object parameters of xobj and iobj member functions, use xobj_iobj_parameters_correspond. * cp-tree.h (enum cp_decl_spec): Add ds_this, add comments. * decl.cc (grokfndecl): Add xobj_func_p parameter. For xobj member functions, Set xobj_flag, don't set static_function flag. (grokdeclarator): Handle xobj member functions, tell grokfndecl. (grok_op_properties): Don't error for xobj operators. * parser.cc (cp_parser_decl_specifier_seq): Handle this specifier. (cp_parser_parameter_declaration): Set default argument to "this_identifier" for xobj parameters. (set_and_check_decl_spec_loc): Add "this", add comments. * tree.cc (build_min_non_dep_op_overload): Handle xobj operators. * typeck.cc (cp_build_addr_expr_1): Handle address-of xobj member functions. gcc/testsuite/ChangeLog: PR c++/102609 C++23 P0847R7 (deducing this) - initial functionality. * g++.dg/cpp23/explicit-obj-basic1.C: New test. * g++.dg/cpp23/explicit-obj-basic2.C: New test. * g++.dg/cpp23/explicit-obj-basic3.C: New test. * g++.dg/cpp23/explicit-obj-basic4.C: New test. * g++.dg/cpp23/explicit-obj-basic5.C: New test. * g++.dg/cpp23/explicit-obj-by-value1.C: New test. * g++.dg/cpp23/explicit-obj-by-value2.C: New test. * g++.dg/cpp23/explicit-obj-by-value3.C: New test. * g++.dg/cpp23/explicit-obj-by-value4.C: New test. * g++.dg/cpp23/explicit-obj-constraints.C: New test. * g++.dg/cpp23/explicit-obj-constraints2.C: New test. * g++.dg/cpp23/explicit-obj-ops-mem-arrow.C: New test. * g++.dg/cpp23/explicit-obj-ops-mem-assignment.C: New test. * g++.dg/cpp23/explicit-obj-ops-mem-call.C: New test. * g++.dg/cpp23/explicit-obj-ops-mem-subscript.C: New test. * g++.dg/cpp23/explicit-obj-ops-non-mem-dep.C: New test. * g++.dg/cpp23/explicit-obj-ops-non-mem-non-dep.C: New test. * g++.dg/cpp23/explicit-obj-ops-non-mem.h: New test. * g++.dg/cpp23/explicit-obj-ops-requires-mem.C: New test. * g++.dg/cpp23/explicit-obj-ops-requires-non-mem.C: New test. * g++.dg/cpp23/explicit-obj-redecl.C: New test. * g++.dg/cpp23/explicit-obj-redecl2.C: New test. * g++.dg/cpp23/explicit-obj-redecl3.C: New test. * g++.dg/cpp23/explicit-obj-redecl4.C: New test. Signed-off-by: Waffl3x <waffl3x@protonmail.com>
2024-01-09c++: P0847R7 (deducing this) - prerequisite changes. [PR102609]waffl3x19-75/+103
Adds the xobj_flag member to lang_decl_fn and a corresponding member access macro and predicate to support the addition of explicit object member functions. Additionally, since explicit object member functions are also non-static member functions, we need to change uses of DECL_NONSTATIC_MEMBER_FUNCTION_P to clarify whether they intend to include or exclude them. PR c++/102609 gcc/cp/ChangeLog: * cp-tree.h (struct lang_decl_fn): New data member. (DECL_NONSTATIC_MEMBER_FUNCTION_P): Poison. (DECL_IOBJ_MEMBER_FUNCTION_P): Define. (DECL_FUNCTION_XOBJ_FLAG): Define. (DECL_XOBJ_MEMBER_FUNCTION_P): Define. (DECL_OBJECT_MEMBER_FUNCTION_P): Define. (DECL_FUNCTION_MEMBER_P): Don't use DECL_NONSTATIC_MEMBER_FUNCTION_P. (DECL_CONST_MEMFUNC_P): Likewise. (DECL_VOLATILE_MEMFUNC_P): Likewise. (DECL_NONSTATIC_MEMBER_P): Likewise. * module.cc (trees_out::lang_decl_bools): Handle xobj_flag. (trees_in::lang_decl_bools): Handle xobj_flag. * call.cc (build_this_conversion) (add_function_candidate) (add_template_candidate_real) (add_candidates) (maybe_warn_class_memaccess) (cand_parms_match) (joust) (do_warn_dangling_reference) * class.cc (finalize_literal_type_property) (finish_struct) (resolve_address_of_overloaded_function) * constexpr.cc (is_valid_constexpr_fn) (cxx_bind_parameters_in_call) * contracts.cc (build_contract_condition_function) * cp-objcp-common.cc (cp_decl_dwarf_attribute) * cxx-pretty-print.cc (cxx_pretty_printer::postfix_expression) (cxx_pretty_printer::declaration_specifiers) (cxx_pretty_printer::direct_declarator) * decl.cc (cp_finish_decl) (grok_special_member_properties) (start_preparsed_function) (record_key_method_defined) * decl2.cc (cp_handle_deprecated_or_unavailable) * init.cc (find_uninit_fields_r) (build_offset_ref) * lambda.cc (lambda_expr_this_capture) (maybe_generic_this_capture) (nonlambda_method_basetype) * mangle.cc (write_nested_name) * method.cc (early_check_defaulted_comparison) (skip_artificial_parms_for) (num_artificial_parms_for) * pt.cc (is_specialization_of_friend) (determine_specialization) (copy_default_args_to_explicit_spec) (check_explicit_specialization) (tsubst_contract_attribute) (check_non_deducible_conversions) (more_specialized_fn) (maybe_instantiate_noexcept) (register_parameter_specializations) (value_dependent_expression_p) * search.cc (shared_member_p) (lookup_member) (field_access_p) * semantics.cc (finish_omp_declare_simd_methods) * tree.cc (lvalue_kind) * typeck.cc (invalid_nonstatic_memfn_p): Don't use DECL_NONSTATIC_MEMBER_FUNCTION_P. libcc1/ChangeLog: * libcp1plugin.cc (plugin_pragma_push_user_expression): Don't use DECL_NONSTATIC_MEMBER_FUNCTION_P. Signed-off-by: Waffl3x <waffl3x@protonmail.com> Co-authored-by: Jason Merrill <jason@redhat.com>
2024-01-09OpenMP: lvalue parsing for map/to/from clauses (C++)Julian Brown9-44/+372
This patch supports "lvalue" parsing (or "locator list item type" parsing) for several OpenMP clause types for C++, as required for OpenMP 5.0 and above. This version has been rebased -- some things have changed around template handling recently, e.g. removal of build_non_dependent_expr and tsubst_copy. A new potential corner-case issue has shown up regarding implicit mapping of references to pointer to pointers -- an interaction with the post-review fixes/rework for the patch here: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/638602.html Which fixed the (new) tests baseptrs-[6789].C. I've noted that for now in the patch, and adjusted the baseptrs-[46].C tests slightly to accommodate. 2024-01-08 Julian Brown <julian@codesourcery.com> gcc/c-family/ * c-common.h (c_omp_address_inspector): Remove static from get_origin and maybe_unconvert_ref methods. * c-omp.cc (c_omp_split_clauses): Support OMP_ARRAY_SECTION. (c_omp_address_inspector::map_supported_p): Handle OMP_ARRAY_SECTION. (c_omp_address_inspector::get_origin): Avoid dereferencing possibly NULL type when processing template decls. (c_omp_address_inspector::maybe_unconvert_ref): Likewise. gcc/cp/ * constexpr.cc (potential_consant_expression_1): Handle OMP_ARRAY_SECTION. * cp-tree.h (grok_omp_array_section, build_omp_array_section): Add prototypes. * decl2.cc (grok_omp_array_section): New function. * error.cc (dump_expr): Handle OMP_ARRAY_SECTION. * parser.cc (cp_parser_new): Initialize parser->omp_array_section_p. (cp_parser_statement_expr): Disallow array sections. (cp_parser_postfix_open_square_expression): Support OMP_ARRAY_SECTION parsing. (cp_parser_parenthesized_expression_list, cp_parser_lambda_expression, cp_parser_braced_list): Disallow array sections. (cp_parser_omp_var_list_no_open): Remove ALLOW_DEREF parameter, add MAP_LVALUE in its place. Support generalised lvalue parsing for OpenMP map, to and from clauses. Use OMP_ARRAY_SECTION code instead of TREE_LIST to represent OpenMP array sections. (cp_parser_omp_var_list): Remove ALLOW_DEREF parameter, add MAP_LVALUE. Pass to cp_parser_omp_var_list_no_open. (cp_parser_oacc_data_clause): Update call to cp_parser_omp_var_list. (cp_parser_omp_clause_map): Add sk_omp scope around cp_parser_omp_var_list_no_open call. * parser.h (cp_parser): Add omp_array_section_p field. * pt.cc (tsubst, tsubst_copy, tsubst_omp_clause_decl, tsubst_copy_and_build): Add OMP_ARRAY_SECTION support. * semantics.cc (handle_omp_array_sections_1, handle_omp_array_sections, cp_oacc_check_attachments, finish_omp_clauses): Use OMP_ARRAY_SECTION instead of TREE_LIST where appropriate. Handle more types of map expression. * typeck.cc (build_omp_array_section): New function. gcc/ * gimplify.cc (gimplify_expr): Ensure OMP_ARRAY_SECTION has been processed out before gimplification. * tree-pretty-print.cc (dump_generic_node): Support OMP_ARRAY_SECTION. * tree.def (OMP_ARRAY_SECTION): New tree code. gcc/testsuite/ * c-c++-common/gomp/map-6.c: Update expected output. * c-c++-common/gomp/target-enter-data-1.c: Update scan test. * g++.dg/gomp/array-section-1.C: New test. * g++.dg/gomp/array-section-2.C: New test. * g++.dg/gomp/bad-array-section-1.C: New test. * g++.dg/gomp/bad-array-section-2.C: New test. * g++.dg/gomp/bad-array-section-3.C: New test. * g++.dg/gomp/bad-array-section-4.C: New test. * g++.dg/gomp/bad-array-section-5.C: New test. * g++.dg/gomp/bad-array-section-6.C: New test. * g++.dg/gomp/bad-array-section-7.C: New test. * g++.dg/gomp/bad-array-section-8.C: New test. * g++.dg/gomp/bad-array-section-9.C: New test. * g++.dg/gomp/bad-array-section-10.C: New test. * g++.dg/gomp/bad-array-section-11.C: New test. * g++.dg/gomp/has_device_addr-non-lvalue-1.C: New test. * g++.dg/gomp/pr67522.C: Update expected output. * g++.dg/gomp/ind-base-3.C: New test. * g++.dg/gomp/map-assignment-1.C: New test. * g++.dg/gomp/map-inc-1.C: New test. * g++.dg/gomp/map-lvalue-ref-1.C: New test. * g++.dg/gomp/map-ptrmem-1.C: New test. * g++.dg/gomp/map-ptrmem-2.C: New test. * g++.dg/gomp/map-static-cast-lvalue-1.C: New test. * g++.dg/gomp/map-ternary-1.C: New test. * g++.dg/gomp/member-array-2.C: New test. libgomp/ * testsuite/libgomp.c++/baseptrs-4.C: Remove commented-out cases that now work. * testsuite/libgomp.c++/baseptrs-6.C: New test. * testsuite/libgomp.c++/ind-base-1.C: New test. * testsuite/libgomp.c++/ind-base-2.C: New test. * testsuite/libgomp.c++/lvalue-tofrom-1.C: New test. * testsuite/libgomp.c++/lvalue-tofrom-2.C: New test. * testsuite/libgomp.c++/map-comma-1.C: New test. * testsuite/libgomp.c++/map-rvalue-ref-1.C: New test. * testsuite/libgomp.c++/struct-ref-1.C: New test. * testsuite/libgomp.c-c++-common/array-field-1.c: New test. * testsuite/libgomp.c-c++-common/array-of-struct-1.c: New test. * testsuite/libgomp.c-c++-common/array-of-struct-2.c: New test.
2024-01-08Daily bump.GCC Administrator1-0/+22
2024-01-07c++: Fix ICE when writing nontrivial variable initializersNathaniel Shead1-1/+2
The attached testcase Patrick found in PR c++/112899 ICEs because it is attempting to write a variable initializer that is no longer in the static_aggregates map. The issue is that, for non-header modules, the loop in c_parse_final_cleanups prunes the static_aggregates list, which means that by the time we get to emitting module information those initialisers have been lost. However, we don't actually need to write non-trivial initialisers for non-header modules, because they've already been emitted as part of the module TU itself. Instead let's just only write the initializers from header modules (which skipped writing them in c_parse_final_cleanups). gcc/cp/ChangeLog: * module.cc (trees_out::write_var_def): Only write initializers in header modules. gcc/testsuite/ChangeLog: * g++.dg/modules/init-5_a.C: New test. * g++.dg/modules/init-5_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-07c++: Export usings referring to global module fragment [PR109679]Nathaniel Shead1-2/+4
This patch stops 'add_binding_entity' from ignoring all names in the global module fragment, since they should still be exported if named in an exported using-declaration. PR c++/109679 gcc/cp/ChangeLog: * module.cc (depset::hash::add_binding_entity): Don't skip names in the GMF if they've been exported with a using declaration. gcc/testsuite/ChangeLog: * g++.dg/modules/using-11.h: New test. * g++.dg/modules/using-11_a.C: New test. * g++.dg/modules/using-11_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-07c++: Follow module grammar more closely [PR110808]Nathaniel Shead1-34/+66
This patch cleans up the parsing of module-declarations and import-declarations to more closely follow the grammar defined by the standard. For instance, currently we allow declarations like 'import A:B', even from an unrelated source file (not part of module A), which causes errors in merging declarations. However, the syntax in [module.import] doesn't even allow this form of import, so this patch prevents this from parsing at all and avoids the error that way. Additionally, we sometimes allow statements like 'import :X' or 'module :X' even when not in a named module, and this causes segfaults, so we disallow this too. PR c++/110808 gcc/cp/ChangeLog: * parser.cc (cp_parser_module_name): Rewrite to handle module-names and module-partitions independently. (cp_parser_module_partition): New function. (cp_parser_module_declaration): Parse module partitions explicitly. Don't change state if parsing module decl failed. (cp_parser_import_declaration): Handle different kinds of import-declarations locally. gcc/testsuite/ChangeLog: * g++.dg/modules/part-hdr-1_c.C: Fix syntax. * g++.dg/modules/part-mac-1_c.C: Likewise. * g++.dg/modules/mod-invalid-1.C: New test. * g++.dg/modules/part-8_a.C: New test. * g++.dg/modules/part-8_b.C: New test. * g++.dg/modules/part-8_c.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-04Daily bump.GCC Administrator1-0/+11
2024-01-03c++: bad direct reference binding via conv fn [PR113064]Patrick Palka1-4/+18
When computing a direct reference binding via a conversion function yields a bad conversion, reference_binding incorrectly commits to that conversion instead of trying a conversion via a temporary. This causes us to reject the first testcase because the bad direct conversion to B&& via the && conversion operator prevents us from considering the good conversion via the & conversion operator and a temporary. (Similar story for the second testcase.) This patch fixes this by making reference_binding not prematurely commit to such a bad direct conversion. We still fall back to it if using a temporary also fails (otherwise the diagnostic for cpp0x/explicit7.C regresses). PR c++/113064 gcc/cp/ChangeLog: * call.cc (reference_binding): Still try a conversion via a temporary if a direct conversion was bad. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/rv-conv4.C: New test. * g++.dg/cpp0x/rv-conv5.C: New test.
2024-01-03openmp: Adjust position of OMP_CLAUSE_INDIRECT in OpenMP clausesKwok Cheung Yeung1-2/+2
Move OMP_CLAUSE_INDIRECT so that it is outside of the range checked by OMP_CLAUSE_SIZE and OMP_CLAUSE_DECL. 2024-01-03 Kwok Cheung Yeung <kcy@codesourcery.com> gcc/c/ * c-parser.cc (c_parser_omp_clause_name): Move handling of indirect clause to correspond to alphabetical order. gcc/cp/ * parser.cc (cp_parser_omp_clause_name): Move handling of indirect clause to correspond to alphabetical order. gcc/ * tree-core.h (enum omp_clause_code): Move OMP_CLAUSE_INDIRECT to before OMP_CLAUSE__SIMDUID_. * tree.cc (omp_clause_num_ops): Update position of entry for OMP_CLAUSE_INDIRECT to correspond with omp_clause_code. (omp_clause_code_name): Likewise.
2024-01-03Update copyright years.Jakub Jelinek62-62/+62
2024-01-03Rotate ChangeLog files.Jakub Jelinek2-4092/+4098
Rotate ChangeLog files for ChangeLogs with yearly cadence.
2023-12-23Daily bump.GCC Administrator1-0/+14
2023-12-21c++: computed goto from catch block [PR81438]Jason Merrill1-8/+34
As with 37722, we don't clean up the exception object if a computed goto leaves a catch block, but we can warn about that. PR c++/81438 gcc/cp/ChangeLog: * decl.cc (poplevel_named_label_1): Handle leaving catch. (check_previous_goto_1): Likewise. (check_goto_1): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/label15.C: Require indirect_jumps. * g++.dg/ext/label16.C: New test.
2023-12-21c++: sizeof... mangling with alias template [PR95298]Jason Merrill2-3/+23
We were getting sizeof... mangling wrong when the argument after substitution was a pack expansion that is not a simple T..., such as list<T>... in variadic-mangle4.C or (A+1)... in variadic-mangle5.C. In the former case we ICEd; in the latter case we wrongly mangled it as sZ <expression>. PR c++/95298 gcc/cp/ChangeLog: * mangle.cc (write_expression): Handle v18 sizeof... bug. * pt.cc (tsubst_pack_expansion): Keep TREE_VEC for sizeof... (tsubst_expr): Don't strip TREE_VEC here. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-mangle2.C: Add non-member. * g++.dg/cpp0x/variadic-mangle4.C: New test. * g++.dg/cpp0x/variadic-mangle5.C: New test. * g++.dg/cpp0x/variadic-mangle5a.C: New test.
2023-12-22Daily bump.GCC Administrator1-0/+49