From: Nathan Sidwell Date: Wed, 6 Sep 2000 08:53:45 +0000 (+0000) Subject: class.c (resolve_address_of_overloaded_function): Add explanation message. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1ce3eb24a65ac83f1ed5dddaf9e1f04afafd41f;p=platform%2Fupstream%2Fgcc.git class.c (resolve_address_of_overloaded_function): Add explanation message. * class.c (resolve_address_of_overloaded_function): Add explanation message. * decl.c (define_case_label): Reformat explanation. * decl2.c (finish_static_data_member_decl): Likewise. (grokfield): Likewise. * friend.c (do_friend): Likewise. From-SVN: r36188 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d0a4851..744511a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2000-09-06 Nathan Sidwell + + * class.c (resolve_address_of_overloaded_function): Add + explanation message. + * decl.c (define_case_label): Reformat explanation. + * decl2.c (finish_static_data_member_decl): Likewise. + (grokfield): Likewise. + * friend.c (do_friend): Likewise. + 2000-09-05 Zack Weinberg * tree.c (walk_tree): Expose tail recursion. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d4c2ad2..de692db 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5965,13 +5965,20 @@ resolve_address_of_overloaded_function (target_type, /* Good, exactly one match. Now, convert it to the correct type. */ fn = TREE_PURPOSE (matches); - if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) && !ptrmem && !flag_ms_extensions) { + static int explained; + if (!complain) return error_mark_node; cp_pedwarn ("assuming pointer to member `%D'", fn); + if (!explained) + { + cp_pedwarn ("(a pointer to member can only be formed with `&%E')", fn); + explained = 1; + } } mark_used (fn); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 63c2ea8..8537981 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5227,8 +5227,7 @@ define_case_label () warning ("where case label appears here"); if (!explained) { - warning ("(enclose actions of previous case statements requiring"); - warning ("destructors in their own binding contours.)"); + warning ("(enclose actions of previous case statements requiring destructors in their own scope.)"); explained = 1; } } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 7fbd80c..085e352 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1597,12 +1597,15 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags) /* Static consts need not be initialized in the class definition. */ if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))) { - static int explanation = 0; + static int explained = 0; error ("initializer invalid for static member with constructor"); - if (explanation++ == 0) - error ("(you really want to initialize it separately)"); - init = 0; + if (!explained) + { + error ("(an out of class initialization is required)"); + explained = 1; + } + init = NULL_TREE; } /* Force the compiler to know when an uninitialized static const member is being used. */ @@ -1656,13 +1659,13 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist) }; Explain that to the user. */ - static int explained_p; + static int explained; cp_error ("invalid data member initiailization"); - if (!explained_p) + if (!explained) { - cp_error ("use `=' to initialize static data members"); - explained_p = 1; + cp_error ("(use `=' to initialize static data members)"); + explained = 1; } declarator = TREE_OPERAND (declarator, 0); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 1a4df14..950169a 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -399,11 +399,10 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist, && current_template_parms && uses_template_parms (decl)) { static int explained; - cp_warning ("friend declaration `%#D'", decl); - warning (" declares a non-template function"); + cp_warning ("friend declaration `%#D' declares a non-template function", decl); if (! explained) { - warning (" (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) -Wno-non-template-friend disables this warning."); + warning ("(if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) -Wno-non-template-friend disables this warning."); explained = 1; } }