diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d4396244164..c3904bffea8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1999-09-03 Nathan Sidwell + + * typeck.c (build_indirect_ref): Reject dereference of pointer to + void. + 1999-09-02 Mark Mitchell * cp-tree.h (cp_function): Move here, from decl.c. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d18744535b7..b86d82db3b7 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2460,7 +2460,14 @@ build_indirect_ref (ptr, errorstring) types. */ tree t = canonical_type_variant (TREE_TYPE (type)); - if (TREE_CODE (pointer) == ADDR_EXPR + if (same_type_p (TYPE_MAIN_VARIANT (t), void_type_node)) + { + /* A pointer to incomplete type (other than cv void) can be + dereferenced [expr.unary.op]/1 */ + cp_error ("`%T' is not a pointer-to-object type", type); + return error_mark_node; + } + else if (TREE_CODE (pointer) == ADDR_EXPR && !flag_volatile && same_type_p (t, TREE_TYPE (TREE_OPERAND (pointer, 0)))) /* The POINTER was something like `&x'. We simplify `*&x' to