class.c (resolve_address_of_overloaded_function): Add explanation message.
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 6 Sep 2000 08:53:45 +0000 (08:53 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 6 Sep 2000 08:53:45 +0000 (08:53 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/friend.c

index d0a4851..744511a 100644 (file)
@@ -1,3 +1,12 @@
+2000-09-06  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * 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  <zack@wolery.cumb.org>
 
        * tree.c (walk_tree): Expose tail recursion.
index d4c2ad2..de692db 100644 (file)
@@ -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);
 
index 63c2ea8..8537981 100644 (file)
@@ -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;
        }
     }
index 7fbd80c..085e352 100644 (file)
@@ -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);
index 1a4df14..950169a 100644 (file)
@@ -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;
                }
            }