diff options
Diffstat (limited to 'clang/test/CodeGenCXX/stmtexpr-copy-init.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/stmtexpr-copy-init.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/stmtexpr-copy-init.cpp b/clang/test/CodeGenCXX/stmtexpr-copy-init.cpp new file mode 100644 index 00000000000..8a460e36a27 --- /dev/null +++ b/clang/test/CodeGenCXX/stmtexpr-copy-init.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s +// rdar //8540501 + +struct A +{ + int i; + A (int j) : i(j) {} + A (const A &j) : i(j.i) {} + A& operator= (const A &j) { i = j.i; return *this; } +}; + +A foo(int j) +{ + return ({ j ? A(1) : A(0); }); +} + +int main() +{ + return foo(1).i-1; +} + +void foo2() +{ + A b = ({ A a(1); a; }); +} + |