Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Guard a call to TYPE_TARGET_TYPE in gnuv3_pass_by_reference
@ 2014-10-16 14:38 Siva Chandra
  2014-10-16 18:01 ` Pedro Alves
  2014-10-16 19:01 ` Siva Chandra
  0 siblings, 2 replies; 11+ messages in thread
From: Siva Chandra @ 2014-10-16 14:38 UTC (permalink / raw)
  To: Doug Evans, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

A call to TYPE_TARGET_TYPE was being done without checking if the type
does have a target type. This was introduced by my commit:
82c48ac732edb0155288a93ef3dd39625ff2d2e1

The attached patch fixes it. This probably qualifies as an obvious
fix, but just in case.

 2014-10-16  Siva Chandra Reddy  <sivachandra@google.com>

        * gnu-v3-abi.c (gnuv3_pass_by_reference): Call TYPE_TARGET_TYPE
        on the arg type of a constructor only if it is of reference type.

[-- Attachment #2: gnuv3_pass_by_reference_v1.txt --]
[-- Type: text/plain, Size: 781 bytes --]

diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index a6c6f9f..b960aa3 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1320,13 +1320,15 @@ gnuv3_pass_by_reference (struct type *type)
 	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)
+	      {
+		struct type *arg_target_type;
 
-	    if (TYPE_CODE (arg_type) == TYPE_CODE_REF
-		&& class_types_same_p (arg_target_type, type))
-	      return 1;
+	        arg_target_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
+		if (class_types_same_p (arg_target_type, type))
+		  return 1;
+	      }
 	  }
       }
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-10-24 12:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-16 14:38 [PATCH] Guard a call to TYPE_TARGET_TYPE in gnuv3_pass_by_reference Siva Chandra
2014-10-16 18:01 ` Pedro Alves
2014-10-16 18:10   ` Siva Chandra
2014-10-16 18:16     ` Sergio Durigan Junior
2014-10-16 18:18       ` Siva Chandra
2014-10-16 18:28         ` Sergio Durigan Junior
2014-10-16 19:01 ` Siva Chandra
2014-10-16 20:42   ` Pedro Alves
2014-10-23 19:09   ` Siva Chandra
2014-10-24  5:31     ` Doug Evans
2014-10-24 12:56       ` Siva Chandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox