diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-01-02 19:48:02 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-01-02 19:48:02 +0000 |
commit | 2e0e6579cae2c8c0f61d55a81315d6166f7d95c3 (patch) | |
tree | aa36d1aa0124a5c7b635fb6c694ef78e0c12e341 /gcc/cp/typeck.c | |
parent | ac601334d6f2a36f86f59f5e323252bf0822a6bc (diff) | |
download | ppe42-gcc-2e0e6579cae2c8c0f61d55a81315d6166f7d95c3.tar.gz ppe42-gcc-2e0e6579cae2c8c0f61d55a81315d6166f7d95c3.zip |
* tree.c (cp_valid_lang_attribute): Don't set CLASSTYPE_COM_INTERFACE
for v3 ABI.
* typeck.c (cp_truthvalue_conversion): New fn.
* cvt.c (ocp_convert): Use it.
* cp-tree.h: Lose c-common.c decls.
* typeck.c (build_unary_op): Restore old &a.f diagnostic code.
* cvt.c (convert_to_void): Use type_unknown_p.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38636 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 443fb2d4b8f..947a1dbcedd 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4348,7 +4348,21 @@ build_x_unary_op (code, xarg) return exp; } -/* Just like truthvalue_conversion, but we want a CLEANUP_POINT_EXPR. */ +/* Like truthvalue_conversion, but handle pointer-to-member constants, where + a null value is represented by an INTEGER_CST of -1. */ + +tree +cp_truthvalue_conversion (expr) + tree expr; +{ + tree type = TREE_TYPE (expr); + if (TYPE_PTRMEM_P (type)) + return build_binary_op (NE_EXPR, expr, integer_zero_node, 1); + else + return truthvalue_conversion (expr); +} + +/* Just like cp_truthvalue_conversion, but we want a CLEANUP_POINT_EXPR. */ tree condition_conversion (expr) @@ -4682,15 +4696,31 @@ build_unary_op (code, xarg, noconvert) return build1 (ADDR_EXPR, unknown_type_node, arg); } - if (TREE_CODE (arg) == COMPONENT_REF && flag_ms_extensions - && type_unknown_p (arg) + if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg) && OVL_NEXT (TREE_OPERAND (arg, 1)) == NULL_TREE) { /* They're trying to take the address of a unique non-static - member function. This is ill-formed, except in microsoft-land. */ + member function. This is ill-formed (except in MS-land), + but let's try to DTRT. + Note: We only handle unique functions here because we don't + want to complain if there's a static overload; non-unique + cases will be handled by instantiate_type. But we need to + handle this case here to allow casts on the resulting PMF. + We could defer this in non-MS mode, but it's easier to give + a useful error here. */ tree base = TREE_TYPE (TREE_OPERAND (arg, 0)); tree name = DECL_NAME (OVL_CURRENT (TREE_OPERAND (arg, 1))); + + if (! flag_ms_extensions) + { + if (current_class_type + && TREE_OPERAND (arg, 0) == current_class_ref) + /* An expression like &memfn. */ + cp_pedwarn ("ISO C++ forbids taking the address of a non-static member function to form a pointer to member function. Say `&%T::%D'", base, name); + else + cp_pedwarn ("ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say `&%T::%D'", base, name); + } arg = build_offset_ref (base, name); } |