1e63d087bSDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -verify %s 2*e7cbb3edSCharles Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s 3*e7cbb3edSCharles Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 4e63d087bSDouglas Gregor 5e63d087bSDouglas Gregor // rdar4641403 6e63d087bSDouglas Gregor namespace N { 7e63d087bSDouglas Gregor struct X { // expected-note{{candidate found by name lookup}} 8e63d087bSDouglas Gregor float b; 9e63d087bSDouglas Gregor }; 10e63d087bSDouglas Gregor } 11e63d087bSDouglas Gregor 12e63d087bSDouglas Gregor using namespace N; 13e63d087bSDouglas Gregor 14e63d087bSDouglas Gregor typedef struct { 15e63d087bSDouglas Gregor int a; 16e63d087bSDouglas Gregor } X; // expected-note{{candidate found by name lookup}} 17e63d087bSDouglas Gregor 18e63d087bSDouglas Gregor 19e63d087bSDouglas Gregor struct Y { }; Y(int)20e63d087bSDouglas Gregorvoid Y(int) { } 21e63d087bSDouglas Gregor f()22e63d087bSDouglas Gregorvoid f() { 23e63d087bSDouglas Gregor X *x; // expected-error{{reference to 'X' is ambiguous}} 24e63d087bSDouglas Gregor Y(1); // okay 25e63d087bSDouglas Gregor } 26e63d087bSDouglas Gregor 273876cc88SRichard Smith namespace PR17731 { f()283876cc88SRichard Smith void f() { 293876cc88SRichard Smith struct S { S() {} }; 303876cc88SRichard Smith int S(void); 313876cc88SRichard Smith int a = S(); 323876cc88SRichard Smith struct S b; 333876cc88SRichard Smith { 343876cc88SRichard Smith int S(void); 353876cc88SRichard Smith int a = S(); 363876cc88SRichard Smith struct S c = b; 373876cc88SRichard Smith } 383876cc88SRichard Smith { 39*e7cbb3edSCharles Li struct S { S() {} }; // expected-note {{candidate constructor (the implicit copy constructor) not viable}} 40*e7cbb3edSCharles Li #if __cplusplus >= 201103L // C++11 or later 41*e7cbb3edSCharles Li // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} 42*e7cbb3edSCharles Li #endif 433876cc88SRichard Smith int a = S(); // expected-error {{no viable conversion from 'S'}} 443876cc88SRichard Smith struct S c = b; // expected-error {{no viable conversion from 'struct S'}} 453876cc88SRichard Smith } 463876cc88SRichard Smith } g()473876cc88SRichard Smith void g() { 483876cc88SRichard Smith int S(void); 493876cc88SRichard Smith struct S { S() {} }; 503876cc88SRichard Smith int a = S(); 513876cc88SRichard Smith struct S b; 523876cc88SRichard Smith { 533876cc88SRichard Smith int S(void); 543876cc88SRichard Smith int a = S(); 553876cc88SRichard Smith struct S c = b; 563876cc88SRichard Smith } 573876cc88SRichard Smith { 58*e7cbb3edSCharles Li struct S { S() {} }; // expected-note {{candidate constructor (the implicit copy constructor) not viable}} 59*e7cbb3edSCharles Li #if __cplusplus >= 201103L // C++11 or later 60*e7cbb3edSCharles Li // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} 61*e7cbb3edSCharles Li #endif 623876cc88SRichard Smith int a = S(); // expected-error {{no viable conversion from 'S'}} 633876cc88SRichard Smith struct S c = b; // expected-error {{no viable conversion from 'struct S'}} 643876cc88SRichard Smith } 653876cc88SRichard Smith } 663876cc88SRichard Smith 673876cc88SRichard Smith struct A { 683876cc88SRichard Smith struct B; 693876cc88SRichard Smith void f(); 703876cc88SRichard Smith int B; 713876cc88SRichard Smith }; 723876cc88SRichard Smith struct A::B {}; f()733876cc88SRichard Smith void A::f() { 743876cc88SRichard Smith B = 123; 753876cc88SRichard Smith struct B b; 763876cc88SRichard Smith } 773876cc88SRichard Smith } 78