diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/init')
-rw-r--r-- | gcc/testsuite/g++.dg/init/elide3.C | 50 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/pr66857.C | 19 |
2 files changed, 69 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/init/elide3.C b/gcc/testsuite/g++.dg/init/elide3.C new file mode 100644 index 0000000000..7eb0389a3f --- /dev/null +++ b/gcc/testsuite/g++.dg/init/elide3.C @@ -0,0 +1,50 @@ +// PR c++/67557 +// { dg-do run } + +namespace std +{ + struct string + { + typedef unsigned long size_type; + const char* _M_p; + char _M_local_buf[1]; + + string(const char* s) : _M_p(_M_local_buf) + { + __builtin_printf("%p constructed\n", this); + } + + string(const string& s) : _M_p(_M_local_buf) + { + __builtin_printf("%p copied from %p\n", this, &s); + } + + ~string() + { + __builtin_printf("%p destroyed\n", this); + if (_M_p != _M_local_buf) + __builtin_abort(); + } + }; +} + +struct StartTag +{ + explicit StartTag(std::string const & tag) : tag_(tag), keepempty_(false) {} + std::string tag_; + bool keepempty_; +}; + +StartTag fontToStartTag() { return StartTag(""); } + +struct FontTag : public StartTag +{ + FontTag() : StartTag(fontToStartTag()) {} +}; + +int main() +{ + FontTag x; + __builtin_printf("%p x.tag_ in main()\n", &x.tag_); + return 0; +} diff --git a/gcc/testsuite/g++.dg/init/pr66857.C b/gcc/testsuite/g++.dg/init/pr66857.C new file mode 100644 index 0000000000..43b0927227 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/pr66857.C @@ -0,0 +1,19 @@ +// PR c++/66857 +// { dg-do run } + +const int i = 0; + +struct Test +{ + Test (const int &rhs) + { + if (&rhs != &i) + __builtin_abort (); + } +}; + +int +main (void) +{ + Test test = i; +} |