diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/lvalue-3.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/lvalue-3.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/lvalue-3.c b/gcc/testsuite/gcc.dg/lvalue-3.c new file mode 100644 index 000000000..6a500d4d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lvalue-3.c @@ -0,0 +1,14 @@ +/* Test that assignment of a read-only variable that gets const-ness + from a read-only field is diagnosed. */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s { const int a; } x; +typeof (x.a) b; +void +f (void) +{ + x.a = 1; /* { dg-error "assignment of read-only member 'a'" } */ + b = 1; /* { dg-error "assignment of read-only variable 'b'" } */ +} |