xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/assign.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
test1(void)3*f4a2713aSLionel Sambuc void *test1(void) { return 0; }
4*f4a2713aSLionel Sambuc 
test2(const struct{int a;} * x)5*f4a2713aSLionel Sambuc void test2 (const struct {int a;} *x) {
6*f4a2713aSLionel Sambuc   x->a = 10; // expected-error {{read-only variable is not assignable}}
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc typedef int arr[10];
test3()10*f4a2713aSLionel Sambuc void test3() {
11*f4a2713aSLionel Sambuc   const arr b;
12*f4a2713aSLionel Sambuc   const int b2[10];
13*f4a2713aSLionel Sambuc   b[4] = 1; // expected-error {{read-only variable is not assignable}}
14*f4a2713aSLionel Sambuc   b2[4] = 1; // expected-error {{read-only variable is not assignable}}
15*f4a2713aSLionel Sambuc }
16