Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / basic / basic.link / p7.cpp
blob9a85eacdda4f6e2ce72b7b652fbea0f0adf8d229
1 // RUN: %clang_cc1 -verify -std=c++1y %s
3 // Example from the standard.
4 namespace X {
5 void p() {
6 q(); // expected-error {{undeclared}}
7 extern void q();
9 void middle() {
10 q(); // expected-error {{undeclared}}
12 void q() { /*...*/ }
13 void bottom() {
14 q();
17 int q();
19 namespace Test1 {
20 void f() {
21 extern int a; // expected-note {{previous}}
22 int g(void); // expected-note {{previous}}
24 double a; // expected-error {{different type: 'double' vs 'int'}}
25 double g(); // expected-error {{differ only in their return type}}
28 namespace Test2 {
29 void f() {
30 extern int a; // expected-note {{previous}}
31 int g(void); // expected-note {{previous}}
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}}
39 namespace Test3 {
40 constexpr void (*f())() {
41 void h();
42 return &h;
44 constexpr void (*g())() {
45 void h();
46 return &h;
48 static_assert(f() == g(), "");
51 namespace Test4 {
52 template<typename T>
53 constexpr void (*f())() {
54 void h();
55 return &h;
57 static_assert(f<int>() == f<char>(), "");
58 void h();
59 static_assert(f<int>() == &h, "");
62 namespace Test5 {
63 constexpr auto f() -> void (*)() {
64 void g();
65 struct X {
66 friend void g();
67 static constexpr auto h() -> void (*)() { return g; }
69 return X::h();
71 void g();
72 static_assert(f() == g, "");