2 // GROUPS passed operators
3 // Check that the & operator, when applied to a global function
4 // or member function returns a proper value as long as the context
5 // in which the result of & is used requires a pointer to a specific
6 // unambigous (function-pointer) type.
8 // This test fails (in test5()) when compiled with g++ 1.34.1.
10 extern "C" int printf (const char *, ...);
12 int function (char c);
13 int function (float f);
24 typedef int (*ptr_to_func_of_char)(char);
25 typedef int (*ptr_to_func_of_float)(float);
26 typedef int (base::*ptr_to_method_of_char)(char);
27 typedef int (base::*ptr_to_method_of_float)(float);
46 ptr_to_func_of_char p0 = &function;
50 ptr_to_func_of_float p1 = &function;
54 ptr_to_method_of_char p2 = &base::method;
55 vp = (void*) p2; // { dg-error "" }
58 ptr_to_method_of_float p3 = &base::method;
59 vp = (void*) p3; // { dg-error "" }
71 return (((ptr_to_func_of_char)vp)(ch) != 9901);
78 return (((ptr_to_func_of_float)vp)(flt) != 9902);
84 ptr_to_method_of_char p = (ptr_to_method_of_char) vp; // { dg-error "" } bad type conversion
86 return ((base_ptr->*p)(ch) != 9904);
92 ptr_to_method_of_float p = (ptr_to_method_of_float) vp; // { dg-error "" } bad type conversion
94 if ((base_ptr->*p)(flt) != 9905) {
100 int function (char c)
106 int function (float f)
112 int base::method (char c)
118 int base::method (float f)