2024-10-10 14:10:38 +02:00
|
|
|
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++17 -verify=expected,both %s
|
|
|
|
// RUN: %clang_cc1 -std=c++17 -verify=ref,both %s
|
|
|
|
|
2025-03-10 10:18:56 +01:00
|
|
|
template<typename T, T val> struct A {};
|
2024-10-10 14:10:38 +02:00
|
|
|
namespace Temp {
|
|
|
|
struct S { int n; };
|
|
|
|
constexpr S &addr(S &&s) { return s; }
|
|
|
|
A<S &, addr({})> a; // both-error {{reference to temporary object}}
|
|
|
|
A<S *, &addr({})> b; // both-error {{pointer to temporary object}}
|
|
|
|
A<int &, addr({}).n> c; // both-error {{reference to subobject of temporary object}}
|
|
|
|
A<int *, &addr({}).n> d; // both-error {{pointer to subobject of temporary object}}
|
|
|
|
}
|
2024-10-11 05:58:25 +02:00
|
|
|
|
|
|
|
char arr[3];
|
|
|
|
A<const char*, &arr[1]> d; // both-error {{refers to subobject '&arr[1]'}}
|
2024-10-11 09:31:49 +02:00
|
|
|
|
|
|
|
void Func() {
|
|
|
|
A<const char*, __func__> a; // both-error {{pointer to subobject of predefined '__func__' variable}}
|
|
|
|
}
|