__builtin_object_size(ptr, type) returns -1 for type = {0,1} if there are any side-effects.
llvm-svn: 92453
diff --git a/clang/test/CodeGen/object-size.c b/clang/test/CodeGen/object-size.c
index 4947c19..4b8cd55 100644
--- a/clang/test/CodeGen/object-size.c
+++ b/clang/test/CodeGen/object-size.c
@@ -109,3 +109,14 @@
   // CHECK:       %call = call i8* @__inline_strcpy_chk(i8* %tmp1, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
   strcpy(gp += 1, "Hi there");
 }
+
+void test17() {
+  // CHECK: store i32 -1
+  gi = __builtin_object_size(gp++, 0);
+  // CHECK: store i32 -1
+  gi = __builtin_object_size(gp++, 1);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(gp++, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(gp++, 3);
+}