Skip to content

Commit 6711aa9

Browse files
committed
Add additional test
1 parent fb5d3da commit 6711aa9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,19 @@ void foo() {
560560
S s;
561561
}
562562
} // namespace GH118000
563+
564+
namespace GH119046 {
565+
566+
template <typename Cls> constexpr auto tfn(int) {
567+
return (unsigned long long)(&Cls::sfn);
568+
//expected-note@-1 {{'tfn<GH119046::S>' is an immediate function because its body evaluates the address of a consteval function 'sfn'}}
569+
};
570+
struct S { static consteval void sfn() {} };
571+
572+
int f() {
573+
int a = 0; // expected-note{{declared here}}
574+
return tfn<S>(a);
575+
//expected-error@-1 {{call to immediate function 'GH119046::tfn<GH119046::S>' is not a constant expression}}
576+
//expected-note@-2 {{read of non-const variable 'a' is not allowed in a constant expression}}
577+
}
578+
}

0 commit comments

Comments
 (0)