1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3void f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
4void (*pf)() const; // expected-error {{pointer to function type cannot have 'const' qualifier}}
5extern void (&rf)() const; // expected-error {{reference to function type cannot have 'const' qualifier}}
6
7typedef void cfn() const;
8cfn f2; // expected-error {{non-member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}}
9
10class C {
11  void f() const;
12  cfn f2;
13  static void f3() const; // expected-error {{static member function cannot have 'const' qualifier}}
14  static cfn f4; // expected-error {{static member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}}
15
16  void m1() {
17    x = 0;
18  }
19
20  void m2() const {
21    x = 0; // expected-error {{read-only variable is not assignable}}
22  }
23
24  int x;
25};
26
27void (C::*mpf)() const;
28cfn C::*mpg;
29
30// Don't crash!
31void (PR14171)() const; // expected-error {{non-member function cannot have 'const' qualifier}}
32
33// Test template instantiation of decayed array types.  Not really related to
34// type quals.
35template <typename T> void arrayDecay(const T a[]) { }
36void instantiateArrayDecay() {
37  int a[1];
38  arrayDecay(a);
39}
40