summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/cast-to-ref-bool.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2015-10-07 10:22:08 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2015-10-07 10:22:08 +0000
commit78e1baf3d1c63b4a83cb359e3a9c671854a89406 (patch)
tree770e03509c9163db1927c7d464a6a4e11632e539 /test/CodeGenCXX/cast-to-ref-bool.cpp
parent5bb246bc8462539d05797a475669ba63f72186f1 (diff)
Fix crash in codegen on casting to `bool &`.
Currently codegen crashes trying to emit casting to bool &. It happens because bool type is converted to i1 and later then lvalue for reference is converted to i1*. But when codegen tries to load this lvalue it crashes trying to load value from this i1*. Differential Revision: http://reviews.llvm.org/D13325 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/cast-to-ref-bool.cpp')
-rw-r--r--test/CodeGenCXX/cast-to-ref-bool.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/CodeGenCXX/cast-to-ref-bool.cpp b/test/CodeGenCXX/cast-to-ref-bool.cpp
new file mode 100644
index 0000000000..10647205de
--- /dev/null
+++ b/test/CodeGenCXX/cast-to-ref-bool.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: main
+int main(int argc, char **argv) {
+ // CHECK: load i8, i8* %
+ // CHECK-NEXT: trunc i8 %{{.+}} to i1
+ bool b = (bool &)argv[argc][1];
+ return b;
+}