diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8f1f7152e6c..78ca95441ef 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,33 @@ +Thu Feb 20 15:12:15 1997 Jason Merrill + + * call.c (build_over_call): Call mark_used before trying to elide + the call. + + * decl.c (implicitly_declare): Don't set DECL_ARTIFICIAL. + +Wed Feb 19 11:18:53 1997 Brendan Kehoe + + * typeck.c (build_modify_expr): Always pedwarn for a cast to + non-reference used as an lvalue. + +Wed Feb 19 10:35:37 1997 Jason Merrill + + * cvt.c (cp_convert_to_pointer): Convert from 0 to a pmf properly. + +Tue Feb 18 15:40:57 1997 Jason Merrill + + * parse.y (handler): Fix template typo. + +Sun Feb 16 02:12:28 1997 Jason Merrill + + * error.c (lang_decl_name): New fn. + * tree.c (lang_printable_name): Use it. + +Fri Feb 14 16:57:05 1997 Mike Stump + + * g++spec.c: Include config.h so that we can catch bzero #defines + from the config file. + Tue Feb 11 13:50:48 1997 Mike Stump * new1.cc: Include a declaration for malloc, to avoid warning, and diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f9fe74dc1d1..75e7b561534 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5092,6 +5092,10 @@ build_over_call (fn, convs, args, flags) converted_args = nreverse (converted_args); + /* [class.copy]: the copy constructor is implicitly defined even if the + implementation elided its use. */ + mark_used (fn); + /* Avoid actually calling copy constructors and copy assignment operators, if possible. */ if (DECL_CONSTRUCTOR_P (fn) @@ -5155,8 +5159,6 @@ build_over_call (fn, convs, args, flags) return val; } - mark_used (fn); - if (DECL_CONTEXT (fn) && IS_SIGNATURE (DECL_CONTEXT (fn))) return build_signature_method_call (fn, converted_args); else if (DECL_VINDEX (fn) && (flags & LOOKUP_NONVIRTUAL) == 0) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index cdc8dd64606..9bd73abc127 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2163,6 +2163,7 @@ extern char *parm_as_string PROTO((int, int)); extern char *op_as_string PROTO((enum tree_code, int)); extern char *assop_as_string PROTO((enum tree_code, int)); extern char *cv_as_string PROTO((tree, int)); +extern char *lang_decl_name PROTO((tree, int)); /* in except.c */ extern void init_exception_processing PROTO((void)); @@ -2410,7 +2411,7 @@ extern tree function_arg_chain PROTO((tree)); extern int promotes_to_aggr_type PROTO((tree, enum tree_code)); extern int is_aggr_type_2 PROTO((tree, tree)); extern void message_2_types PROTO((void (*)(), char *, tree, tree)); -extern char *lang_printable_name PROTO((tree)); +extern char *lang_printable_name PROTO((tree, int)); extern tree build_exception_variant PROTO((tree, tree)); extern tree copy_to_permanent PROTO((tree)); extern void print_lang_statistics PROTO((void)); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index ad3c2080d98..1c40640a45a 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -272,6 +272,8 @@ cp_convert_to_pointer (type, expr) if (integer_zerop (expr)) { + if (TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE) + return build_ptrmemfunc (type, expr, 0); expr = build_int_2 (0, 0); TREE_TYPE (expr) = type; return expr; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 26601104b9a..77dce5b4a73 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3583,7 +3583,6 @@ implicitly_declare (functionid) DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; /* ANSI standard says implicit declarations are in the innermost block. So we record the decl in the standard fashion. */ diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 31431e75adf..8d9ade45fcf 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1486,6 +1486,41 @@ decl_as_string (decl, v) return (char *)obstack_base (&scratch_obstack); } +/* Generate the three forms of printable names for lang_printable_name. */ + +char * +lang_decl_name (decl, v) + tree decl; + int v; +{ + if (v >= 2) + return decl_as_string (decl, 1); + + OB_INIT (); + + if (v == 1 && DECL_CONTEXT (decl) + && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't') + { + tree cname; + if (TREE_CODE (decl) == FUNCTION_DECL) + cname = DECL_CLASS_CONTEXT (decl); + else + cname = DECL_CONTEXT (decl); + dump_type (cname, 0); + OB_PUTC2 (':', ':'); + } + + if (TREE_CODE (decl) == FUNCTION_DECL) + dump_function_name (decl); + else + dump_decl (DECL_NAME (decl), 0); + + OB_FINISH (); + + return (char *)obstack_base (&scratch_obstack); +} + + char * cp_file_of (t) tree t; diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c index e4bfc8d6d88..d41c516f64e 100644 --- a/gcc/cp/g++spec.c +++ b/gcc/cp/g++spec.c @@ -1,5 +1,7 @@ #include #include + +#include "config.h" #include "gansidecl.h" /* This bit is set if we saw a `-xfoo' language specification. */ diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 6a53feef941..ff0a139f3f2 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -3742,18 +3742,18 @@ handler: { if (processing_template_decl) { - TREE_OPERAND ($3, 0) = TREE_CHAIN ($3); - TREE_CHAIN ($3) = NULL_TREE; - last_tree = $3; + TREE_OPERAND ($2, 0) = TREE_CHAIN ($2); + TREE_CHAIN ($2) = NULL_TREE; + last_tree = $2; } } compstmt { if (processing_template_decl) { - TREE_OPERAND ($3, 1) = TREE_CHAIN ($3); - TREE_CHAIN ($3) = NULL_TREE; - last_tree = $3; + TREE_OPERAND ($2, 1) = TREE_CHAIN ($2); + TREE_CHAIN ($2) = NULL_TREE; + last_tree = $2; } else expand_end_catch_block (); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index a5b791687d3..df732f53440 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1385,8 +1385,9 @@ message_2_types (pfn, s, type1, type2) #define PRINT_RING_SIZE 4 char * -lang_printable_name (decl) +lang_printable_name (decl, v) tree decl; + int v; { static tree decl_ring[PRINT_RING_SIZE]; static char *print_ring[PRINT_RING_SIZE]; @@ -1394,9 +1395,10 @@ lang_printable_name (decl) int i; /* Only cache functions. */ - if (TREE_CODE (decl) != FUNCTION_DECL + if (v < 2 + || TREE_CODE (decl) != FUNCTION_DECL || DECL_LANG_SPECIFIC (decl) == 0) - return decl_as_string (decl, 1); + return lang_decl_name (decl, v); /* See if this print name is lying around. */ for (i = 0; i < PRINT_RING_SIZE; i++) @@ -1420,16 +1422,8 @@ lang_printable_name (decl) if (print_ring[ring_counter]) free (print_ring[ring_counter]); - { - int print_ret_type_p - = (!DECL_CONSTRUCTOR_P (decl) - && !DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl))); - - char *name = (char *)decl_as_string (decl, print_ret_type_p); - print_ring[ring_counter] = (char *)malloc (strlen (name) + 1); - strcpy (print_ring[ring_counter], name); - decl_ring[ring_counter] = decl; - } + print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v)); + decl_ring[ring_counter] = decl; return print_ring[ring_counter]; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 23630983e3d..10fbdef9a0d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5787,8 +5787,11 @@ build_modify_expr (lhs, modifycode, rhs) { tree inner_lhs = TREE_OPERAND (lhs, 0); tree result; - if (! lvalue_p (lhs) && pedantic) - pedwarn ("cast to non-reference type used as lvalue"); + + /* WP 5.4.1: The result is an lvalue if T is a reference type, + otherwise the result is an rvalue. */ + if (! lvalue_p (lhs)) + pedwarn ("ANSI C++ forbids cast to non-reference type used as lvalue"); result = build_modify_expr (inner_lhs, NOP_EXPR, convert (TREE_TYPE (inner_lhs),