4 // GROUPS passed operators
5 // Check that the & operator, when applied to a global function
6 // or member function returns a proper value as long as the context
7 // in which the result of & is used requires a pointer to a specific
8 // unambigous (function-pointer) type.
10 // This test fails (in test5()) when compiled with g++ 1.34.1.
12 extern "C" int printf (const char *, ...);
14 int function (char c);
15 int function (float f);
26 typedef int (*ptr_to_func_of_char)(char);
27 typedef int (*ptr_to_func_of_float)(float);
28 typedef int (base::*ptr_to_method_of_char)(char);
29 typedef int (base::*ptr_to_method_of_float)(float);
48 ptr_to_func_of_char p0 = &function;
52 ptr_to_func_of_float p1 = &function;
56 ptr_to_method_of_char p2 = &base::method;
57 vp = (void*) p2; // { dg-warning "converting" }
60 ptr_to_method_of_float p3 = &base::method;
61 vp = (void*) p3; // { dg-warning "converting" }
73 return (((ptr_to_func_of_char)vp)(ch) != 9901);
80 return (((ptr_to_func_of_float)vp)(flt) != 9902);
86 ptr_to_method_of_char p = (ptr_to_method_of_char) vp; // { dg-error "invalid cast" } bad type conversion
88 return ((base_ptr->*p)(ch) != 9904);
94 ptr_to_method_of_float p = (ptr_to_method_of_float) vp; // { dg-error "invalid cast" } bad type conversion
96 if ((base_ptr->*p)(flt) != 9905) {
102 int function (char c)
108 int function (float f)
114 int base::method (char c)
120 int base::method (float f)