+1999-05-03 Mark Mitchell <mark@codesourcery.com>
+
+ * typeck.c (build_const_cast): Tighten checks for legality.
+
1999-05-02 Martin von Löwis <loewis@informatik.hu-berlin.de>
* init.c (build_member_call): Lookup names coming from
return t;
}
- if (!POINTER_TYPE_P (type) && !TYPE_PTRMEMFUNC_P (type))
+ if (!POINTER_TYPE_P (type))
{
- cp_error ("`%T' is not a pointer, reference, or pointer-to-member type",
+ cp_error ("`%T' is not a pointer, reference, or pointer-to-data-member type",
type);
cp_error ("as required by const_cast");
+ }
+ else if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
+ {
+ cp_error ("`%T' is a pointer or reference to a function type",
+ type);
+ cp_error ("which is forbidden by const_cast");
return error_mark_node;
}
int main()
{
A a;
+ typedef void (A::*F)();
+ F p;
+
const_cast<const A>(a); // ERROR - const_cast requires pointer/ref types
+ const_cast<F>(p); // ERROR - const_cast requires pointer/ref types
+ const_cast<int (*)()>(&main); // ERROR - function type in const_cast
+ const_cast<int (&)()>(main); // ERROR - function type in const_cast
}