forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
SingleSource/Regression/C++/2008-01-29-ParamAliasesReturn.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
|
||
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; | ||
} |