blob: 1fff77864420c8d7ff57d9219ca17c661f6efbc8 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Chris Lattner613cef82007-08-28 16:20:14 +00002
3void *test1(void) { return 0; }
4
Eli Friedman1242fff2008-02-06 22:48:16 +00005void test2 (const struct {int a;} *x) {
Richard Trieuaf7d76c2015-04-11 01:53:13 +00006 // 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 Friedman1242fff2008-02-06 22:48:16 +000010}
Steve Naroff45173e02008-02-09 16:59:44 +000011
12typedef int arr[10];
13void 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}