From c05d5156f97c60d90142df43a7362c53808a6c0b Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Tue, 29 Jan 2008 06:46:44 +0000 Subject: [PATCH] Test for PR1942. llvm-svn: 46498 --- .../C++/2008-01-29-ParamAliasesReturn.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 SingleSource/Regression/C++/2008-01-29-ParamAliasesReturn.cpp diff --git a/SingleSource/Regression/C++/2008-01-29-ParamAliasesReturn.cpp b/SingleSource/Regression/C++/2008-01-29-ParamAliasesReturn.cpp new file mode 100644 index 0000000000..9440a4fe14 --- /dev/null +++ b/SingleSource/Regression/C++/2008-01-29-ParamAliasesReturn.cpp @@ -0,0 +1,38 @@ +#include + +class foo +{ +public: + int a; + int b; + int c; + int d; + + foo(void) : a(0), b(0) {} + + foo(int aa, int bb) : a(aa), b(bb) {} + + const foo operator+(const foo& in) const; + + foo operator+=(const foo& in); +}; + +const foo foo::operator+(const foo& in) const { + foo Out; + Out.a = a + in.a; + Out.b = b + in.b; + return Out; +} + +foo foo::operator+=(const foo& in) { + *this = *this + in; + return *this; +} + +int main() { + foo x(1, 2); + foo y(3, 4); + x += y; + printf("%d %d\n", x.a, x.b); + return 0; +}