aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
AgeCommit message (Collapse)AuthorFilesLines
2024-10-08Daily bump.GCC Administrator1-0/+13
2024-10-07c++: -Wmismatched-tags and modulesJason Merrill1-1/+1
In Wmismatched-tags-6.C, we try to compare two declarations of the Cp alias template, and ICE trying to check whether they're in module purview. We need to check DECL_LANG_SPECIFIC like elsewhere in the compiler. gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Only check PURVIEW_P if DECL_LANG_SPECIFIC.
2024-10-07c++: require_deduced_type and modulesJason Merrill1-8/+9
With modules more variables have DECL_LANG_SPECIFIC, so we were failing to call require_deduced_type in constexpr-if30.C. gcc/cp/ChangeLog: * decl2.cc (mark_used): Always check require_deduced_type. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/auto43.C: Adjust diagnostic. * g++.dg/cpp2a/lambda-generic7.C: Likewise.
2024-10-07c++: modules don't require preprocessor outputJason Merrill1-17/+0
init_modules has rejected -M -fmodules-ts on the premise that module dependency analysis requires macro expansion, but this is no longer accurate; P1857 prohibited module directives produced by macro expansion. They can still be dependent on #if directives, but those are still handled with -fdirectives-only. What wasn't working was -M or -dM, because cpp_scan_nooutput never called module_token_pre to implement the import. The simplest fix is to use the -fdirectives-only scan when modules are enabled and teach directives_only_cb about flag_no_output. gcc/cp/ChangeLog: * module.cc (init_modules): Don't warn about -M. gcc/c-family/ChangeLog: * c-ppoutput.cc (preprocess_file): For modules, use directives-only scan even with flag_no_output. (directives_only_cb): Respect flag_no_output. gcc/ChangeLog: * doc/invoke.texi (C++ Module Preprocessing): Allow -M, refer to -fdeps. gcc/testsuite/ChangeLog: * g++.dg/modules/macro-8_a.H: New test. * g++.dg/modules/macro-8_b.C: New test. * g++.dg/modules/macro-8_c.C: New test. * g++.dg/modules/macro-8_d.C: New test.
2024-10-05Daily bump.GCC Administrator1-0/+27
2024-10-04c++: Allow references to internal-linkage vars in C++11 [PR113266]Nathaniel Shead1-5/+12
[temp.arg.nontype] changed in C++11 to allow naming internal-linkage variables and functions. We currently already handle internal-linkage functions, but variables were missed; this patch updates this. PR c++/113266 PR c++/116911 gcc/cp/ChangeLog: * parser.cc (cp_parser_template_argument): Allow internal-linkage variables since C++11. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/nontype6.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-10-04c++: Return the underlying decl rather than the USING_DECL from ↵Nathaniel Shead1-2/+2
update_binding [PR116913] Users of pushdecl assume that the returned decl will be a possibly updated decl matching the one that was passed in. My r15-3910 change broke this since in some cases we would now return USING_DECLs; this patch fixes the situation. PR c++/116913 gcc/cp/ChangeLog: * name-lookup.cc (update_binding): Return the strip_using'd old decl rather than the binding. gcc/testsuite/ChangeLog: * g++.dg/lookup/using70.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-10-03c++: record template specialization hashJason Merrill2-23/+23
A lot of compile time of template-heavy code is spent in re-hashing hashtable elements upon expansion. The following records the hash in the hash element. This speeds up C++20 compilation of stdc++.h by about 25% for about a 0.1% increase in memory usage. With the hash value in the entry, we don't need to pass it separately to the find functions. Adding default arguments to the spec and hash fields simplifies spec_entry initialization and avoids problems from hash starting with an indeterminate value. gcc/cp/ChangeLog: * cp-tree.h (spec_entry::hash): New member. * pt.cc (spec_hasher::hash): Set it and return it. (maybe_process_partial_specialization): Clear it when changing tmpl/args. (lookup_template_class): Likewise, don't pass hash to find. (retrieve_specialization): Set it, don't pass hash to find. (register_specialization): Don't pass hash to find. (reregister_specialization): Likewise. (match_mergeable_specialization): Likewise. (add_mergeable_specialization): Likewise. Co-authored-by: Richard Biener <rguenther@suse.de>
2024-10-04Daily bump.GCC Administrator1-0/+25
2024-10-03c++: free garbage vec in coerce_template_parmsJason Merrill1-1/+9
coerce_template_parms can create two different vecs for the inner template arguments, new_inner_args and (potentially) the result of expand_template_argument_pack. One or the other, or possibly both, end up being garbage: in the typical case, the expanded vec is garbage because it's only used as the source for convert_template_argument. In some dependent cases, the new vec is garbage because we decide to return the original args instead. In these cases, ggc_free the garbage vec to reduce the memory overhead of overload resolution. gcc/cp/ChangeLog: * pt.cc (coerce_template_parms): Free garbage vecs. Co-authored-by: Richard Biener <rguenther@suse.de>
2024-10-03Revert "c++: free garbage vec in coerce_template_parms"Jason Merrill1-30/+6
This broke bootstrap, improving. This reverts commit 5b08ae503dd4aef2789a667daaf1984e7cc94aaa.
2024-10-03c++: add -Wdeprecated-literal-operator [CWG2521]Jason Merrill1-4/+29
C++23 CWG issue 2521 (https://wg21.link/cwg2521) deprecates user-defined literal operators declared with the optional space between "" and the suffix. Many testcases used that syntax; I removed the space from most of them, and added C++23 warning tests to a few. CWG 2521 gcc/ChangeLog: * doc/invoke.texi: Document -Wdeprecated-literal-operator. gcc/c-family/ChangeLog: * c.opt: Add -Wdeprecated-literal-operator. * c-opts.cc (c_common_post_options): Default on in C++23. * c.opt.urls: Regenerate. gcc/cp/ChangeLog: * parser.cc (location_between): New. (cp_parser_operator): Handle -Wdeprecated-literal-operator. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/udlit-string-literal.h * g++.dg/cpp0x/Wliteral-suffix2.C * g++.dg/cpp0x/constexpr-55708.C * g++.dg/cpp0x/gnu_fext-numeric-literals.C * g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C * g++.dg/cpp0x/pr51420.C * g++.dg/cpp0x/pr60209-neg.C * g++.dg/cpp0x/pr60209.C * g++.dg/cpp0x/pr61038.C * g++.dg/cpp0x/std_fext-numeric-literals.C * g++.dg/cpp0x/std_fno-ext-numeric-literals.C * g++.dg/cpp0x/udlit-addr.C * g++.dg/cpp0x/udlit-args-neg.C * g++.dg/cpp0x/udlit-args.C * g++.dg/cpp0x/udlit-args2.C * g++.dg/cpp0x/udlit-clink-neg.C * g++.dg/cpp0x/udlit-concat-neg.C * g++.dg/cpp0x/udlit-concat.C * g++.dg/cpp0x/udlit-constexpr.C * g++.dg/cpp0x/udlit-cpp98-neg.C * g++.dg/cpp0x/udlit-declare-neg.C * g++.dg/cpp0x/udlit-embed-quote.C * g++.dg/cpp0x/udlit-extended-id-1.C * g++.dg/cpp0x/udlit-extended-id-3.C * g++.dg/cpp0x/udlit-extern-c.C * g++.dg/cpp0x/udlit-friend.C * g++.dg/cpp0x/udlit-general.C * g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C * g++.dg/cpp0x/udlit-implicit-conv-neg.C * g++.dg/cpp0x/udlit-inline.C * g++.dg/cpp0x/udlit-mangle.C * g++.dg/cpp0x/udlit-member-neg.C * g++.dg/cpp0x/udlit-namespace.C * g++.dg/cpp0x/udlit-nofunc-neg.C * g++.dg/cpp0x/udlit-nonempty-str-neg.C * g++.dg/cpp0x/udlit-nosuffix-neg.C * g++.dg/cpp0x/udlit-nounder-neg.C * g++.dg/cpp0x/udlit-operator-neg.C * g++.dg/cpp0x/udlit-overflow-neg.C * g++.dg/cpp0x/udlit-overflow.C * g++.dg/cpp0x/udlit-preproc-neg.C * g++.dg/cpp0x/udlit-raw-length.C * g++.dg/cpp0x/udlit-raw-op-string-neg.C * g++.dg/cpp0x/udlit-raw-op.C * g++.dg/cpp0x/udlit-raw-str.C * g++.dg/cpp0x/udlit-resolve-char8_t.C * g++.dg/cpp0x/udlit-resolve.C * g++.dg/cpp0x/udlit-shadow-neg.C * g++.dg/cpp0x/udlit-string-length.C * g++.dg/cpp0x/udlit-suffix-neg.C * g++.dg/cpp0x/udlit-template.C * g++.dg/cpp0x/udlit-tmpl-arg-neg.C * g++.dg/cpp0x/udlit-tmpl-arg-neg2.C * g++.dg/cpp0x/udlit-tmpl-arg.C * g++.dg/cpp0x/udlit-tmpl-parms-neg.C * g++.dg/cpp0x/udlit-tmpl-parms.C * g++.dg/cpp1y/pr57640.C * g++.dg/cpp1y/pr88872.C * g++.dg/cpp26/unevalstr1.C * g++.dg/cpp2a/concepts-pr60391.C * g++.dg/cpp2a/consteval-prop21.C * g++.dg/cpp2a/nontype-class6.C * g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C * g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C * g++.dg/cpp2a/udlit-class-nttp-ctad.C * g++.dg/cpp2a/udlit-class-nttp-neg.C * g++.dg/cpp2a/udlit-class-nttp-neg2.C * g++.dg/cpp2a/udlit-class-nttp.C * g++.dg/ext/is_convertible2.C * g++.dg/lookup/pr87269.C * g++.dg/cpp0x/udlit_system_header: Adjust for C++23 deprecated operator "" _suffix. * g++.dg/DRs/dr2521.C: New test.
2024-10-03c++: free garbage vec in coerce_template_parmsJason Merrill1-6/+30
coerce_template_parms can create two different vecs for the inner template arguments, new_inner_args and (potentially) the result of expand_template_argument_pack. One or the other, or possibly both, end up being garbage: in the typical case, the expanded vec is garbage because it's only used as the source for convert_template_argument. In some dependent cases, the new vec is garbage because we decide to return the original args instead. In these cases, ggc_free the garbage vec to reduce the memory overhead of overload resolution. gcc/cp/ChangeLog: * pt.cc (struct free_if_changed_proxy): New. (coerce_template_parms): Use it. Co-authored-by: Richard Biener <rguenther@suse.de>
2024-10-03Daily bump.GCC Administrator1-0/+17
2024-10-02c++: Fix regression introduced by r15-3796 [PR116722]Simon Martin1-0/+6
Jason pointed out that the fix I made for PR116722 via r15-3796 introduces a regression when running constexpr-dynamic10.C with -fimplicit-constexpr. The problem is that my change makes us leave cxx_eval_call_expression early, and bypass the call to cxx_eval_thunk_call (through a recursive call to cxx_eval_call_expression) that used to emit an error for that testcase with -fimplicit-constexpr. This patch emits the error if !ctx->quiet before bailing out because the {con,de}structor belongs to a class with virtual bases. PR c++/116722 gcc/cp/ChangeLog: * constexpr.cc (cxx_bind_parameters_in_call): When !ctx->quiet, emit error before bailing out due to a call to {con,de}structor for a class with virtual bases.
2024-10-02Replace another missed iterative_hash_objectRichard Biener1-1/+1
I missed one that's actually hit quite a lot, hashing of the canonical type TYPE_HASH. gcc/cp/ * pt.cc (iterative_hash_template_arg): Use iterative_hash_hashval_t to hash TYPE_HASH.
2024-10-02Speedup iterative_hash_template_argRichard Biener1-3/+3
Using iterative_hash_object is expensive compared to using iterative_hash_hashval_t which is fit for integer sized values. The following reduces the number of perf cycles spent in iterative_hash_template_arg and iterative_hash combined by 20%. gcc/cp/ * pt.cc (iterative_hash_template_arg): Avoid using iterative_hash_object.
2024-10-02Daily bump.GCC Administrator1-0/+17
2024-10-01c++: introduce __builtin_is_virtual_base_ofGiuseppe D'Angelo6-4/+32
P2985R0 (C++26) introduces std::is_virtual_base_of; this is the compiler builtin that will back up the library trait (which strictly requires compiler support). The name has been chosen to match LLVM/MSVC's, as per the discussion here: https://github.com/llvm/llvm-project/issues/98310 The actual user-facing type trait in libstdc++ will be added later. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): New diagnostic. * cp-trait.def (IS_VIRTUAL_BASE_OF): New builtin. * cp-tree.h (enum base_access_flags): Add a new flag to be able to request a search for a virtual base class. * cxx-pretty-print.cc (pp_cxx_userdef_literal): Update the list of GNU extensions to the grammar. * search.cc (struct lookup_base_data_s): Add a field to request searching for a virtual base class. (dfs_lookup_base): Add the ability to look for a virtual base class. (lookup_base): Forward the flag to dfs_lookup_base. * semantics.cc (trait_expr_value): Implement the builtin by calling lookup_base with the new flag. (finish_trait_expr): Handle the new builtin. gcc/ChangeLog: * doc/extend.texi: Document the new __builtin_is_virtual_base_of builtin; amend the docs for __is_base_of. gcc/testsuite/ChangeLog: * g++.dg/ext/is_virtual_base_of.C: New test. * g++.dg/ext/is_virtual_base_of_diagnostic.C: New test. Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-10-01Daily bump.GCC Administrator1-0/+17
2024-09-30c++: concept in default argument [PR109859]Marek Polacek1-2/+7
1) We're hitting the assert in cp_parser_placeholder_type_specifier. It says that if it turns out to be false, we should do error() instead. Do so, then. 2) lambda-targ8.C should compile fine, though. The problem was that local_variables_forbidden_p wasn't cleared when we're about to parse the optional template-parameter-list for a lambda in a default argument. PR c++/109859 gcc/cp/ChangeLog: * parser.cc (cp_parser_lambda_declarator_opt): Temporarily clear local_variables_forbidden_p. (cp_parser_placeholder_type_specifier): Turn an assert into an error. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-defarg3.C: New test. * g++.dg/cpp2a/lambda-targ8.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-30diagnostics: use "%e" to avoid intermediate strings [PR116613]David Malcolm1-7/+11
Various diagnostics build an intermediate string, potentially with colorization, and then use this in a diagnostic message. This won't work if we have multiple diagnostic sinks, where some might be colorized and some not. This patch reworks such places using "%e" and pp_element subclasses, so that any colorization happens within report_diagnostic's call to pp_format. gcc/analyzer/ChangeLog: PR other/116613 * kf-analyzer.cc: Include "pretty-print-markup.h". (kf_analyzer_dump_escaped::impl_call_pre): Defer colorization choices by eliminating the construction of a intermediate string, replacing it with a new pp_element subclass via "%e". gcc/ChangeLog: PR other/116613 * attribs.cc: Include "pretty-print-markup.h". (decls_mismatched_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. (maybe_diag_alias_attributes): As above, replacing pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e" in two places. * attribs.h (decls_mismatched_attributes): Update decl. * gimple-ssa-warn-access.cc: Include "pretty-print-markup.h". (pass_waccess::maybe_warn_memmodel): Defer colorization choices by replacing printing to a pretty_printer * param with use of pp_markup::comma_separated_quoted_strings and "%e". (pass_waccess::maybe_warn_memmodel): Likewise, replacing printing to a temporary buffer. * pretty-print-markup.h (class pp_markup::comma_separated_quoted_strings): New. * pretty-print.cc (pp_markup::comma_separated_quoted_strings::add_to_phase_2): New. (selftest::test_pp_printf_within_pp_element): New. (selftest::test_comma_separated_quoted_strings): New. (selftest::pretty_print_cc_tests): Call the new tests. gcc/cp/ChangeLog: PR other/116613 * pt.cc: Include "pretty-print-markup.h". (warn_spec_missing_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. Replace pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e". gcc/testsuite/ChangeLog: PR other/116613 * c-c++-common/analyzer/escaping-1.c: Update expected results to remove type information from C++ results. Previously we were using %qD with default_tree_printer, which used lang_hooks.decl_printable_name, whereas now we're using %qD with a clone of the cxx_pretty_printer. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-28Daily bump.GCC Administrator1-0/+69
2024-09-28c++: Implement resolution for DR 36 [PR116160]Nathaniel Shead1-5/+7
This implements part of P1787 to no longer complain about redeclaring an entity via using-decl other than in a class scope. PR c++/116160 gcc/cp/ChangeLog: * name-lookup.cc (supplement_binding): Allow redeclaration via USING_DECL if not in class scope. (do_nonmember_using_decl): Remove function-scope exemption. (push_using_decl_bindings): Remove outdated comment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/using-enum-3.C: No longer expect an error. * g++.dg/lookup/using53.C: Remove XFAIL. * g++.dg/cpp2a/using-enum-11.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-28c++: Don't strip USING_DECLs when updating local bindings [PR116748]Nathaniel Shead1-5/+7
Currently update_binding strips USING_DECLs too eagerly, leading to ICEs in pop_local_decl as it can't find the decl it's popping in the binding list. Let's rather try to keep the original USING_DECL around. This also means that using59.C can point to the location of the using-decl rather than the underlying object directly; this is in the direction required to fix PR c++/106851 (though more work is needed to emit properly helpful diagnostics here). PR c++/116748 gcc/cp/ChangeLog: * name-lookup.cc (update_binding): Maintain USING_DECLs in the binding slots. gcc/testsuite/ChangeLog: * g++.dg/lookup/using59.C: Update location. * g++.dg/lookup/using69.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-28c++/modules: Propagate purview/import for templates in duplicate_decls ↵Nathaniel Shead1-0/+10
[PR116803] We need to ensure that for a declaration in the module purview, that the resulting declaration has PURVIEW_P set and IMPORT_P cleared so that we understand it might be something requiring exporting. This is normally handled for a declaration by set_instantiating_module, but when this declaration is a redeclaration duplicate_decls needs to propagate this to olddecl. This patch only changes the logic for template declarations, because in the non-template case the whole contents of olddecl's DECL_LANG_SPECIFIC is replaced with newdecl's (which includes these flags), so there's nothing to do. PR c++/116803 gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Propagate DECL_MODULE_PURVIEW_P and DECL_MODULE_IMPORT_P for template redeclarations. gcc/testsuite/ChangeLog: * g++.dg/modules/merge-18_a.H: New test. * g++.dg/modules/merge-18_b.H: New test. * g++.dg/modules/merge-18_c.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27c++: ICE with structured bindings and m-d array [PR102594]Marek Polacek1-1/+7
We ICE in decay_conversion with this test: struct S { S() {} }; S arr[1][1]; auto [m](arr3); But not when the last line is: auto [n] = arr3; Therefore the difference is between copy- and direct-init. In particular, in build_vec_init we have: if (direct_init) from = build_tree_list (NULL_TREE, from); and then we call build_vec_init again with init==from. Then decay_conversion gets the TREE_LIST and it crashes. build_aggr_init has: /* Wrap the initializer in a CONSTRUCTOR so that build_vec_init recognizes it as direct-initialization. */ init = build_constructor_single (init_list_type_node, NULL_TREE, init); CONSTRUCTOR_IS_DIRECT_INIT (init) = true; so I propose to do the same in build_vec_init. PR c++/102594 gcc/cp/ChangeLog: * init.cc (build_vec_init): Build up a CONSTRUCTOR to signal direct-initialization rather than a TREE_LIST. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/decomp61.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27c++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]Arsen Arsenović1-1/+3
If we reach a CLEANUP_POINT_EXPR while trying to walk statements, we actually care about the statement or statement list contained within it. Indeed, such a construction started happening with r15-3513-g964577c31df206, after temporary promotion. In the test case presented in PR116793, the compiler generated: <<cleanup_point { struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3]; int T002 [value-expr: frame_ptr->T002_2_3]; int T002 [value-expr: frame_ptr->T002_2_3]; <<cleanup_point <<< Unknown tree: expr_stmt (void) (T002 = TARGET_EXPR <D.20994, 3>) >>>>>; struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3]; <<cleanup_point <<< Unknown tree: expr_stmt (void) (Aw0 = TARGET_EXPR <D.20995, func ((int &) &T002)>) >>>>>; <<cleanup_point <<< Unknown tree: expr_stmt (void) (D.22450 = <<< Unknown tree: co_await TARGET_EXPR <D.20995, func ((int &) &T002)> Aw0 {_cleanup_task::await_ready (&Aw0), _cleanup_task::await_suspend<_task1::promise_type> (&Aw0, TARGET_EXPR <D.21078, _Coro_self_handle>), <<< Unknown tree: aggr_init_expr 4 await_resume D.22443 &Aw0 >>>} 0 >>>) >>>>>; <<cleanup_point <<< Unknown tree: expr_stmt (void) (D.20991 = (struct tuple &) &D.22450) >>>>>; } D.22467 = 1; int & i [value-expr: frame_ptr->i_1_2]; <<cleanup_point <<< Unknown tree: expr_stmt (void) (i = std::get<0, int&> (NON_LVALUE_EXPR <D.20991>)) >>>>>;>>; ... i.e. a statement list within a cleanup point. In such a case, we don't actually care about the cleanup point, but we do care about the statement inside, so, we can just walk down into the CLEANUP_POINT_EXPR. PR c++/116793 gcc/cp/ChangeLog: * coroutines.cc (await_statement_expander): Just process subtrees if encountering a CLEANUP_POINT_EXPR. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr116793-1.C: New test.
2024-09-27c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_voidArsen Arsenović3-53/+55
convert_to_void has, so far, when converting a co_await expression to void altered the await_resume expression of a co_await so that it is also converted to void. This meant that the type of the await_resume expression, which is also supposed to be the type of the whole co_await expression, was not the same as the type of the CO_AWAIT_EXPR tree. While this has not caused problems so far, it is unexpected, I think. Also, convert_to_void had a special case when an INDIRECT_REF wrapped a CALL_EXPR. In this case, we also diagnosed maybe_warn_nodiscard. This was a duplication of logic related to converting call expressions to void. Instead, we can generalize a bit, and rather discard the expression that was implicitly dereferenced instead. This patch changes the diagnostic of: void f(struct S* x) { static_cast<volatile S&>(*x); } ... from: warning: indirection will not access object of incomplete type 'volatile S' in statement ... to: warning: implicit dereference will not access object of type ‘volatile S’ in statement ... but should have no impact in other cases. gcc/cp/ChangeLog: * coroutines.cc (co_await_get_resume_call): Return a tree directly, rather than a tree pointer. * cp-tree.h (co_await_get_resume_call): Adjust signature accordingly. * cvt.cc (convert_to_void): Do not alter CO_AWAIT_EXPRs when discarding them. Simplify handling implicit INDIRECT_REFs. gcc/testsuite/ChangeLog: * g++.dg/coroutines/nodiscard-1.C: New test.
2024-09-27c++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]Arsen Arsenović1-3/+9
If such a diagnostic is necessary, it has already been emitted, otherwise, it is not correct and emitting it here is inactionable by the user, and bogus. PR c++/116502 gcc/cp/ChangeLog: * coroutines.cc (maybe_promote_temps): Convert temporary initializers to void without complaining. gcc/testsuite/ChangeLog: * g++.dg/coroutines/maybe-unused-1.C: New test. * g++.dg/coroutines/pr116502.C: New test.
2024-09-27c++/modules: Allow imported references in constant expressionsNathaniel Shead1-1/+1
Currently the streaming code uses TREE_CONSTANT to determine whether an entity will have a definition that is interesting to stream out. This is not sufficient, however; we also need to write the definition of references, since although not TREE_CONSTANT they can still be usable in constant expressions. As such this patch uses the existing decl_maybe_constant_var function which correctly handles this case. gcc/cp/ChangeLog: * module.cc (has_definition): Use decl_maybe_constant_var instead of TREE_CONSTANT. gcc/testsuite/ChangeLog: * g++.dg/modules/cexpr-5_a.C: New test. * g++.dg/modules/cexpr-5_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27c++/modules: Fix linkage checks for exported using-declsNathaniel Shead1-24/+33
This fixes some inconsistencies with what kinds of linkage various entities are assumed to have. This also fixes handling of exported using-decls binding to GM entities and type aliases to better align with the standard's requirements. gcc/cp/ChangeLog: * name-lookup.cc (check_can_export_using_decl): Handle internal linkage GM entities (but ignore in header units); use linkage of entity ultimately referred to by aliases. gcc/testsuite/ChangeLog: * g++.dg/modules/using-10.C: Add tests for no-linkage, fix expected linkage of aliases. * g++.dg/modules/using-12.C: Likewise. * g++.dg/modules/using-27.C: New test. * g++.dg/modules/using-28_a.C: New test. * g++.dg/modules/using-28_b.C: New test. * g++.dg/modules/using-29.H: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27c++/modules: Use decl_linkage in maybe_record_mergeable_declNathaniel Shead1-8/+1
This avoids any possible inconsistencies (current or future) about whether a declaration is internal or not. gcc/cp/ChangeLog: * name-lookup.cc (maybe_record_mergeable_decl): Use decl_linkage instead of ad-hoc checks. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27c++: Update decl_linkage for C++11Nathaniel Shead2-35/+58
Currently modules code uses a variety of ad-hoc methods to attempt to determine whether an entity has internal linkage, which leads to inconsistencies and some correctness issues as different edge cases are neglected. While investigating this I discovered 'decl_linkage', but it doesn't seem to have been updated to account for the C++11 clarification that all entities declared in an anonymous namespace are internal. I'm not convinced that even in C++98 it was intended that e.g. types in anonymous namespaces should be external, but some tests in the testsuite rely on this, so for compatibility I restricted those modifications to C++11 and later. This should have relatively minimal impact as not much seems to actually rely on decl_linkage, but does change the mangling of symbols in anonymous namespaces slightly. Previously, we had namespace { int x; // mangled as '_ZN12_GLOBAL__N_11xE' static int y; // mangled as '_ZN12_GLOBAL__N_1L1yE' } but with this patch the x is now mangled like y (with the extra 'L'). For contrast, Clang currently mangles neither x nor y with the 'L'. Since this only affects internal-linkage entities I don't believe this should break ABI in any observable fashion. gcc/cp/ChangeLog: * name-lookup.cc (do_namespace_alias): Propagate TREE_PUBLIC for namespace aliases. * tree.cc (decl_linkage): Update rules for C++11. gcc/testsuite/ChangeLog: * g++.dg/modules/mod-sym-4.C: Update test to account for non-static internal-linkage variables new mangling. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27Daily bump.GCC Administrator1-0/+6
2024-09-26c++: tweak for -Wrange-loop-construct [PR116731]Marek Polacek1-3/+5
This PR reports that the warning would be better off using a check for trivially constructible rather than trivially copyable. LLVM accepted a similar fix: https://github.com/llvm/llvm-project/issues/47355 PR c++/116731 gcc/cp/ChangeLog: * parser.cc (warn_for_range_copy): Check if TYPE is trivially constructible, not copyable. gcc/testsuite/ChangeLog: * g++.dg/warn/Wrange-loop-construct3.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-26Daily bump.GCC Administrator1-0/+21
2024-09-25c++: use TARGET_EXPR accessorsMarek Polacek5-31/+32
While futzing around with PR116416 I noticed that we can use the _SLOT and _INITIAL macros to make the code more readable. gcc/c-family/ChangeLog: * c-pretty-print.cc (c_pretty_printer::primary_expression): Use TARGET_EXPR accessors. (c_pretty_printer::expression): Likewise. gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Use TARGET_EXPR accessors. (finish_co_yield_expr): Likewise. (register_awaits): Likewise. (tmp_target_expr_p): Likewise. (flatten_await_stmt): Likewise. * error.cc (dump_expr): Likewise. * semantics.cc (finish_omp_target_clauses): Likewise. * tree.cc (bot_manip): Likewise. (cp_tree_equal): Likewise. * typeck.cc (cxx_mark_addressable): Likewise. (cp_build_compound_expr): Likewise. (cp_build_modify_expr): Likewise. (check_return_expr): Likewise. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-25OpenMP: Update OMP_REQUIRES_TARGET_USED for declare_target + interopTobias Burnus1-0/+3
Older versions of the OpenMP specification were not clear about what counted as device usage. Newer (like TR13) are rather clear. Hence, this commit adds GCC's target-used flag also when a 'declare target' or an 'interop' are encountered. (The latter only to Fortran as C/C++ parsing support is still missing.) TR13 also lists 'dispatch' as target-used construct (as it has the device clause) and 'device_safesync' as clause with global requirement property, but both are not yet supported in GCC. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_declare_target): Set target-used bit in omp_requires_mask. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_declare_target): Set target-used bit in omp_requires_mask. gcc/fortran/ChangeLog: * parse.cc (decode_omp_directive): Set target-used bit of omp_requires_mask when encountering the declare_target or interop directive. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/interop-1.f90: Add dg-error for missing omp requires requirement and declare_variant usage. * gfortran.dg/gomp/requires-8.f90: Likewise.
2024-09-25Daily bump.GCC Administrator1-0/+48
2024-09-24c++: Implement C++23 P2718R0 - Wording for P2644R1 Fix for Range-based for ↵Jakub Jelinek6-22/+145
Loop [PR107637] The following patch implements the C++23 P2718R0 paper - Wording for P2644R1 Fix for Range-based for Loop. The patch introduces a new option, -f{,no-}range-for-ext-temps so that user can control the behavior even in older C++ versions. The option is on by default in C++23 and later (-fno-range-for-ext-temps is an error in that case) and in the -std=gnu++11 ... -std=gnu++20 modes (one can use -fno-range-for-ext-temps to request previous behavior in that case), and is not enabled by default in -std=c++11 ... -std=c++20 modes but one can explicitly enable it with -frange-for-ext-temps. As all the temporaries from __for_range initialization should have life extended until the end of __for_range scope, this patch disables (for -frange-for-ext-temps and if !processing_template_decl) CLEANUP_POINT_EXPR wrapping of the __for_range declaration, also disables -Wdangling-reference warning as well as the rest of extend_ref_init_temps (we know the __for_range temporary is not TREE_STATIC and as all the temporaries from the initializer will be life extended, we shouldn't try to handle temporaries referenced by references any differently) and adds an extra push_stmt_list/pop_stmt_list before cp_finish_decl of __for_range and after end of the for body and wraps all that into CLEANUP_POINT_EXPR. I had to repeat that also for OpenMP range loops because those are handled differently. 2024-09-24 Jakub Jelinek <jakub@redhat.com> PR c++/107637 gcc/ * omp-general.cc (find_combined_omp_for, find_nested_loop_xform): Handle CLEANUP_POINT_EXPR like TRY_FINALLY_EXPR. * doc/invoke.texi (frange-for-ext-temps): Document. Add -fconcepts to the C++ option list. gcc/c-family/ * c.opt (frange-for-ext-temps): New option. * c-opts.cc (c_common_post_options): Set flag_range_for_ext_temps for C++23 or later or for C++11 or later in !flag_iso mode if the option wasn't set by user. * c-cppbuiltin.cc (c_cpp_builtins): Change __cpp_range_based_for value for flag_range_for_ext_temps from 201603L to 202212L in C++17 or later. * c-omp.cc (c_find_nested_loop_xform_r): Handle CLEANUP_POINT_EXPR like TRY_FINALLY_EXPR. gcc/cp/ * cp-tree.h: Implement C++23 P2718R0 - Wording for P2644R1 Fix for Range-based for Loop. (cp_convert_omp_range_for): Add bool tmpl_p argument. (find_range_for_decls): Declare. * parser.cc (cp_convert_range_for): For flag_range_for_ext_temps call push_stmt_list () before cp_finish_decl for range_temp and save it temporarily to FOR_INIT_STMT. (cp_convert_omp_range_for): Add tmpl_p argument. If set, remember DECL_NAME of range_temp and for cp_finish_decl call restore it before clearing it again, if unset, don't adjust DECL_NAME of range_temp at all. (cp_parser_omp_loop_nest): For flag_range_for_ext_temps range for add CLEANUP_POINT_EXPR around sl. Call find_range_for_decls and adjust DECL_NAMEs for range fors if not processing_template_decl. Adjust cp_convert_omp_range_for caller. Remove superfluous backslash at the end of line. * decl.cc (initialize_local_var): For flag_range_for_ext_temps temporarily clear stmts_are_full_exprs_p rather than set for for_range__identifier decls. * call.cc (extend_ref_init_temps): For flag_range_for_ext_temps return init early for for_range__identifier decls. * semantics.cc (find_range_for_decls): New function. (finish_for_stmt): Use it. For flag_range_for_ext_temps if cp_convert_range_for set FOR_INIT_STMT, pop_stmt_list it and wrap into CLEANUP_POINT_EXPR. * pt.cc (tsubst_omp_for_iterator): Adjust tsubst_omp_for_iterator caller. (tsubst_stmt) <case OMP_FOR>: For flag_range_for_ext_temps if there are any range fors in the loop nest, add push_stmt_list starting before the initializations, pop_stmt_list it after the body and wrap into CLEANUP_POINT_EXPR. Change DECL_NAME of range for temps from NULL to for_range_identifier. gcc/testsuite/ * g++.dg/cpp23/range-for1.C: New test. * g++.dg/cpp23/range-for2.C: New test. * g++.dg/cpp23/range-for3.C: New test. * g++.dg/cpp23/range-for4.C: New test. * g++.dg/cpp23/range-for5.C: New test. * g++.dg/cpp23/range-for6.C: New test. * g++.dg/cpp23/range-for7.C: New test. * g++.dg/cpp23/range-for8.C: New test. * g++.dg/cpp23/feat-cxx2b.C (__cpp_range_based_for): Check for 202212L rather than 201603L. * g++.dg/cpp26/feat-cxx26.C (__cpp_range_based_for): Likewise. * g++.dg/warn/Wdangling-reference4.C: Don't expect warning for C++23 or newer. Use dg-additional-options rather than dg-options. libgomp/ * testsuite/libgomp.c++/range-for-1.C: New test. * testsuite/libgomp.c++/range-for-2.C: New test. * testsuite/libgomp.c++/range-for-3.C: New test. * testsuite/libgomp.c++/range-for-4.C: New test. * testsuite/libgomp.c++/range-for-5.C: New test.
2024-09-24c++/contracts: ICE in build_contract_condition_function [PR116490]Nina Dinka Ranns1-3/+9
We currently do not expect comdat group of the guarded function to be set at the time of generating pre and post check function. However, in the case of an explicit instantiation, the guarded function has been added to a comdat group before generating contract check functions, which causes the observed ICE. Current assert removed and an additional check for comdat group of the guarded function added. With this change, the pre and post check functions get added to the same comdat group of the guarded function if the guarded function is already placed in a comdat group. PR c++/116490 gcc/cp/ChangeLog: * contracts.cc (build_contract_condition_function): added a check for comdat group of the guarded function. If set, the condition check function is added to the same comdat group. gcc/testsuite/ChangeLog: * g++.dg/contracts/pr116490.C: New test. Signed-off-by: Nina Ranns <dinka.ranns@gmail.com>
2024-09-24OpenMP: Add support for 'self_maps' to the 'require' directiveTobias Burnus1-0/+3
'self_maps' implies 'unified_shared_memory', except that the latter also permits that explicit maps copy data to device memory while self_maps does not. In GCC, currently, both are handled identical. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_requires): Handle self_maps clause. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_requires): Handle self_maps clause. gcc/fortran/ChangeLog: * gfortran.h (enum gfc_omp_requires_kind): Add OMP_REQ_SELF_MAPS. (gfc_namespace): Enlarge omp_requires bitfield. * module.cc (enum ab_attribute, attr_bits): Add AB_OMP_REQ_SELF_MAPS. (mio_symbol_attribute): Handle it. * openmp.cc (gfc_check_omp_requires, gfc_match_omp_requires): Handle self_maps clause. * parse.cc (gfc_parse_file): Handle self_maps clause. gcc/ChangeLog: * lto-cgraph.cc (output_offload_tables, omp_requires_to_name): Handle self_maps clause. * omp-general.cc (struct omp_ts_info, omp_context_selector_matches): Likewise for the associated trait. * omp-general.h (enum omp_requires): Add OMP_REQUIRES_SELF_MAPS. * omp-selectors.h (enum omp_ts_code): Add OMP_TRAIT_IMPLEMENTATION_SELF_MAPS. include/ChangeLog: * gomp-constants.h (GOMP_REQUIRES_SELF_MAPS): #define. libgomp/ChangeLog: * plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Accept self_maps clause. * plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices): Likewise. * libgomp.texi (TR13 Impl. Status): Set to 'Y'. * target.c (gomp_requires_to_name, GOMP_offload_register_ver, gomp_target_init): Handle self_maps clause. * testsuite/libgomp.fortran/self_maps.f90: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/declare-variant-1.c: Add self_maps test. * c-c++-common/gomp/requires-4.c: Likewise. * gfortran.dg/gomp/declare-variant-3.f90: Likewise. * c-c++-common/gomp/requires-2.c: Update dg-error msg. * gfortran.dg/gomp/requires-2.f90: Likewise. * gfortran.dg/gomp/requires-self-maps-aux.f90: New. * gfortran.dg/gomp/requires-self-maps.f90: New.
2024-09-24Daily bump.GCC Administrator1-0/+20
2024-09-23c++: diagnose this specifier in requires expr [PR116798]Marek Polacek1-3/+8
We don't detect an explicit object parameter in a requires expression. We can get there by way of requires-expression -> requirement-parameter-list -> parameter-declaration-clause -> ... -> parameter-declaration with this[opt]. But [dcl.fct]/5 doesn't allow an explicit object parameter in this context. So let's fix it like r14-9033 and not like r14-8832. PR c++/116798 gcc/cp/ChangeLog: * parser.cc (cp_parser_parameter_declaration): Detect an explicit object parameter in a requires expression. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics12.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-23c++: Don't crash when mangling member with anonymous union or template type ↵Simon Martin1-1/+7
[PR100632, PR109790] We currently crash upon mangling members that have an anonymous union or a template operator type. The problem is that before calling write_unqualified_name, write_member_name asserts that it has a declaration whose DECL_NAME is an identifier node that is not that of an operator. This is wrong: - In PR100632, it's an anonymous union declaration, hence a 0 DECL_NAME - In PR109790, it's a legitimate template declaration for an operator (this was accepted up to GCC 10) This assert was added via r11-6301, to be sure that we do write the "on" marker for operator members. This patch removes that assert and instead - Lets members with an anonymous union type go through - For operators, adds the missing "on" marker for ABI versions greater than the highest usable with GCC 10 PR c++/109790 PR c++/100632 gcc/cp/ChangeLog: * mangle.cc (write_member_name): Handle members whose type is an anonymous union member. Write missing "on" marker for operators when ABI version is at least 16. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/decltype83.C: New test. * g++.dg/cpp0x/decltype83a.C: New test. * g++.dg/cpp1y/lambda-ice3.C: New test. * g++.dg/cpp1y/lambda-ice3a.C: New test. * g++.dg/cpp2a/nontype-class67.C: New test.
2024-09-23c++: Don't ICE due to artificial constructor parameters [PR116722]Simon Martin1-1/+10
The following code triggers an ICE === cut here === class base {}; class derived : virtual public base { public: template<typename Arg> constexpr derived(Arg) {} }; int main() { derived obj(1.); } === cut here === The problem is that cxx_bind_parameters_in_call ends up attempting to convert a REAL_CST (the first non artificial parameter) to INTEGER_TYPE (the type of the __in_chrg parameter), which ICEs. This patch changes cxx_bind_parameters_in_call to return early if it's called with a *structor that has an __in_chrg or __vtt_parm parameter since the expression won't be a constant expression. Note that in the test case, the constructor is not constexpr-suitable, however it's OK since it's a template according to my read of paragraph (3) of [dcl.constexpr]. PR c++/116722 gcc/cp/ChangeLog: * constexpr.cc (cxx_bind_parameters_in_call): Leave early for {con,de}structors of classes with virtual bases. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-ctor22.C: New test.
2024-09-21Daily bump.GCC Administrator1-0/+33
2024-09-20diagnostics: convert text hooks to use diagnostic_text_output_format [PR116613]David Malcolm2-70/+81
The diagnostic_starter and diagnostic_finalizer callbacks and most of their support subroutines are only used by the "text" output format. Emphasize this and reduce the binding with diagnostic_context by renaming the callbacks to add "_text" in their names, and converting the first param from diagnostic_context * to diagnostic_text_output_output &. Update the various subroutines used by diagnostic starter/finalizer callbacks to also take a diagnostic_text_output_output & rather than a diagnostic_context *. Move m_includes and m_last_seen from the context to the text output. Use the text_output's get_printer () rather than the context's m_printer, which should ease the transition to multiple output sinks. No functional change intended. gcc/c-family/ChangeLog: PR other/116613 * c-opts.cc: Include "diagnostic-format-text.h". (c_diagnostic_finalizer): Rename to... (c_diagnostic_text_finalizer): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (c_common_diagnostics_set_defaults): Update for renamings. gcc/ChangeLog: PR other/116613 * coretypes.h (class diagnostic_text_output_format): Add forward decl. * diagnostic-format-json.cc (json_output_format::after_diagnostic): New. * diagnostic-format-sarif.cc (sarif_output_format::after_diagnostic): New. * diagnostic-format-text.cc: Use pragmas to ignore -Wformat-diag. (diagnostic_text_output_format::~diagnostic_text_output_format): Use get_printer. Clean up m_includes_seen here, rather than in ~diagnostic_context. (diagnostic_text_output_format::on_report_diagnostic): Use get_printer. Update for callback renamings and pass *this to them, rather than &m_context. (diagnostic_text_output_format::after_diagnostic): New. (diagnostic_text_output_format::includes_seen_p): Move here from diagnostic_context/diagnostic.cc. (diagnostic_text_output_format::get_location_text): New. (maybe_line_and_column): Move here from diagnostic.cc and make non-static. (diagnostic_text_output_format::report_current_module): Move here from diagnostic_context/diagnostic.cc. (default_diagnostic_text_starter): Move here from diagnostic.cc, renaming from default_diagnostic_starter. (default_diagnostic_text_finalizer): Likewise, renaming from default_diagnostic_finalizer. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_text_output_format): Initialize m_last_module and m_includes_seen. (diagnostic_text_output_format::after_diagnostic): New decl. (diagnostic_text_output_format::build_prefix): New decl. (diagnostic_text_output_format::report_current_module): New decl. (diagnostic_text_output_format::append_note): New decl. (diagnostic_text_output_format::file_name_as_prefix): New decl. (diagnostic_text_output_format::print_path): New decl. (diagnostic_text_output_format::show_column_p): New decl. (diagnostic_text_output_format::get_location_text): New decl. (diagnostic_text_output_format::includes_seen_p): New decl. (diagnostic_text_output_format::show_any_path): New decl. (diagnostic_text_output_format::m_last_module): New field. (diagnostic_text_output_format::m_includes_seen): New field. * diagnostic-format.h (diagnostic_output_format::after_diagnostic): New vfunc. (diagnostic_output_format::get_context): New. (diagnostic_output_format::get_diagram_theme): New. * diagnostic-macro-unwinding.cc: Include "diagnostic-format-text.h". (maybe_unwind_expanded_macro_loc): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (virt_loc_aware_diagnostic_finalizer): Likewise. * diagnostic-macro-unwinding.h (virt_loc_aware_diagnostic_finalizer): Likewise. (maybe_unwind_expanded_macro_loc): Likewise. * diagnostic-path.cc: Include "diagnostic-format-text.h". (path_label::path_label): Drop "ctxt" param and add "colorize" and "allow_emojis" params. Update initializations. (path_label::get_text): Use m_colorize rather than querying m_ctxt.m_printer. Use m_allow_emojis rather than querying m_ctxt's diagram theme. (path_label::m_ctxt): Drop field. (path_label::m_colorize): Drop field. (path_label::m_allow_emojis): Drop field. (event_range::event_range): Drop param "ctxt". Add params "colorize_labels" and "allow_emojis". (event_range::print): Convert first param from diagnostic_context & to diagnostic_text_output_format & and update accordingly. (path_summary::path_summary): Likewise. (path_summary::print_swimlane_for_event_range): Likewise. (print_path_summary_as_text): Likewise for 3rd param. (diagnostic_context::print_path): Convert to... (diagnostic_text_output_format::print_path): ...this. (selftest::test_empty_path): Update to use a diagnostic_text_output_format. (selftest::test_intraprocedural_path): Likewise. (selftest::test_interprocedural_path_1): Likewise. (selftest::test_interprocedural_path_2): Likewise. (selftest::test_recursion): Likewise. (selftest::test_control_flow_1): Likewise. (selftest::test_control_flow_2): Likewise. (selftest::test_control_flow_3): Likewise. (selftest::assert_cfg_edge_path_streq): Likewise. (selftest::test_control_flow_5): Likewise. (selftest::test_control_flow_6): Likewise. * diagnostic.cc (file_name_as_prefix): Convert to... (diagnostic_text_output_format::file_name_as_prefix): ...this. (diagnostic_context::initialize): Update for renamings. Move m_last_module and m_includes_seen into text output. (diagnostic_context::finish): Likewise. (diagnostic_context::get_location_text): Add "colorize" param. (diagnostic_build_prefix): Convert to... (diagnostic_text_output_format::build_prefix): ...this. (diagnostic_context::includes_seen_p): Move from here to diagnostic_text_output_format/diagnostic-format-text.cc. (diagnostic_context::report_current_module): Likewise. (diagnostic_context::show_any_path): Convert to... (diagnostic_text_output_format::show_any_path): ...this. (default_diagnostic_starter): Rename and move to diagnostic-format-text.cc. (default_diagnostic_start_span_fn): Pass colorize bool to get_location_text. (default_diagnostic_finalizer): Rename and move to diagnostic-format-text.cc. (diagnostic_context::report_diagnostic): Replace call to show_any_path with call to new output format "after_diagnostic" vfunc, moving show_any_path call to the text output format. (diagnostic_append_note): Convert to... (diagnostic_text_output_format::append_note): ...this. (selftest::assert_location_text): Pass in false for colorization. * diagnostic.h (diagnostic_starter_fn): Rename to... (diagnostic_text_starter_fn): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format &. (diagnostic_finalizer_fn, diagnostic_text_finalizer_fn): Likewise. (diagnostic_context): Update friends for renamings. (diagnostic_context::report_current_module): Move to text output format. (diagnostic_context::get_location_text): Add "colorize" bool. (diagnostic_context::includes_seen_p): Move to text output format. (diagnostic_context::show_any_path): Likewise. (diagnostic_context::print_path): Likewise. (diagnostic_context::m_text_callbacks): Update for renamings. (diagnostic_context::m_last_module): Move to text output format. (diagnostic_context::m_includes_seen): Likewise. (diagnostic_starter): Rename to... (diagnostic_text_starter): ...this and update return type. (diagnostic_finalizer): Rename to... (diagnostic_text_finalizer): ...this and update return type. (diagnostic_report_current_module): Drop decl in favor of a member function of diagnostic_text_output_format. (diagnostic_append_note): Likewise. (default_diagnostic_starter): Rename to... (default_diagnostic_text_starter): ...this, updating type. (default_diagnostic_finalizer): Rename to... (default_diagnostic_text_finalizer): ...this, updating type. (file_name_as_prefix): Drop decl. * langhooks-def.h (lhd_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * langhooks.cc: Include "diagnostic-format-text.h". (lhd_print_error_function): Likewise. Update accordingly * langhooks.h (lang_hooks::print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * tree-diagnostic.cc: Include "diagnostic-format-text.h". (diagnostic_report_current_function): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (default_tree_diagnostic_starter): Rename to... (default_tree_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (tree_diagnostics_defaults): Update for renamings. gcc/cp/ChangeLog: PR other/116613 * cp-tree.h (cxx_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * error.cc: Include "diagnostic-format-text.h". (cxx_initialize_diagnostics): Update for renamings. (cxx_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly (cp_diagnostic_starter): Rename to... (cp_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (cp_print_error_function): Likewise. (print_instantiation_full_context): Likewise. (print_instantiation_partial_context_line): Likewise. (print_instantiation_partial_context): Likewise. (maybe_print_instantiation_context): Likewise. (maybe_print_constexpr_context): Likewise. (print_location): Likewise. (print_constrained_decl_info): Likewise. (print_concept_check_info): Likewise. (print_constraint_context_head): Likewise. (print_requires_expression_info): Likewise. (maybe_print_single_constraint_context): Likewise. gcc/fortran/ChangeLog: PR other/116613 * error.cc: Include "diagnostic-format-text.h". (gfc_diagnostic_starter): Rename to... (gfc_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (gfc_diagnostic_finalizer, gfc_diagnostic_text_finalizer): Likewise. (gfc_diagnostics_init): Update for renamings. (gfc_diagnostics_finish): Likewise. gcc/jit/ChangeLog: PR other/116613 * dummy-frontend.cc: Include "diagnostic-format-text.h". (jit_begin_diagnostic): Convert first param from diagnostic_context * to diagnostic_text_output_format & (jit_end_diagnostic): Likewise. Update accordingly. (jit_langhook_init): Update for renamings. gcc/rust/ChangeLog: PR other/116613 * resolve/rust-ast-resolve-expr.cc (funny_ice_finalizer): : Convert first param from diagnostic_context * to diagnostic_text_output_format &. (ResolveExpr::visit): Update for renaming. gcc/testsuite/ChangeLog: PR other/116613 * g++.dg/plugin/show_template_tree_color_plugin.c (noop_starter_fn): Rename to... (noop_text_starter_fn): ...this. Update first param from dc to text_output. (plugin_init): Update for renamings. * gcc.dg/plugin/diagnostic_group_plugin.c (test_diagnostic_starter): Rename to... (test_diagnostic_text_starter): ...this. Update first param from dc to text_output. (plugin_init): Update for renaming. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include "diagnostic-format-text.h". (custom_diagnostic_finalizer): Rename to... (custom_diagnostic_text_finalizer): ...this. Update first param from dc to text_output. (test_show_locus): Update for renamings. * gcc.dg/plugin/location_overflow_plugin.c: Include "diagnostic-format-text.h". (original_finalizer): Rename to... (original_text_finalizer): ...this and update type. (verify_unpacked_ranges): Update first param from dc to text_output. Update for this and for renamings. (verify_no_columns): Likewise. (plugin_init): Update for renamings. libcc1/ChangeLog: PR other/116613 * context.cc: Include "diagnostic-format-text.h". (plugin_print_error_function): Update first param from diagnostic_context * to diagnostic_text_output_format &. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-20c++: CWG 2789 and reversed operator candidatesPatrick Palka1-4/+7
As a follow-up to r15-3741-gee3efe06c9c49c, which was specifically concerned with usings, it seems the CWG 2789 refinement should also compare contexts of a reversed vs non-reversed (member) candidate during operator overload resolution. DR 2789 gcc/cp/ChangeLog: * call.cc (cand_parms_match): Check for matching class contexts even in the reversed case. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-memfun4.C: Adjust expected result involving reversed candidate. Reviewed-by: Jason Merrill <jason@redhat.com>