aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c')
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c b/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c
new file mode 100644
index 0000000..1bad7f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c
@@ -0,0 +1,19 @@
+/* PR c/122982 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int* f (int);
+
+struct __bounded_ptr {
+ int k;
+ int *buf __attribute__ ((counted_by (k)));
+};
+
+int*
+f1 (int n) { return f (n); }
+
+void h1 (void)
+{
+ int *p = (struct __bounded_ptr) {3, f1 (3)}.buf;
+ __builtin_memset (p, 0, 3 * sizeof p);
+}