diff options
Diffstat (limited to 'test/SemaCXX/address-of-temporary.cpp')
-rw-r--r-- | test/SemaCXX/address-of-temporary.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/SemaCXX/address-of-temporary.cpp b/test/SemaCXX/address-of-temporary.cpp index 5eef1c5521c4d..eb0ca3c4a7f14 100644 --- a/test/SemaCXX/address-of-temporary.cpp +++ b/test/SemaCXX/address-of-temporary.cpp @@ -26,11 +26,12 @@ namespace PointerToArrayDecay { template<typename T> void consume(T); struct S { int *p; }; - void g0() { int *p = Y().a; } // expected-warning{{pointer is initialized by a temporary array}} - void g1() { int *p = Y{}.a; } // expected-warning{{pointer is initialized by a temporary array}} - void g2() { int *p = A{}; } // expected-warning{{pointer is initialized by a temporary array}} - void g3() { int *p = (A){}; } // expected-warning{{pointer is initialized by a temporary array}} - void g4() { Z *p = AZ{}; } // expected-warning{{pointer is initialized by a temporary array}} + void g0() { int *p = Y().a; } // expected-warning{{will be destroyed at the end of the full-expression}} + void g1() { int *p = Y{}.a; } // expected-warning{{will be destroyed at the end of the full-expression}} + void g2() { int *p = A{}; } // expected-warning{{will be destroyed at the end of the full-expression}} + void g3() { int *p = (A){}; } // expected-warning{{will be destroyed at the end of the full-expression}} + void g4() { Z *p = AZ{}; } // expected-warning{{will be destroyed at the end of the full-expression}} + void g5() { Z *p = &(Z&)(AZ{}[0]); } // expected-warning{{will be destroyed at the end of the full-expression}} void h0() { consume(Y().a); } void h1() { consume(Y{}.a); } @@ -38,10 +39,10 @@ namespace PointerToArrayDecay { void h3() { consume((A){}); } void h4() { consume(AZ{}); } - void i0() { S s = { Y().a }; } // expected-warning{{pointer is initialized by a temporary array}} - void i1() { S s = { Y{}.a }; } // expected-warning{{pointer is initialized by a temporary array}} - void i2() { S s = { A{} }; } // expected-warning{{pointer is initialized by a temporary array}} - void i3() { S s = { (A){} }; } // expected-warning{{pointer is initialized by a temporary array}} + void i0() { S s = { Y().a }; } // expected-warning{{will be destroyed at the end of the full-expression}} + void i1() { S s = { Y{}.a }; } // expected-warning{{will be destroyed at the end of the full-expression}} + void i2() { S s = { A{} }; } // expected-warning{{will be destroyed at the end of the full-expression}} + void i3() { S s = { (A){} }; } // expected-warning{{will be destroyed at the end of the full-expression}} void j0() { (void)S { Y().a }; } void j1() { (void)S { Y{}.a }; } |