1651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// RUN: %clang_cc1 -fsyntax-only -verify %s
252a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher// PR 1603
352a75bab9da635b52c778c0ec178f51b9303ebbeEric Christophervoid func()
452a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher{
552a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher   const int *arr;
6651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines   arr[0] = 1;  // expected-error {{read-only variable is not assignable}}
752a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher}
852a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher
952a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopherstruct foo {
1052a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher  int bar;
1152a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher};
1252a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopherstruct foo sfoo = { 0 };
1352a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher
1452a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopherint func2()
1552a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher{
1652a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher  const struct foo *fp;
1752a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher  fp = &sfoo;
18651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  fp[0].bar = 1;  // expected-error {{read-only variable is not assignable}}
1952a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher  return sfoo.bar;
2052a75bab9da635b52c778c0ec178f51b9303ebbeEric Christopher}
21