From 2602f436bec01dc06a25ec94ac7f7e48ff376c7d Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 25 Mar 2009 16:29:33 +0000 Subject: [PATCH] Add a __builtin_object_size test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67688 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/FrontendC/object_size.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/FrontendC/object_size.c diff --git a/test/FrontendC/object_size.c b/test/FrontendC/object_size.c new file mode 100644 index 00000000000..0ddd66bc38c --- /dev/null +++ b/test/FrontendC/object_size.c @@ -0,0 +1,16 @@ +// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep ret | grep {\\-1} | count 1 +// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep ret | grep {0} | count 1 +// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep ret | grep {8} | count 1 + +unsigned t1(void *d) { + return __builtin_object_size(d, 0); +} + +unsigned t2(void *d) { + return __builtin_object_size(d, 2); +} + +char buf[8]; +unsigned t3() { + return __builtin_object_size(buf, 0); +}