1 // RUN: %clang_cc1 -fsyntax-only -Wno-error=address-of-temporary -verify -std=gnu++11 %s
8 void f0() { (void)&X(); } // expected-warning{{taking the address of a temporary object}}
9 void f1() { (void)&X(1); } // expected-warning{{taking the address of a temporary object}}
10 void f2() { (void)&X(1, 2); } // expected-warning{{taking the address of a temporary object}}
11 void f3() { (void)&(X)1; } // expected-warning{{taking the address of a temporary object}}
14 namespace PointerToArrayDecay {
21 template<typename T> void consume(T);
24 void g0() { int *p = Y().a; } // expected-warning{{pointer is initialized by a temporary array}}
25 void g1() { int *p = Y{}.a; } // expected-warning{{pointer is initialized by a temporary array}}
26 void g2() { int *p = A{}; } // expected-warning{{pointer is initialized by a temporary array}}
27 void g3() { int *p = (A){}; } // expected-warning{{pointer is initialized by a temporary array}}
29 void h0() { consume(Y().a); }
30 void h1() { consume(Y{}.a); }
31 void h2() { consume(A{}); }
32 void h3() { consume((A){}); }
34 void i0() { S s = { Y().a }; } // expected-warning{{pointer is initialized by a temporary array}}
35 void i1() { S s = { Y{}.a }; } // expected-warning{{pointer is initialized by a temporary array}}
36 void i2() { S s = { A{} }; } // expected-warning{{pointer is initialized by a temporary array}}
37 void i3() { S s = { (A){} }; } // expected-warning{{pointer is initialized by a temporary array}}
39 void j0() { (void)S { Y().a }; }
40 void j1() { (void)S { Y{}.a }; }
41 void j2() { (void)S { A{} }; }
42 void j3() { (void)S { (A){} }; }
44 void k0() { consume(S { Y().a }); }
45 void k1() { consume(S { Y{}.a }); }
46 void k2() { consume(S { A{} }); }
47 void k3() { consume(S { (A){} }); }