Home | History | Annotate | Download | only in basic.scope.hiding
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
      3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
      4 
      5 // rdar4641403
      6 namespace N {
      7   struct X { // expected-note{{candidate found by name lookup}}
      8     float b;
      9   };
     10 }
     11 
     12 using namespace N;
     13 
     14 typedef struct {
     15   int a;
     16 } X; // expected-note{{candidate found by name lookup}}
     17 
     18 
     19 struct Y { };
     20 void Y(int) { }
     21 
     22 void f() {
     23   X *x; // expected-error{{reference to 'X' is ambiguous}}
     24   Y(1); // okay
     25 }
     26 
     27 namespace PR17731 {
     28   void f() {
     29     struct S { S() {} };
     30     int S(void);
     31     int a = S();
     32     struct S b;
     33     {
     34       int S(void);
     35       int a = S();
     36       struct S c = b;
     37     }
     38     {
     39       struct S { S() {} }; // expected-note {{candidate constructor (the implicit copy constructor) not viable}}
     40 #if __cplusplus >= 201103L // C++11 or later
     41       // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
     42 #endif
     43       int a = S(); // expected-error {{no viable conversion from 'S'}}
     44       struct S c = b; // expected-error {{no viable conversion from 'struct S'}}
     45     }
     46   }
     47   void g() {
     48     int S(void);
     49     struct S { S() {} };
     50     int a = S();
     51     struct S b;
     52     {
     53       int S(void);
     54       int a = S();
     55       struct S c = b;
     56     }
     57     {
     58       struct S { S() {} }; // expected-note {{candidate constructor (the implicit copy constructor) not viable}}
     59 #if __cplusplus >= 201103L // C++11 or later
     60       // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
     61 #endif
     62       int a = S(); // expected-error {{no viable conversion from 'S'}}
     63       struct S c = b; // expected-error {{no viable conversion from 'struct S'}}
     64     }
     65   }
     66 
     67   struct A {
     68     struct B;
     69     void f();
     70     int B;
     71   };
     72   struct A::B {};
     73   void A::f() {
     74     B = 123;
     75     struct B b;
     76   }
     77 }
     78