1// RUN: %clang_cc1 -verify -std=c++1y %s
2
3// Example from the standard.
4namespace X {
5  void p() {
6    q(); // expected-error {{undeclared}}
7    extern void q();
8  }
9  void middle() {
10    q(); // expected-error {{undeclared}}
11  }
12  void q() { /*...*/ }
13  void bottom() {
14    q();
15  }
16}
17int q();
18
19namespace Test1 {
20  void f() {
21    extern int a; // expected-note {{previous}}
22    int g(void); // expected-note {{previous}}
23  }
24  double a; // expected-error {{different type: 'double' vs 'int'}}
25  double g(); // expected-error {{differ only in their return type}}
26}
27
28namespace Test2 {
29  void f() {
30    extern int a; // expected-note {{previous}}
31    int g(void); // expected-note {{previous}}
32  }
33  void h() {
34    extern double a; // expected-error {{different type: 'double' vs 'int'}}
35    double g(void); // expected-error {{differ only in their return type}}
36  }
37}
38
39namespace Test3 {
40  constexpr void (*f())() {
41    void h();
42    return &h;
43  }
44  constexpr void (*g())() {
45    void h();
46    return &h;
47  }
48  static_assert(f() == g(), "");
49}
50
51namespace Test4 {
52  template<typename T>
53  constexpr void (*f())() {
54    void h();
55    return &h;
56  }
57  static_assert(f<int>() == f<char>(), "");
58  void h();
59  static_assert(f<int>() == &h, "");
60}
61
62namespace Test5 {
63  constexpr auto f() -> void (*)() {
64    void g();
65    struct X {
66      friend void g();
67      static constexpr auto h() -> void (*)() { return g; }
68    };
69    return X::h();
70  }
71  void g();
72  static_assert(f() == g, "");
73}
74