Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / dcl.dcl / basic.namespace / namespace.udecl / p11.cpp
blob4ffb93a1ef74d8c8dc0f04185ad3b931f93fadae
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // C++03 [namespace.udecl]p11: (per DR101)
4 // If a function declaration in namespace scope or block scope has
5 // the same name and the same parameter types as a function
6 // introduced by a using-declaration, and the declarations do not declare the
7 // same function, the program is ill-formed. [Note: two using-declarations may
8 // introduce functions with the same name and the same parameter types. If,
9 // for a call to an unqualified function name, function overload resolution
10 // selects the functions introduced by such using-declarations, the function
11 // call is ill-formed.]
13 // FIXME: DR565 introduces parallel wording here for function templates.
15 namespace test0 {
16 namespace ns { void foo(); } // expected-note {{target of using declaration}}
17 int foo(void); // expected-note {{conflicting declaration}}
18 using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
21 namespace test1 {
22 namespace ns { void foo(); } // expected-note {{target of using declaration}}
23 using ns::foo; //expected-note {{using declaration}}
24 int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
27 namespace test2 {
28 namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
29 void test0() {
30 int foo(void); // expected-note {{conflicting declaration}}
31 using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
34 void test1() {
35 using ns::foo; //expected-note {{using declaration}}
36 int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
40 namespace test3 {
41 namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
42 class Test0 {
43 void test() {
44 int foo(void); // expected-note {{conflicting declaration}}
45 using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
49 class Test1 {
50 void test() {
51 using ns::foo; //expected-note {{using declaration}}
52 int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
57 namespace test4 {
58 namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
59 template <typename> class Test0 {
60 void test() {
61 int foo(void); // expected-note {{conflicting declaration}}
62 using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
66 template <typename> class Test1 {
67 void test() {
68 using ns::foo; //expected-note {{using declaration}}
69 int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
74 // FIXME: we should be able to diagnose both of these, but we can't.
75 namespace test5 {
76 namespace ns { void foo(int); }
77 template <typename T> class Test0 {
78 void test() {
79 int foo(T);
80 using ns::foo;
84 template <typename T> class Test1 {
85 void test() {
86 using ns::foo;
87 int foo(T);
91 template class Test0<int>;
92 template class Test1<int>;
95 namespace test6 {
96 namespace ns { void foo(); } // expected-note {{target of using declaration}}
97 using ns::foo; // expected-note {{using declaration}}
98 namespace ns {
99 using test6::foo;
100 void foo() {}
102 void foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}}
105 namespace test7 {
106 void foo();
107 using test7::foo;
108 void foo() {}