typeck.c (build_unary_op): Deal with const qualifier in invalid pointer-to-member...
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Tue, 6 May 2003 14:02:09 +0000 (14:02 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Tue, 6 May 2003 14:02:09 +0000 (14:02 +0000)
* typeck.c (build_unary_op): Deal with const qualifier in
invalid pointer-to-member earlier.

From-SVN: r66522

gcc/cp/ChangeLog
gcc/cp/typeck.c

index 40a4de12532cc621da65a739ac7dab4c4cd46adb..15ca7a65013310171693e48cfd7fd3beeea49b39 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       * typeck.c (build_unary_op): Deal with const qualifier in
+       invalid pointer-to-member earlier.
+
 2003-05-05  Jason Merrill  <jason@redhat.com>
 
        PR c++/9537
index 35073dc3a7cfeb6aecb931232169d0376d1e98a1..20e602a883e4fd70ee212fa38f00ed3fd2e0907b 100644 (file)
@@ -4430,26 +4430,27 @@ build_unary_op (code, xarg, noconvert)
             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));
+         /* Inside constant member functions, the `this' pointer
+            contains an extra const qualifier.  TYPE_MAIN_VARIANT
+            is used here to remove this const from the diagnostics
+            and the created OFFSET_REF.  */
+         tree base = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg, 0)));
          tree name = DECL_NAME (get_first_fn (TREE_OPERAND (arg, 1)));
 
          if (! flag_ms_extensions)
            {
-             /* Inside constant member functions, the `this' pointer
-                contains an extra const qualifier.  TYPE_MAIN_VARIANT
-                is used here to remove this const from the diagnostics.  */
              if (current_class_type
                  && TREE_OPERAND (arg, 0) == current_class_ref)
                /* An expression like &memfn.  */
                pedwarn ("ISO C++ forbids taking the address of an unqualified"
                         " or parenthesized non-static member function to form"
                         " a pointer to member function.  Say `&%T::%D'",
-                        TYPE_MAIN_VARIANT (base), name);
+                        base, name);
              else
                pedwarn ("ISO C++ forbids taking the address of a bound member"
                         " function to form a pointer to member function."
                         "  Say `&%T::%D'",
-                        TYPE_MAIN_VARIANT (base), name);
+                        base, name);
            }
          arg = build_offset_ref (base, name);
         }