llvm-project/clang/test/CodeGenCXX/conditional-temporaries.cpp

37 lines
473 B
C++
Raw Normal View History

2010-02-05 01:06:52 +08:00
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
2010-02-05 01:06:52 +08:00
namespace {
static int counter;
struct A {
A() : i(0) { counter++; }
~A() { counter--; }
int i;
};
2010-02-05 01:06:52 +08:00
void g(int) { }
2010-02-05 01:06:52 +08:00
void f1(bool b) {
g(b ? A().i : 0);
g(b || A().i);
g(b && A().i);
}
2010-02-05 01:06:52 +08:00
struct Checker {
Checker() {
f1(true);
f1(false);
}
};
2010-02-05 01:06:52 +08:00
Checker c;
}
2010-02-05 01:06:52 +08:00
// CHECK: define i32 @_Z10getCounterv()
int getCounter() {
// CHECK: ret i32 0
return counter;
}