Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / dcl.dcl / basic.namespace / namespace.udecl / p8.cpp
blob466097171c8dec9381ceae7f17c4f15bd5a58172
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 struct Opaque0 {};
4 struct Opaque1 {};
6 // Redeclarations are okay in a namespace.
7 namespace test0 {
8 namespace ns {
9 void foo(Opaque0); // expected-note 2 {{candidate function}}
12 using ns::foo;
13 using ns::foo;
15 void test0() {
16 foo(Opaque1()); // expected-error {{no matching function for call}}
19 namespace ns {
20 void foo(Opaque1);
23 void test1() {
24 foo(Opaque1()); // expected-error {{no matching function for call}}
27 using ns::foo;
29 void test2() {
30 foo(Opaque1());
33 using ns::foo;
36 // Make sure we handle transparent contexts the same way.
37 namespace test1 {
38 namespace ns {
39 void foo(Opaque0); // expected-note 2 {{candidate function}}
42 extern "C++" {
43 using ns::foo;
46 void test0() {
47 foo(Opaque1()); // expected-error {{no matching function for call}}
50 namespace ns {
51 void foo(Opaque1);
54 void test1() {
55 foo(Opaque1()); // expected-error {{no matching function for call}}
58 extern "C++" {
59 using ns::foo;
62 void test2() {
63 foo(Opaque1());
67 // Make sure we detect invalid redeclarations that can't be detected
68 // until template instantiation.
69 namespace test2 {
70 template <class T> struct Base {
71 typedef Base type;
72 void foo();
75 template <class T> struct Derived : Base<T> {
76 // These are invalid redeclarations, detectable only after
77 // instantiation.
78 using Base<T>::foo; // expected-note {{previous using decl}}
79 using Base<T>::type::foo; //expected-error {{redeclaration of using decl}}
82 template struct Derived<int>; // expected-note {{in instantiation of template class}}
85 // Redeclarations are okay in a function.
86 namespace test3 {
87 namespace N {
88 int f(int);
89 typedef int type;
92 void g() {
93 using N::f;
94 using N::f;
95 using N::type;
96 using N::type;