[Patch,C++] P232519

Fabien Chêne fabien.chene@gmail.com
Wed Jun 25 23:07:00 GMT 2008


Hi!

I'm trying to fix PR32519.

The macro DECL_NONSTATIC_MEMBER_P in cp-tree.h does not return true
for template member functions. I have just removed the test 
TREE_CODE (NODE) == FUNCTION_DECL, because for template member
functions, TREE_CODE( NODE ) == TEMPLATE_DECL.

This macro is used three times:

$ grep -C4 DECL_NONSTATIC_MEMBER_P *.[ch]
cp-tree.h-   && CP_TYPE_VOLATILE_P (TREE_TYPE (TREE_VALUE                                \
cp-tree.h-                                (TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
cp-tree.h-
cp-tree.h-/* Nonzero for a DECL means that this member is a non-static member.  */
cp-tree.h:#define DECL_NONSTATIC_MEMBER_P(NODE)         \
cp-tree.h-  (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE)    \
cp-tree.h-   || TREE_CODE (NODE) == FIELD_DECL)
cp-tree.h-
cp-tree.h-/* Nonzero for _DECL means that this member object type
--
init.c-        If the access is to form a pointer to member, the
init.c-        nested-name-specifier shall name the derived class
init.c-        (or any class derived from that class).  */
init.c-   if (address_p && DECL_P (t)
init.c:       && DECL_NONSTATIC_MEMBER_P (t))
init.c-     perform_or_defer_access_check (TYPE_BINFO (type), t, t);
init.c-   else
init.c-     perform_or_defer_access_check (basebinfo, t, t);
init.c-
--
search.c-     reference to, or object of the derived class itself (or any class
search.c-     derived from that class) (_expr.ref_).  If the access is to form
search.c-     a pointer to member, the nested-name-specifier shall name the
search.c-     derived class (or any class derived from that class).  */
search.c:  if (DECL_NONSTATIC_MEMBER_P (decl))
search.c-    {
search.c-      /* We can tell through what the reference is occurring by
search.c-        chasing BINFO up to the root.  */
search.c-      tree t = binfo;
--
semantics.c-    {
semantics.c-      /* If the reference is to a non-static member of the
semantics.c-     current class, treat it as if it were referenced through
semantics.c-     `this'.  */
semantics.c:      if (DECL_NONSTATIC_MEMBER_P (decl)
semantics.c-      && current_class_ptr
semantics.c-      && DERIVED_FROM_P (scope, current_class_type))
semantics.c-    qualifying_type = current_class_type;
semantics.c-      /* Otherwise, use the type indicated by the

It fixes search.c, but I cannot say if it fixes/breaks semantics.c and
init.c -- however, it shows no regressions. Tested x86_64-pc-linux-gnu, is it
OK or do you prefer not affecting semantics.c and init.c ?

As it is my first patch, thanks for your carefull review.
(I am wainting for my copyright assignment, but this patch is very small.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr35219.patch
Type: text/x-patch
Size: 1844 bytes
Desc: patch for PR32519
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080625/d7fc3401/attachment.bin>
-------------- next part --------------

--
Fab


More information about the Gcc-patches mailing list