2009-01-25 05:16:55 +08:00
// RUN: clang -fsyntax-only -verify %s
struct A { } ;
enum B { Dummy } ;
namespace C { }
2009-01-26 03:43:20 +08:00
struct D : A { } ;
2009-01-27 03:54:48 +08:00
struct E : A { } ;
struct F : D , E { } ;
struct G : virtual D { } ;
2009-01-25 05:16:55 +08:00
int A : : * pdi1 ;
int ( : : A : : * pdi2 ) ;
int ( A : : * pfi ) ( int ) ;
int B : : * pbi ; // expected-error {{expected a class or namespace}}
int C : : * pci ; // expected-error {{'pci' does not point into a class}}
void A : : * pdv ; // expected-error {{'pdv' declared as a member pointer to void}}
int & A : : * pdr ; // expected-error {{'pdr' declared as a pointer to a reference}}
2009-01-25 07:29:36 +08:00
void f ( ) {
// This requires tentative parsing.
int ( A : : * pf ) ( int , int ) ;
2009-01-26 03:43:20 +08:00
// Implicit conversion to bool.
bool b = pdi1 ;
b = pfi ;
// Conversion from null pointer constant.
pf = 0 ;
pf = __null ;
// Conversion to member of derived.
int D : : * pdid = pdi1 ;
pdid = pdi2 ;
2009-01-27 03:54:48 +08:00
// Fail conversion due to ambiguity and virtuality.
int F : : * pdif = pdi1 ; // expected-error {{ambiguous conversion from pointer to member of base class 'struct A' to pointer to member of derived class 'struct F'}} expected-error {{incompatible type}}
int G : : * pdig = pdi1 ; // expected-error {{conversion from pointer to member of class 'struct A' to pointer to member of class 'struct G' via virtual base 'struct D' is not allowed}} expected-error {{incompatible type}}
2009-01-29 02:33:18 +08:00
// Conversion to member of base.
pdi1 = pdid ; // expected-error {{incompatible type assigning 'int struct D::*', expected 'int struct A::*'}}
2009-01-25 07:29:36 +08:00
}
2009-02-04 04:19:35 +08:00
struct HasMembers
{
int i ;
void f ( ) ;
} ;
namespace Fake
{
int i ;
void f ( ) ;
}
void g ( ) {
int HasMembers : : * pmi = & HasMembers : : i ;
int * pni = & Fake : : i ;
// FIXME: Test the member function, too.
void ( * pnf ) ( ) = & Fake : : f ;
}