mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 23:25:24 +02:00
testsuite: Add testcase for LWG4556 - Unclear properties of reflection strings
The issue clarifies what the *string_view points to is not valid for template arguments with pointer type, the following testcase verifies that we already reject it. 2026-04-03 Jakub Jelinek <jakub@redhat.com> * g++.dg/reflect/lwg4556.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
This commit is contained in:
committed by
Jakub Jelinek
parent
0229b5b3da
commit
581a9a289d
40
gcc/testsuite/g++.dg/reflect/lwg4556.C
Normal file
40
gcc/testsuite/g++.dg/reflect/lwg4556.C
Normal file
@@ -0,0 +1,40 @@
|
||||
// LWG4556 - Unclear properties of reflection strings
|
||||
// { dg-do compile { target c++26 } }
|
||||
// { dg-additional-options "-freflection" }
|
||||
|
||||
#include <meta>
|
||||
|
||||
template <const char *P>
|
||||
void foo () {}
|
||||
|
||||
template <const char8_t *P>
|
||||
void bar () {}
|
||||
|
||||
void
|
||||
baz ()
|
||||
{
|
||||
foo <symbol_of (std::meta::op_plus_equals).data ()> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"\\\+=\\\"\\\[0\\\]' is not a valid template argument of type 'const char\\\*'" "" { target *-*-* } .-1 }
|
||||
bar <u8symbol_of (std::meta::op_pipe).data ()> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"\\\|\\\"\\\[0\\\]' is not a valid template argument of type 'const char8_t\\\*'" "" { target *-*-* } .-1 }
|
||||
foo <symbol_of (std::meta::op_plus_equals).data () + 1> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"\\\+=\\\"\\\[1\\\]' is not a valid template argument of type 'const char\\\*'" "" { target *-*-* } .-1 }
|
||||
bar <u8symbol_of (std::meta::op_pipe).data () + 1> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"\\\|\\\"\\\[1\\\]' is not a valid template argument of type 'const char8_t\\\*'" "" { target *-*-* } .-1 }
|
||||
foo <identifier_of (^^baz).data ()> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"baz\\\"\\\[0\\\]' is not a valid template argument of type 'const char\\\*'" "" { target *-*-* } .-1 }
|
||||
bar <u8identifier_of (^^baz).data ()> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"baz\\\"\\\[0\\\]' is not a valid template argument of type 'const char8_t\\\*'" "" { target *-*-* } .-1 }
|
||||
foo <identifier_of (^^baz).data () + 1> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"baz\\\"\\\[1\\\]' is not a valid template argument of type 'const char\\\*'" "" { target *-*-* } .-1 }
|
||||
bar <u8identifier_of (^^baz).data () + 1> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"baz\\\"\\\[1\\\]' is not a valid template argument of type 'const char8_t\\\*'" "" { target *-*-* } .-1 }
|
||||
foo <display_string_of (^^baz).data ()> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"void baz\\\(\\\)\\\"\\\[0\\\]' is not a valid template argument of type 'const char\\\*'" "" { target *-*-* } .-1 }
|
||||
bar <u8display_string_of (^^baz).data ()> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"void baz\\\(\\\)\\\"\\\[0\\\]' is not a valid template argument of type 'const char8_t\\\*'" "" { target *-*-* } .-1 }
|
||||
foo <display_string_of (^^baz).data () + 1> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"void baz\\\(\\\)\\\"\\\[1\\\]' is not a valid template argument of type 'const char\\\*'" "" { target *-*-* } .-1 }
|
||||
bar <u8display_string_of (^^baz).data () + 1> (); // { dg-error "no matching function for call to" }
|
||||
// { dg-error "'\\\&\\\"void baz\\\(\\\)\\\"\\\[1\\\]' is not a valid template argument of type 'const char8_t\\\*'" "" { target *-*-* } .-1 }
|
||||
}
|
||||
Reference in New Issue
Block a user