diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index 8caa0f9afd5..bc195bbb787 100644 --- a/gcc/cp/reflect.cc +++ b/gcc/cp/reflect.cc @@ -8396,16 +8396,16 @@ check_splice_expr (location_t loc, location_t start_loc, tree t, && (DECL_CONSTRUCTOR_P (t) || DECL_DESTRUCTOR_P (t))) { if (complain_p) - error_at (loc, "cannot use constructor or destructor in a splice " - "expression"); + error_at (loc, "cannot use constructor or destructor %qD in a splice " + "expression", t); return false; } /* -- an unnamed bit-field */ if (TREE_CODE (t) == FIELD_DECL && DECL_UNNAMED_BIT_FIELD (t)) { if (complain_p) - error_at (loc, "cannot use an unnamed bit-field in a splice " - "expression"); + error_at (loc, "cannot use an unnamed bit-field %qD in a splice " + "expression", t); return false; } /* Class members may not be implicitly referenced through a splice. @@ -8417,8 +8417,8 @@ check_splice_expr (location_t loc, location_t start_loc, tree t, || (VAR_P (t) && DECL_ANON_UNION_VAR_P (t)))) { if (complain_p) - error_at (loc, "cannot implicitly reference a class member through " - "a splice"); + error_at (loc, "cannot implicitly reference a class member %qD " + "through a splice", t); return false; } /* [expr.unary.op]/3.1 "If the operand [of unary &] is a qualified-id or @@ -8459,7 +8459,8 @@ check_splice_expr (location_t loc, location_t start_loc, tree t, if (TREE_CODE (t) == TREE_LIST && annotation_p (t)) { if (complain_p) - error_at (loc, "cannot use an annotation in a splice expression"); + error_at (loc, "cannot use an annotation %qE in a splice expression", + t); return false; } diff --git a/gcc/testsuite/g++.dg/reflect/anon2.C b/gcc/testsuite/g++.dg/reflect/anon2.C index 5a55ace2d07..b69306096d5 100644 --- a/gcc/testsuite/g++.dg/reflect/anon2.C +++ b/gcc/testsuite/g++.dg/reflect/anon2.C @@ -3,12 +3,12 @@ static union { int m; }; constexpr auto r = ^^m; -auto p = [:r:]; // { dg-error "cannot implicitly reference a class member through a splice" } +auto p = [:r:]; // { dg-error "cannot implicitly reference a class member .m. through a splice" } namespace N { static union { int mn; }; constexpr auto rn = ^^mn; - auto pn = [:rn:]; // { dg-error "cannot implicitly reference a class member through a splice" } + auto pn = [:rn:]; // { dg-error "cannot implicitly reference a class member .mn. through a splice" } } struct S { @@ -17,7 +17,7 @@ struct S { }; }; -constexpr auto p2 = [: ^^S::m :]; // { dg-error "cannot implicitly reference a class member through a splice" } +constexpr auto p2 = [: ^^S::m :]; // { dg-error "cannot implicitly reference a class member .S::::m. through a splice" } void f () @@ -25,19 +25,19 @@ f () static union { int x; }; - auto rx = [: ^^x :]; // { dg-error "cannot implicitly reference a class member through a splice" } + auto rx = [: ^^x :]; // { dg-error "cannot implicitly reference a class member .x. through a splice" } union { union { int u; }; }; - auto ru = [: ^^u :]; // { dg-error "cannot implicitly reference a class member through a splice" } + auto ru = [: ^^u :]; // { dg-error "cannot implicitly reference a class member .u. through a splice" } struct L { union { int z; }; }; - auto rz = [: ^^L::z :]; // { dg-error "cannot implicitly reference a class member through a splice" } + auto rz = [: ^^L::z :]; // { dg-error "cannot implicitly reference a class member .f\\(\\)::L::::z. through a splice" } } diff --git a/gcc/testsuite/g++.dg/reflect/error2.C b/gcc/testsuite/g++.dg/reflect/error2.C index 27fd3fdfb66..766862b688a 100644 --- a/gcc/testsuite/g++.dg/reflect/error2.C +++ b/gcc/testsuite/g++.dg/reflect/error2.C @@ -14,6 +14,6 @@ g () constexpr auto r2 = ^^A::A(); // { dg-error "cannot take the reflection of an overload set" } constexpr auto r3 = ^^A::A::A; // { dg-error "cannot take the reflection of an overload set" } constexpr auto r4 = ^^A::~A; - [: r4 :]; // { dg-error "cannot use constructor or destructor in a splice expression" } - [: ^^A::~A :]; // { dg-error "cannot use constructor or destructor in a splice expression" } + [: r4 :]; // { dg-error "cannot use constructor or destructor .A::~A\\(\\). in a splice expression" } + [: ^^A::~A :]; // { dg-error "cannot use constructor or destructor .A::~A\\(\\). in a splice expression" } } diff --git a/gcc/testsuite/g++.dg/reflect/member5.C b/gcc/testsuite/g++.dg/reflect/member5.C index 96085636902..9a5308629d8 100644 --- a/gcc/testsuite/g++.dg/reflect/member5.C +++ b/gcc/testsuite/g++.dg/reflect/member5.C @@ -13,7 +13,7 @@ struct S { auto p = &[: ^^S::m :]; auto q = &[: ^^S::m :]; -auto rm = [: ^^S::m :]; // { dg-error "cannot implicitly reference a class member through a splice" } -auto rn = [: ^^S::n :]; // { dg-error "cannot implicitly reference a class member through a splice" } -auto re = [: ^^S::e :]; // { dg-error "cannot implicitly reference a class member through a splice" } -auto ra = [: ^^S::a :]; // { dg-error "cannot implicitly reference a class member through a splice" } +auto rm = [: ^^S::m :]; // { dg-error "cannot implicitly reference a class member .int S::m\\(this S\\). through a splice" } +auto rn = [: ^^S::n :]; // { dg-error "cannot implicitly reference a class member .int S::n\\(\\) const. through a splice" } +auto re = [: ^^S::e :]; // { dg-error "cannot implicitly reference a class member .S::e. through a splice" } +auto ra = [: ^^S::a :]; // { dg-error "cannot implicitly reference a class member .S::a. through a splice" } diff --git a/gcc/testsuite/g++.dg/reflect/member6.C b/gcc/testsuite/g++.dg/reflect/member6.C index e77e1ca0168..5d425ae0920 100644 --- a/gcc/testsuite/g++.dg/reflect/member6.C +++ b/gcc/testsuite/g++.dg/reflect/member6.C @@ -9,5 +9,5 @@ constexpr auto r = ^^S::i; /* A pointer to member is only formed when an explicit & is used and its operand is a qualified-id or splice-expression not enclosed in parentheses. */ -auto p = &([: r :]); // { dg-error "cannot implicitly reference a class member through a splice" } +auto p = &([: r :]); // { dg-error "cannot implicitly reference a class member .S::i. through a splice" } auto q = &[: r :]; diff --git a/gcc/testsuite/g++.dg/reflect/qrn2.C b/gcc/testsuite/g++.dg/reflect/qrn2.C index d28ae1c14c1..51c3c9fd927 100644 --- a/gcc/testsuite/g++.dg/reflect/qrn2.C +++ b/gcc/testsuite/g++.dg/reflect/qrn2.C @@ -25,15 +25,15 @@ g () constexpr auto r2 = ^^B::x; // { dg-error "private within this context" } constexpr auto r3 = ^^C::x; - int i1 = [: r3 :]; // { dg-error "cannot implicitly reference a class member through a splice" } - [: r3 :]; // { dg-error "cannot implicitly reference a class member through a splice" } - [: r3 :] = 0; // { dg-error "cannot implicitly reference a class member through a splice" } + int i1 = [: r3 :]; // { dg-error "cannot implicitly reference a class member .C::x. through a splice" } + [: r3 :]; // { dg-error "cannot implicitly reference a class member .C::x. through a splice" } + [: r3 :] = 0; // { dg-error "cannot implicitly reference a class member .C::x. through a splice" } constexpr auto r4 = ^^foo; // { dg-error "reflection of an overload set" } constexpr auto r5 = ^^bar; // { dg-error "reflection of an overload set" } constexpr auto r6 = ^^D::x; // { dg-error "expected" } constexpr auto r7 = ^^D::x; - [: r7 :]; // { dg-error "cannot implicitly reference a class member through a splice" } + [: r7 :]; // { dg-error "cannot implicitly reference a class member .D::x. through a splice" } } void diff --git a/gcc/testsuite/g++.dg/reflect/splice1.C b/gcc/testsuite/g++.dg/reflect/splice1.C index 6eb1f6f857d..fd9fab1efa3 100644 --- a/gcc/testsuite/g++.dg/reflect/splice1.C +++ b/gcc/testsuite/g++.dg/reflect/splice1.C @@ -18,11 +18,11 @@ foo () { S s = { 0 }, t = { 0 }; constexpr auto ctx = access_context::unchecked (); - s.[: members_of (^^S, ctx)[1] :] = 1; // { dg-error "cannot use an unnamed bit-field in a splice expression" } - s.[: (members_of (^^S, ctx) | std::views::filter (is_default_constructor) | std::ranges::to ())[0] :] (); // { dg-error "cannot use constructor or destructor in a splice expression" } - s.[: (members_of (^^S, ctx) | std::views::filter (is_copy_constructor) | std::ranges::to ())[0] :] (t); // { dg-error "cannot use constructor or destructor in a splice expression" } - s.[: (members_of (^^S, ctx) | std::views::filter (is_destructor) | std::ranges::to ())[0] :] (); // { dg-error "cannot use constructor or destructor in a splice expression" } - [: annotations_of (^^foo)[0] :]; // { dg-error "cannot use an annotation in a splice expression" } + s.[: members_of (^^S, ctx)[1] :] = 1; // { dg-error "cannot use an unnamed bit-field .S::. in a splice expression" } + s.[: (members_of (^^S, ctx) | std::views::filter (is_default_constructor) | std::ranges::to ())[0] :] (); // { dg-error "cannot use constructor or destructor .constexpr S::S\\(\\). in a splice expression" } + s.[: (members_of (^^S, ctx) | std::views::filter (is_copy_constructor) | std::ranges::to ())[0] :] (t); // { dg-error "cannot use constructor or destructor .constexpr S::S\\(const S&\\). in a splice expression" } + s.[: (members_of (^^S, ctx) | std::views::filter (is_destructor) | std::ranges::to ())[0] :] (); // { dg-error "cannot use constructor or destructor .constexpr S::~S\\(\\). in a splice expression" } + [: annotations_of (^^foo)[0] :]; // { dg-error "cannot use an annotation .1. in a splice expression" } [: data_member_spec (^^S, { .name = "name" }) :]; // { dg-error "cannot use a data member specification in a splice expression" } [: bases_of (^^T, ctx)[0] :]; // { dg-error "" "" { xfail *-*-* } } }