[2/4] PR c++/13403 and PR c++/15154: Fix gnuv3_pass_by_reference to lookup copy c-tors with qualified args

Message ID CAGyQ6gxdno4x2dxQ==-d3A4UxRGJjE18y-xPAdLWqxA06cgQhw@mail.gmail.com
State New, archived
Headers

Commit Message

Siva Chandra Reddy Sept. 29, 2014, 9:11 p.m. UTC
  On Sun, Sep 28, 2014 at 11:01 PM, Doug Evans <dje@google.com> wrote:
>> 2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>
>>
>>         PR c++/13403
>>         PR c++/15154
>>         * gdbtypes.c (make_qualified_type): Make non-static.
>>         * gdbtypes.h (make_qualified_type): Declare.
>>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy
>>         constructors with qualified args

> Can you use class_types_same_p here (instead of comparing with the
> result of make_qualified_type) ?

Yes, I made this change now. The patch is attached.

I am assuming that the other patches in this series are approved
modulo making the test regexes more specific.

 gdb/ChangeLog:

2014-09-29  Siva Chandra Reddy  <sivachandra@google.com>

        PR c++/13403
        PR c++/15154
        * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy constructors
        with qualified args.
  

Comments

Siva Chandra Reddy Oct. 6, 2014, 9:20 p.m. UTC | #1
On Mon, Sep 29, 2014 at 2:11 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Sun, Sep 28, 2014 at 11:01 PM, Doug Evans <dje@google.com> wrote:
>>> 2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>
>>>
>>>         PR c++/13403
>>>         PR c++/15154
>>>         * gdbtypes.c (make_qualified_type): Make non-static.
>>>         * gdbtypes.h (make_qualified_type): Declare.
>>>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy
>>>         constructors with qualified args
>
>> Can you use class_types_same_p here (instead of comparing with the
>> result of make_qualified_type) ?
>
> Yes, I made this change now. The patch is attached.
>
> I am assuming that the other patches in this series are approved
> modulo making the test regexes more specific.
>
>  gdb/ChangeLog:
>
> 2014-09-29  Siva Chandra Reddy  <sivachandra@google.com>
>
>         PR c++/13403
>         PR c++/15154
>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy constructors
>         with qualified args.

Ping.
  
Siva Chandra Reddy Oct. 14, 2014, 2:12 p.m. UTC | #2
On Mon, Sep 29, 2014 at 2:11 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Sun, Sep 28, 2014 at 11:01 PM, Doug Evans <dje@google.com> wrote:
>>>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy
>>>         constructors with qualified args
>
>> Can you use class_types_same_p here (instead of comparing with the
>> result of make_qualified_type) ?
>
> Yes, I made this change now. The patch is attached.
>
> I am assuming that the other patches in this series are approved
> modulo making the test regexes more specific.
>
>  gdb/ChangeLog:
>
> 2014-09-29  Siva Chandra Reddy  <sivachandra@google.com>
>
>         PR c++/13403
>         PR c++/15154
>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy constructors
>         with qualified args.

Ping. Link: https://sourceware.org/ml/gdb-patches/2014-09/msg00854.html
  
Doug Evans Oct. 14, 2014, 9:03 p.m. UTC | #3
Siva Chandra writes:
 > On Sun, Sep 28, 2014 at 11:01 PM, Doug Evans <dje@google.com> wrote:
 > >> 2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>
 > >>
 > >>         PR c++/13403
 > >>         PR c++/15154
 > >>         * gdbtypes.c (make_qualified_type): Make non-static.
 > >>         * gdbtypes.h (make_qualified_type): Declare.
 > >>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy
 > >>         constructors with qualified args
 > 
 > > Can you use class_types_same_p here (instead of comparing with the
 > > result of make_qualified_type) ?
 > 
 > Yes, I made this change now. The patch is attached.
 > 
 > I am assuming that the other patches in this series are approved
 > modulo making the test regexes more specific.
 > 
 >  gdb/ChangeLog:
 > 
 > 2014-09-29  Siva Chandra Reddy  <sivachandra@google.com>
 > 
 >         PR c++/13403
 >         PR c++/15154
 >         * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy constructors
 >         with qualified args.

LGTM.

And yeah, the rest of the patch set is approved.
[Modulo the potential addition of a comment in 4/4.]
  

Patch

diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index d5ed355..043c30f 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1313,11 +1313,17 @@  gnuv3_pass_by_reference (struct type *type)
 
 	/* If this method takes two arguments, and the second argument is
 	   a reference to this class, then it is a copy constructor.  */
-	if (TYPE_NFIELDS (fieldtype) == 2
-	    && TYPE_CODE (TYPE_FIELD_TYPE (fieldtype, 1)) == TYPE_CODE_REF
-	    && check_typedef (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (fieldtype,
-								 1))) == type)
-	  return 1;
+	if (TYPE_NFIELDS (fieldtype) == 2)
+	  {
+	    struct type *arg_type = TYPE_FIELD_TYPE (fieldtype, 1);
+	    struct type *arg_target_type;
+
+	    arg_target_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
+
+	    if (TYPE_CODE (arg_type) == TYPE_CODE_REF
+		&& class_types_same_p (arg_target_type, type))
+	      return 1;
+	  }
       }
 
   /* Even if all the constructors and destructors were artificial, one