return __builtin_dynamic_object_size (&str[off], 0);
}
+struct S2
+{
+ char arr[7];
+};
+
+struct S1
+{
+ int pad;
+ struct S2 s2;
+};
+
+static long
+g (struct S1 *s1)
+{
+ struct S2 *s2 = &s1->s2;
+ return __builtin_dynamic_object_size (s2->arr, 0);
+}
+
+long
+__attribute__ ((noinline))
+test_alloc_nested_structs (int x)
+{
+ struct S1 *s1 = __builtin_malloc (x);
+ return g (s1);
+}
+
+/* POINTER_PLUS expressions. */
+
size_t
__attribute__ ((noinline))
test_substring_ptrplus (size_t sz, size_t off)
return __builtin_dynamic_object_size (ptr + off2, 0);
}
+/* Function parameters. */
+
size_t
__attribute__ ((access (__read_write__, 1, 2)))
__attribute__ ((noinline))
return __builtin_dynamic_object_size (cond ? obj : unknown, 0);
}
+/* Loops. */
+
size_t
__attribute__ ((noinline))
__attribute__ ((access (__read_write__, 1, 2)))
FAIL ();
if (test_dynarray_cond (1) != 8)
FAIL ();
+ if (test_alloc_nested_structs (42) != 42 - sizeof (int))
+ FAIL ();
if (test_deploop (128, 4) != 128)
FAIL ();
if (test_deploop (128, 129) != 32)
}
/* Safe to convert now, since a valid net offset should be non-negative. */
- if (!types_compatible_p (TREE_TYPE (offset), sizetype))
- fold_convert (sizetype, offset);
+ if (!useless_type_conversion_p (sizetype, TREE_TYPE (offset)))
+ offset = fold_convert (sizetype, offset);
if (TREE_CODE (offset) == INTEGER_CST)
{