Alp Toker | a644314 | 2013-12-08 18:49:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Eric Christopher | 279c20f | 2011-07-23 02:16:25 +0000 | [diff] [blame] | 2 | // PR 1603 |
| 3 | void func() |
| 4 | { |
| 5 | const int *arr; |
Alp Toker | a644314 | 2013-12-08 18:49:05 +0000 | [diff] [blame] | 6 | arr[0] = 1; // expected-error {{read-only variable is not assignable}} |
Eric Christopher | 279c20f | 2011-07-23 02:16:25 +0000 | [diff] [blame] | 7 | } |
| 8 | |
| 9 | struct foo { |
| 10 | int bar; |
| 11 | }; |
| 12 | struct foo sfoo = { 0 }; |
| 13 | |
| 14 | int func2() |
| 15 | { |
| 16 | const struct foo *fp; |
| 17 | fp = &sfoo; |
Alp Toker | a644314 | 2013-12-08 18:49:05 +0000 | [diff] [blame] | 18 | fp[0].bar = 1; // expected-error {{read-only variable is not assignable}} |
Eric Christopher | 279c20f | 2011-07-23 02:16:25 +0000 | [diff] [blame] | 19 | return sfoo.bar; |
| 20 | } |