xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/2007-10-01-BuildArrayRef.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: not %clang_cc1_only -c %s -o - > /dev/null
2*f4a2713aSLionel Sambuc // PR 1603
3*f4a2713aSLionel Sambuc void func()
4*f4a2713aSLionel Sambuc {
5*f4a2713aSLionel Sambuc    const int *arr;
6*f4a2713aSLionel Sambuc    arr[0] = 1;  // expected-error {{assignment of read-only location}}
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct foo {
10*f4a2713aSLionel Sambuc   int bar;
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc struct foo sfoo = { 0 };
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc int func2()
15*f4a2713aSLionel Sambuc {
16*f4a2713aSLionel Sambuc   const struct foo *fp;
17*f4a2713aSLionel Sambuc   fp = &sfoo;
18*f4a2713aSLionel Sambuc   fp[0].bar = 1;  // expected-error {{ assignment of read-only member}}
19*f4a2713aSLionel Sambuc   return sfoo.bar;
20*f4a2713aSLionel Sambuc }
21