diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/readonly-loc.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/readonly-loc.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/readonly-loc.c b/gcc/testsuite/gcc.dg/readonly-loc.c new file mode 100644 index 000000000..c5d1c97d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/readonly-loc.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +int func() +{ + const int *arr; + const int arr2[5]; + arr[0] = 1; /* { dg-error "assignment of read-only location" "*(arr)" } */ + arr[1] = 1; /* { dg-error "assignment of read-only location" "*(arr + 4u)" } */ + arr2[0] = 1; /* { dg-error "assignment of read-only location" "arr2\[0\]" } */ + arr2[1] = 1; /* { dg-error "assignment of read-only location" "arr2\[1\]" } */ +} |