summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/object-size.c19
-rw-r--r--test/Sema/builtin-object-size.c15
2 files changed, 34 insertions, 0 deletions
diff --git a/test/CodeGen/object-size.c b/test/CodeGen/object-size.c
index fe4c1859a2..a824f554b5 100644
--- a/test/CodeGen/object-size.c
+++ b/test/CodeGen/object-size.c
@@ -549,3 +549,22 @@ int incomplete_and_function_types() {
// CHECK: store i32 0
gi = __builtin_object_size(incomplete_char_array, 3);
}
+
+// Flips between the pointer and lvalue evaluator a lot.
+void deeply_nested() {
+ struct {
+ struct {
+ struct {
+ struct {
+ int e[2];
+ char f; // Inhibit our writing-off-the-end check
+ } d[2];
+ } c[2];
+ } b[2];
+ } *a;
+
+ // CHECK: store i32 4
+ gi = __builtin_object_size(&a->b[1].c[1].d[1].e[1], 1);
+ // CHECK: store i32 4
+ gi = __builtin_object_size(&a->b[1].c[1].d[1].e[1], 3);
+}
diff --git a/test/Sema/builtin-object-size.c b/test/Sema/builtin-object-size.c
index 14674c66f3..300c739bbd 100644
--- a/test/Sema/builtin-object-size.c
+++ b/test/Sema/builtin-object-size.c
@@ -76,3 +76,18 @@ int pr28314(void) {
a += __builtin_object_size(p3->b, 0);
return a;
}
+
+int pr31843() {
+ int n = 0;
+
+ struct { int f; } a;
+ int b;
+ n += __builtin_object_size(({&(b ? &a : &a)->f; pr31843;}), 0); // expected-warning{{expression result unused}}
+
+ struct statfs { char f_mntonname[1024];};
+ struct statfs *outStatFSBuf;
+ n += __builtin_object_size(outStatFSBuf->f_mntonname ? "" : "", 1); // expected-warning{{address of array}}
+ n += __builtin_object_size(outStatFSBuf->f_mntonname ?: "", 1);
+
+ return n;
+}