[LV] Add test showing debug output for loops with uncountable BTCs.
[llvm-project.git] / clang / test / SemaCXX / cxx20-warn-dangling-paren-list-agg-init.cpp
blob645a7caba714e2a75653b1836f59cee4bd695a9a
1 // RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
3 namespace std {
4 template <class T> struct remove_reference { typedef T type; };
5 template <class T> struct remove_reference<T&> { typedef T type; };
6 template <class T> struct remove_reference<T&&> { typedef T type; };
8 template <class T> typename remove_reference<T>::type &&move(T &&t);
9 } // namespace std
11 // dcl.init 16.6.2.2
12 struct A {
13 int a;
14 int&& r;
17 int f();
18 int n = 10;
20 A a1{1, f()}; // OK, lifetime is extended for direct-list-initialization
21 // well-formed, but dangling reference
22 A a2(1, f()); // expected-warning {{temporary whose address is used as value}}
23 // well-formed, but dangling reference
24 A a4(1.0, 1); // expected-warning {{temporary whose address is used as value}}
25 A a5(1.0, std::move(n)); // OK
29 struct B {
30 const int& r;
32 B test(int local) {
33 return B(1); // expected-warning {{returning address}}
34 return B(local); // expected-warning {{address of stack memory}}
37 void f(B b);
38 void test2(int local) {
39 // No diagnostic on the following cases where both the aggregate object and
40 // temporary end at the end of the full expression.
41 f(B(1));
42 f(B(local));
45 // Test nested struct.
46 struct C {
47 B b;
50 struct D {
51 C c;
54 C c1(B(
55 1 // expected-warning {{temporary whose address is used as value}}
56 ));
57 D d1(C(B(
58 1 // expected-warning {{temporary whose address is used as value}}
59 )));