Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Chris Lattner | 613cef8 | 2007-08-28 16:20:14 +0000 | [diff] [blame] | 2 | |
| 3 | void *test1(void) { return 0; } |
| 4 | |
Eli Friedman | 1242fff | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 5 | void test2 (const struct {int a;} *x) { |
Richard Trieu | af7d76c | 2015-04-11 01:53:13 +0000 | [diff] [blame] | 6 | // expected-note@-1 {{variable 'x' declared const here}} |
| 7 | |
| 8 | x->a = 10; |
| 9 | // expected-error-re@-1 {{cannot assign to variable 'x' with const-qualified type 'const struct (anonymous struct at {{.*}}assign.c:5:19) *'}} |
Eli Friedman | 1242fff | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 10 | } |
Steve Naroff | 45173e0 | 2008-02-09 16:59:44 +0000 | [diff] [blame] | 11 | |
| 12 | typedef int arr[10]; |
| 13 | void test3() { |
| 14 | const arr b; |
| 15 | const int b2[10]; |
| 16 | b[4] = 1; // expected-error {{read-only variable is not assignable}} |
| 17 | b2[4] = 1; // expected-error {{read-only variable is not assignable}} |
| 18 | } |