]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Guard a call to TYPE_TARGET_TYPE in gnuv3_pass_by_reference.
authorSiva Chandra <sivachandra@chromium.org>
Thu, 16 Oct 2014 14:14:13 +0000 (07:14 -0700)
committerSiva Chandra <sivachandra@chromium.org>
Fri, 24 Oct 2014 12:45:06 +0000 (05:45 -0700)
gdb/ChangeLog:

* 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.

gdb/testsuite/ChangeLog:

* gdb.cp/non-trivial-retval.cc: Add a test case.
* gdb.cp/non-trivial-retval.exp: Add a test.

gdb/ChangeLog
gdb/gnu-v3-abi.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/non-trivial-retval.cc
gdb/testsuite/gdb.cp/non-trivial-retval.exp

index 370a7ad66c984acf4a60f982802e3264ac02d8f5..c366ab770e9edeb9a2ec290e24cf31b27a8309ca 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-24  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.
+
 2014-10-23  Sandra Loosemore  <sandra@codesourcery.com>
 
        * nios2-tdep.c (nios2_analyze_prologue): Use new instruction field
index a6c6f9fd9c8308b83d88964fadc3ca31b7e84854..b960aa38bffdbfc36f0374e5faa934b613e8ebda 100644 (file)
@@ -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;
+             }
          }
       }
 
index 3b7bb46e531b8bdd4ae40c5acd4f62edfd2801ae..b6e3505297fce3b059edaa4ef0eb3eee5ec462b5 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-24  Siva Chandra Reddy  <sivachandra@google.com>
+
+       * gdb.cp/non-trivial-retval.cc: Add a test case.
+       * gdb.cp/non-trivial-retval.exp: Add a test.
+
 2014-10-20  Yao Qi  <yao@codesourcery.com>
 
        * gdb.python/py-objfile-script-gdb.py.in: Rename it to ...
index 8382f40d0a22198fbdd1149c233f0a35c71573f5..fd1b695046d44988acec44aa860dd4e543afda79 100644 (file)
@@ -63,6 +63,39 @@ f2 (int i1, int i2)
   return b;
 }
 
+class B1
+{
+public:
+  B1 () {}
+  /* This class exists to test that GDB does not trip on other
+     constructors (not copy constructors) which take one
+     argument.  Hence, put this decl before the copy-ctor decl.
+     If it is put after copy-ctor decl, then the decision to mark
+     this class as non-trivial will already be made and GDB will
+     not look at this constructor.  */
+  B1 (int i);
+  B1 (const B1 &obj);
+
+  int b1;
+};
+
+B1::B1 (const B1 &obj)
+{
+  b1 = obj.b1;
+}
+
+B1::B1 (int i) : b1 (i) { }
+
+B1
+f22 (int i1, int i2)
+{
+  B1 b1;
+
+  b1.b1 = i1 + i2;
+
+  return b1;
+}
+
 class C
 {
 public:
index 793494685473832883c26a3259862cd0312ce9b5..3450a94e25ee7d019a0606e19cdfdd8e3b9cb7ec 100644 (file)
@@ -32,5 +32,6 @@ gdb_continue_to_breakpoint "Break here"
 
 gdb_test "p f1 (i1, i2)" ".* = {a = 123}" "p f1 (i1, i2)"
 gdb_test "p f2 (i1, i2)" ".* = {b = 123}" "p f2 (i1, i2)"
+gdb_test "p f22 (i1, i2)" ".* = {b1 = 123}" "p f22 (i1, i2)"
 gdb_test "p f3 (i1, i2)" ".* = {.* c = 123}" "p f3 (i1, i2)"
 gdb_test "p f4 (i1, i2)" ".* = {.* e = 123}" "p f4 (i1, i2)"