PR c++/9197:
authorTom Tromey <tromey@redhat.com>
Mon, 25 Mar 2013 17:26:18 +0000 (17:26 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 25 Mar 2013 17:26:18 +0000 (17:26 +0000)
* opencl-lang.c (evaluate_subexp_opencl) <STRUCTOP_STRUCT>: Use
value_struct_elt, not lookup_struct_elt_type.
* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT,
STRUCTOP_PTR>: Use value_struct_elt, not lookup_struct_elt_type.
* expression.h (EVAL_AVOID_SIDE_EFFECTS): Update comment.
gdb/testsuite
* gdb.cp/m-static.exp: Add constructor ptype tests.
* gdb.cp/m-static.cc (single_constructor): New class.
(main): Make instance of single_constructor.

gdb/ChangeLog
gdb/eval.c
gdb/expression.h
gdb/opencl-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/m-static.cc
gdb/testsuite/gdb.cp/m-static.exp

index e065e94569b2dbff22a80c7bad4354d94b61086c..4639417eedee29d4c20e8c1b6b54679839d14f5f 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-25  Tom Tromey  <tromey@redhat.com>
+
+       PR c++/9197:
+       * opencl-lang.c (evaluate_subexp_opencl) <STRUCTOP_STRUCT>: Use
+       value_struct_elt, not lookup_struct_elt_type.
+       * eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT,
+       STRUCTOP_PTR>: Use value_struct_elt, not lookup_struct_elt_type.
+       * expression.h (EVAL_AVOID_SIDE_EFFECTS): Update comment.
+
 2013-03-25  Yao Qi  <yao@codesourcery.com>
 
        * ctf.c [USE_WIN32API]: Undef 'mkdir' and use 'mkdir'
index 146840e7843d61a8bf7d3fe2f4ccc38f436eb6ff..a91ba2271abd589541a6d5910ff4dfe73ace7d86 100644 (file)
@@ -1847,18 +1847,9 @@ evaluate_subexp_standard (struct type *expect_type,
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
        goto nosideret;
-      if (noside == EVAL_AVOID_SIDE_EFFECTS)
-       return value_zero (lookup_struct_elt_type (value_type (arg1),
-                                                  &exp->elts[pc + 2].string,
-                                                  0),
-                          lval_memory);
-      else
-       {
-         struct value *temp = arg1;
-
-         return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
-                                  NULL, "structure");
-       }
+      /* Also handle EVAL_AVOID_SIDE_EFFECTS.  */
+      return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+                              NULL, "structure");
 
     case STRUCTOP_PTR:
       tem = longest_to_int (exp->elts[pc + 1].longconst);
@@ -1908,18 +1899,9 @@ evaluate_subexp_standard (struct type *expect_type,
           }
       }
 
-      if (noside == EVAL_AVOID_SIDE_EFFECTS)
-       return value_zero (lookup_struct_elt_type (value_type (arg1),
-                                                  &exp->elts[pc + 2].string,
-                                                  0),
-                          lval_memory);
-      else
-       {
-         struct value *temp = arg1;
-
-         return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
-                                  NULL, "structure pointer");
-       }
+      /* Also handle EVAL_AVOID_SIDE_EFFECTS.  */
+      return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+                              NULL, "structure pointer");
 
     case STRUCTOP_MEMBER:
     case STRUCTOP_MPTR:
index 6b96b12a78386dae2d0836a0537d57aa83f8fa74..9252dd25ef9b738a2fe7ed6130b2f8a3cc8b80b8 100644 (file)
@@ -128,7 +128,10 @@ enum noside
                                   type (inaccuracy: anything that is
                                   listed as being in a register in
                                   the function in which it was
-                                  declared will be lval_register).  */
+                                  declared will be lval_register).
+                                  Ideally this would not even read
+                                  target memory, but currently it
+                                  does in many situations.  */
   };
 
 extern struct value *evaluate_subexp_standard
index 819a83202aa83aef1596a795162c4d13cd9f02f3..d7e66c465856f167c14f2591d9ad5c2887dd5160 100644 (file)
@@ -1035,15 +1035,10 @@ Cannot perform conditional operation on vectors with different sizes"));
          }
        else
          {
-           if (noside == EVAL_AVOID_SIDE_EFFECTS)
-             return
-                 value_zero (lookup_struct_elt_type
-                             (value_type (arg1),&exp->elts[pc + 2].string, 0),
-                             lval_memory);
-           else
-             return value_struct_elt (&arg1, NULL,
-                                      &exp->elts[pc + 2].string, NULL,
-                                      "structure");
+           /* Also handle EVAL_AVOID_SIDE_EFFECTS.  */
+           return value_struct_elt (&arg1, NULL,
+                                    &exp->elts[pc + 2].string, NULL,
+                                    "structure");
          }
       }
     default:
index beadddb26be9baf5a74a24e06708a4b19cf5a605..6e8a0f4cd2e6379ec07b6b4f7186cd49086fa75b 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-25  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.cp/m-static.exp: Add constructor ptype tests.
+       * gdb.cp/m-static.cc (single_constructor): New class.
+       (main): Make instance of single_constructor.
+
 2013-03-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
            Pedro Alves  <palves@redhat.com>
 
index eadbdfc44ba824f03ee2da609a3346699fc84b4f..cb871e8d18eef69de8d900fe38ab654b27c8a9c5 100644 (file)
@@ -31,6 +31,14 @@ public:
   }
 };
 
+// An object with a single constructor.
+class single_constructor
+{
+public:
+  single_constructor () { }
+  ~single_constructor () { }
+};
+
 const bool gnu_obj_1::test;
 const int gnu_obj_1::key1;
 long gnu_obj_1::key2 = 77;
@@ -81,6 +89,7 @@ int main()
   gnu_obj_2<long>      test2(roman);
   gnu_obj_3<long>      test3(greek);
   gnu_obj_4            test4;
+  single_constructor   test5;
 
   test4.dummy = test4.elsewhere;
   test4.dummy = 0;
index 5d1cb8b1aa20427aa69709e2601e58ae5885853f..b31922aae75506b8b559d9b61252930994ebc874 100644 (file)
@@ -69,6 +69,16 @@ gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
 # simple object, static enum
 gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
 
+gdb_test "print test5.single_constructor" \
+    { = {void \(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
+    "simple object instance, print constructor"
+gdb_test "ptype test5.single_constructor" \
+    {type = void \(single_constructor \* const\)} \
+    "simple object instance, ptype constructor"
+gdb_test "ptype single_constructor::single_constructor" \
+    {type = void \(single_constructor \* const\)} \
+    "simple object class, ptype constructor"
+
 gdb_test "print test1.'~gnu_obj_1'" \
     { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
     "simple object instance, print quoted destructor"