[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / AST / ByteCode / cxx1z.cpp
blob57f99235a2b2015446747d938032b55743b7c8dd
1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++17 -verify=expected,both %s
2 // RUN: %clang_cc1 -std=c++17 -verify=ref,both %s
4 template<typename T, T val> struct A {};
5 namespace Temp {
6 struct S { int n; };
7 constexpr S &addr(S &&s) { return s; }
8 A<S &, addr({})> a; // both-error {{reference to temporary object}}
9 A<S *, &addr({})> b; // both-error {{pointer to temporary object}}
10 A<int &, addr({}).n> c; // both-error {{reference to subobject of temporary object}}
11 A<int *, &addr({}).n> d; // both-error {{pointer to subobject of temporary object}}
14 char arr[3];
15 A<const char*, &arr[1]> d; // both-error {{refers to subobject '&arr[1]'}}
17 void Func() {
18 A<const char*, __func__> a; // both-error {{pointer to subobject of predefined '__func__' variable}}