diff options
author | Jason Merrill <jason@redhat.com> | 2023-06-06 12:01:23 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-06-06 21:24:13 -0400 |
commit | 4fe84e2a4c0b600d2bc01f171b3b9dd1f4357208 (patch) | |
tree | afb45ce948111003cbcf61a9725debd0fedc8633 /gcc | |
parent | 29c82c6ca929e0f5eccfe038dea71177d814c6b7 (diff) | |
download | gcc-4fe84e2a4c0b600d2bc01f171b3b9dd1f4357208.zip gcc-4fe84e2a4c0b600d2bc01f171b3b9dd1f4357208.tar.gz gcc-4fe84e2a4c0b600d2bc01f171b3b9dd1f4357208.tar.bz2 |
c++: add NRV testcase [PR58050]
This was fixed in GCC 10.
PR c++/58050
gcc/testsuite/ChangeLog:
* g++.dg/opt/nrv24.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/g++.dg/opt/nrv24.C | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/nrv24.C b/gcc/testsuite/g++.dg/opt/nrv24.C new file mode 100644 index 0000000..7a7a59b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/nrv24.C @@ -0,0 +1,18 @@ +// PR c++/58050 +// { dg-do link } + +struct B { + B() { } + B(const B&); // not defined, link error on unnecessary copy + ~B() { } +}; +struct A { + static B make() { return B(); } +} a; +A *ap() { return &a; } +int main () { + {B b = A::make();} + {B B = a.make();} + {B b = ap()->make();} + {B b = A().make();} +} |