aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/error.cc
diff options
context:
space:
mode:
authorwaffl3x <waffl3x@protonmail.com>2024-01-07 00:03:19 +0000
committerJason Merrill <jason@redhat.com>2024-01-09 15:59:04 -0500
commitf8bf6a69e260a5f1aa0dbf89a6e4bcdf1a24af5d (patch)
tree6b7dd5366d64daaebc9cd68b91ee40de3fd6e537 /gcc/cp/error.cc
parentfbc980d85149409ce62c22f48d3693113803929e (diff)
downloadgcc-f8bf6a69e260a5f1aa0dbf89a6e4bcdf1a24af5d.zip
gcc-f8bf6a69e260a5f1aa0dbf89a6e4bcdf1a24af5d.tar.gz
gcc-f8bf6a69e260a5f1aa0dbf89a6e4bcdf1a24af5d.tar.bz2
c++: P0847R7 (deducing this) - diagnostics. [PR102609]
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>
Diffstat (limited to 'gcc/cp/error.cc')
-rw-r--r--gcc/cp/error.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index a384f62..52e24fb 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -840,10 +840,14 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags)
{
/* A lambda's "type" is essentially its signature. */
pp_string (pp, M_("<lambda"));
- if (lambda_function (t))
- dump_parameters (pp,
- FUNCTION_FIRST_USER_PARMTYPE (lambda_function (t)),
- flags);
+ tree const fn = lambda_function (t);
+ if (fn)
+ {
+ int const parm_flags
+ = DECL_XOBJ_MEMBER_FUNCTION_P (fn) ? TFF_XOBJ_FUNC | flags
+ : flags;
+ dump_parameters (pp, FUNCTION_FIRST_USER_PARMTYPE (fn), parm_flags);
+ }
pp_greater (pp);
}
else if (!decl || IDENTIFIER_ANON_P (DECL_NAME (decl)))
@@ -1712,7 +1716,9 @@ dump_lambda_function (cxx_pretty_printer *pp,
{
/* A lambda's signature is essentially its "type". */
dump_type (pp, DECL_CONTEXT (fn), flags);
- if (TREE_CODE (TREE_TYPE (fn)) == FUNCTION_TYPE)
+ if (DECL_XOBJ_MEMBER_FUNCTION_P (fn))
+ /* Early escape. */;
+ else if (TREE_CODE (TREE_TYPE (fn)) == FUNCTION_TYPE)
{
pp->padding = pp_before;
pp_c_ws_string (pp, "static");
@@ -1833,7 +1839,9 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags)
if (!(flags & TFF_NO_FUNCTION_ARGUMENTS))
{
- dump_parameters (pp, parmtypes, flags);
+ int const parm_flags
+ = DECL_XOBJ_MEMBER_FUNCTION_P (t) ? TFF_XOBJ_FUNC | flags : flags;
+ dump_parameters (pp, parmtypes, parm_flags);
if (TREE_CODE (fntype) == METHOD_TYPE)
{
@@ -1912,6 +1920,8 @@ dump_parameters (cxx_pretty_printer *pp, tree parmtypes, int flags)
for (first = 1; parmtypes != void_list_node;
parmtypes = TREE_CHAIN (parmtypes))
{
+ if (first && flags & TFF_XOBJ_FUNC)
+ pp_string (pp, "this ");
if (!first)
pp_separate_with_comma (pp);
first = 0;
@@ -3696,6 +3706,8 @@ function_category (tree fn)
return _("In destructor %qD");
else if (LAMBDA_FUNCTION_P (fn))
return _("In lambda function");
+ else if (DECL_XOBJ_MEMBER_FUNCTION_P (fn))
+ return _("In explicit object member function %qD");
else
return _("In member function %qD");
}