// { dg-do assemble }
|
// { dg-do assemble }
|
//980529 bkoz
|
//980529 bkoz
|
//3.4.5 Class member access via pointer and non-pointer
|
//3.4.5 Class member access via pointer and non-pointer
|
// non-nested dtor calls
|
// non-nested dtor calls
|
|
|
int counter = 0;
|
int counter = 0;
|
|
|
struct X {
|
struct X {
|
int rank;
|
int rank;
|
X(int init = 64) : rank(init) { }
|
X(int init = 64) : rank(init) { }
|
~X() { ++counter; }
|
~X() { ++counter; }
|
typedef X classtype;
|
typedef X classtype;
|
};
|
};
|
typedef X globaltype;
|
typedef X globaltype;
|
|
|
#if 0
|
#if 0
|
template
|
template
|
struct X_tem {
|
struct X_tem {
|
T rank;
|
T rank;
|
X_tem(T init = T(64) ) : rank(init) { }
|
X_tem(T init = T(64) ) : rank(init) { }
|
~X_tem() { ++counter; }
|
~X_tem() { ++counter; }
|
typedef X_tem classtype_tem;
|
typedef X_tem classtype_tem;
|
};
|
};
|
typedef X_tem globaltype_tem;
|
typedef X_tem globaltype_tem;
|
#endif
|
#endif
|
|
|
|
|
|
|
|
|
int main(void)
|
int main(void)
|
{
|
{
|
// 3.4.5 Class member access
|
// 3.4.5 Class member access
|
// p 2
|
// p 2
|
// if the id-expression in a class member access is an
|
// if the id-expression in a class member access is an
|
// unqualified-id, and the type of the object expression is of class
|
// unqualified-id, and the type of the object expression is of class
|
// type C (or pointer to class type C), the unqualified-id is looked
|
// type C (or pointer to class type C), the unqualified-id is looked
|
// up in the scope of class C. If the type of the object-expression
|
// up in the scope of class C. If the type of the object-expression
|
// is of pointer to scalar type, the unqualified-id is looked up in
|
// is of pointer to scalar type, the unqualified-id is looked up in
|
// the context of the complete postfix-expression.
|
// the context of the complete postfix-expression.
|
|
|
// p 3
|
// p 3
|
// if the unqualitified id is ~type-name, and the type of the object
|
// if the unqualitified id is ~type-name, and the type of the object
|
// expression is of a class type C (or pointer to class type C), the
|
// expression is of a class type C (or pointer to class type C), the
|
// type-name is looked up in the context of the entire
|
// type-name is looked up in the context of the entire
|
// postfix-expression and in the scope of class C. The type-name
|
// postfix-expression and in the scope of class C. The type-name
|
// shall refer to a class-name. If type-name is found in both
|
// shall refer to a class-name. If type-name is found in both
|
// contexts, the name shall refer to the same class type. If the
|
// contexts, the name shall refer to the same class type. If the
|
// type of the object expression is of scalar type, the type-name is
|
// type of the object expression is of scalar type, the type-name is
|
// looked up in the complete postfix-expression.
|
// looked up in the complete postfix-expression.
|
|
|
typedef X localtype;
|
typedef X localtype;
|
|
|
//
|
//
|
// 1 non-templatized, pointer, unqualified
|
// 1 non-templatized, pointer, unqualified
|
//
|
//
|
X x01 ;
|
X x01 ;
|
X *px = &x01;
|
X *px = &x01;
|
px->~X();
|
px->~X();
|
|
|
X x02 (66);
|
X x02 (66);
|
px = &x02;
|
px = &x02;
|
px->~localtype();
|
px->~localtype();
|
|
|
X x03 (68);
|
X x03 (68);
|
px = &x03;
|
px = &x03;
|
px->~classtype(); //-g++ //p3: unqual-id lookup in object and postfix-expr
|
px->~classtype(); //-g++ //p3: unqual-id lookup in object and postfix-expr
|
|
|
X x04 (70);
|
X x04 (70);
|
px = &x04;
|
px = &x04;
|
px->~globaltype();
|
px->~globaltype();
|
|
|
|
|
// p 1
|
// p 1
|
// . . . the id-expression is first looked up in the class of the
|
// . . . the id-expression is first looked up in the class of the
|
// object-expression. If the identifier is not found, itis then
|
// object-expression. If the identifier is not found, itis then
|
// looked up in the context of the entier postfix-expression and
|
// looked up in the context of the entier postfix-expression and
|
// shall name a class or function template. If the lookup in the
|
// shall name a class or function template. If the lookup in the
|
// class of the object-expression finds a template, the name is also
|
// class of the object-expression finds a template, the name is also
|
// looked up in teh context of the entier postfix-expression and
|
// looked up in teh context of the entier postfix-expression and
|
// 1 if the name is not found, use the name from the object-expr
|
// 1 if the name is not found, use the name from the object-expr
|
// 2 if the name found in postfix-expr != class template, use object-expr
|
// 2 if the name found in postfix-expr != class template, use object-expr
|
// 3 if name found is class template, name must match object-expr or error
|
// 3 if name found is class template, name must match object-expr or error
|
|
|
// p 4
|
// p 4
|
|
|
// if the id-expr in a class member acess is a qualified-id, the
|
// if the id-expr in a class member acess is a qualified-id, the
|
// id-expression is looked up in both the context of the entire
|
// id-expression is looked up in both the context of the entire
|
// postfix-expr and in the scope of the class of the object-expr. If
|
// postfix-expr and in the scope of the class of the object-expr. If
|
// the name is found in both contexts, the id-expr shall refer to
|
// the name is found in both contexts, the id-expr shall refer to
|
// the same entity.
|
// the same entity.
|
|
|
|
|
//
|
//
|
// 2 non-templatized, pointer, qualified
|
// 2 non-templatized, pointer, qualified
|
//
|
//
|
X x05 ;
|
X x05 ;
|
px = &x05;
|
px = &x05;
|
px->X::~X();
|
px->X::~X();
|
|
|
X x06 (66);
|
X x06 (66);
|
px = &x06;
|
px = &x06;
|
px->X::~localtype();
|
px->X::~localtype();
|
|
|
X x07 (68);
|
X x07 (68);
|
px = &x07;
|
px = &x07;
|
px->X::~classtype(); // -edg
|
px->X::~classtype(); // -edg
|
|
|
X x08 (70);
|
X x08 (70);
|
px = &x08;
|
px = &x08;
|
px->X::~globaltype();
|
px->X::~globaltype();
|
|
|
X x09 (66);
|
X x09 (66);
|
px = &x09;
|
px = &x09;
|
px->localtype::~localtype();
|
px->localtype::~localtype();
|
|
|
X x10 (68);
|
X x10 (68);
|
px = &x10;
|
px = &x10;
|
px->classtype::~classtype();
|
px->classtype::~classtype();
|
|
|
X x11 (70);
|
X x11 (70);
|
px = &x11;
|
px = &x11;
|
px->globaltype::~globaltype();
|
px->globaltype::~globaltype();
|
|
|
X x12 (66);
|
X x12 (66);
|
px = &x12;
|
px = &x12;
|
px->classtype::~localtype();
|
px->classtype::~localtype();
|
|
|
X x13 (68);
|
X x13 (68);
|
px = &x13;
|
px = &x13;
|
px->globaltype::~localtype();
|
px->globaltype::~localtype();
|
|
|
X x14 (70);
|
X x14 (70);
|
px = &x14;
|
px = &x14;
|
px->localtype::~globaltype();
|
px->localtype::~globaltype();
|
|
|
X x15 (70);
|
X x15 (70);
|
px = &x15;
|
px = &x15;
|
px->classtype::~globaltype();
|
px->classtype::~globaltype();
|
|
|
X x16 (70);
|
X x16 (70);
|
px = &x16;
|
px = &x16;
|
px->localtype::~classtype(); //-edg
|
px->localtype::~classtype(); //-edg
|
|
|
X x17 (70);
|
X x17 (70);
|
px = &x17;
|
px = &x17;
|
px->globaltype::~classtype(); //-edg
|
px->globaltype::~classtype(); //-edg
|
|
|
#if 0
|
#if 0
|
//
|
//
|
// non-templatized, non-pointer
|
// non-templatized, non-pointer
|
//
|
//
|
X xo5 ;
|
X xo5 ;
|
xo5.~X(); //unqualified
|
xo5.~X(); //unqualified
|
|
|
localtype xo6 (66);
|
localtype xo6 (66);
|
xo6.~localtype();
|
xo6.~localtype();
|
|
|
X xo7 (68);
|
X xo7 (68);
|
xo7.~classtype();
|
xo7.~classtype();
|
|
|
X xo8 (70);
|
X xo8 (70);
|
xo8.~globaltype();
|
xo8.~globaltype();
|
|
|
|
|
//
|
//
|
// templatized, pointer
|
// templatized, pointer
|
//
|
//
|
X_tem xto1 ;
|
X_tem xto1 ;
|
X_tem *pxt = &xto1;
|
X_tem *pxt = &xto1;
|
pxt->~X_tem(); //unqualified
|
pxt->~X_tem(); //unqualified
|
|
|
typedef X_tem localtype_tem;
|
typedef X_tem localtype_tem;
|
localtype_tem xto2 (66);
|
localtype_tem xto2 (66);
|
pxt = &xto2;
|
pxt = &xto2;
|
pxt->~localtype_tem();
|
pxt->~localtype_tem();
|
|
|
//paragraph 2: unqualitifed id looked up in scope of post-fix expr if object
|
//paragraph 2: unqualitifed id looked up in scope of post-fix expr if object
|
X_tem xto3 (68);
|
X_tem xto3 (68);
|
pxt = &xto3;
|
pxt = &xto3;
|
pxt->~classtype_tem();
|
pxt->~classtype_tem();
|
|
|
X_tem xto4 (70);
|
X_tem xto4 (70);
|
pxt = &xto4;
|
pxt = &xto4;
|
pxt->~globaltype_tem();
|
pxt->~globaltype_tem();
|
|
|
//
|
//
|
// templatized, non-pointer
|
// templatized, non-pointer
|
//
|
//
|
X_tem xto5 ;
|
X_tem xto5 ;
|
xto5.~X_tem(); //unqualified
|
xto5.~X_tem(); //unqualified
|
|
|
localtype_tem xto6 (66);
|
localtype_tem xto6 (66);
|
xto6.~localtype_tem();
|
xto6.~localtype_tem();
|
|
|
X_tem xto7 (68);
|
X_tem xto7 (68);
|
xto7.~classtype_tem();
|
xto7.~classtype_tem();
|
|
|
X_tem xto8 (70);
|
X_tem xto8 (70);
|
xto8.~globaltype_tem();
|
xto8.~globaltype_tem();
|
#endif
|
#endif
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|