PR exp/15364:
authorTom Tromey <tromey@redhat.com>
Mon, 13 May 2013 16:51:52 +0000 (16:51 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 13 May 2013 16:51:52 +0000 (16:51 +0000)
* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT,
STRUCTOP_PTR>: Return a not_lval value for
EVAL_AVOID_SIDE_EFFECTS.
* opencl-lang.c (evaluate_subexp_opencl): Return a not_lval value
for EVAL_AVOID_SIDE_EFFECTS.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add regression test.
* gdb.base/exprs.c (null_t_struct): New global.

gdb/ChangeLog
gdb/eval.c
gdb/opencl-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/exprs.c
gdb/testsuite/gdb.base/exprs.exp

index e3c2c4be846c4144298c030f6f6f1d753aae9a1c..deefda944f7e16dd4f11a11ab5940fbcc596ca42 100644 (file)
@@ -1,3 +1,12 @@
+2013-05-13  Tom Tromey  <tromey@redhat.com>
+
+       PR exp/15364:
+       * eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT,
+       STRUCTOP_PTR>: Return a not_lval value for
+       EVAL_AVOID_SIDE_EFFECTS.
+       * opencl-lang.c (evaluate_subexp_opencl): Return a not_lval value
+       for EVAL_AVOID_SIDE_EFFECTS.
+
 2013-05-13  Joel Brobecker  <brobecker@adacore.com>
 
        * rs6000-aix-tdep.c (rs6000_push_dummy_call): Convert
index f04baeee8e426577368e7169a8509a51fc5a7b9c..cf1fda96b6fd0cc79b70fe54b20b769f141f2d7b 100644 (file)
@@ -1847,9 +1847,11 @@ evaluate_subexp_standard (struct type *expect_type,
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
        goto nosideret;
-      /* Also handle EVAL_AVOID_SIDE_EFFECTS.  */
-      return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+      arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
                               NULL, "structure");
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+       arg3 = value_zero (value_type (arg3), not_lval);
+      return arg3;
 
     case STRUCTOP_PTR:
       tem = longest_to_int (exp->elts[pc + 1].longconst);
@@ -1899,9 +1901,11 @@ evaluate_subexp_standard (struct type *expect_type,
           }
       }
 
-      /* Also handle EVAL_AVOID_SIDE_EFFECTS.  */
-      return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+      arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
                               NULL, "structure pointer");
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+       arg3 = value_zero (value_type (arg3), not_lval);
+      return arg3;
 
     case STRUCTOP_MEMBER:
     case STRUCTOP_MPTR:
index d7e66c465856f167c14f2591d9ad5c2887dd5160..4720e2b194409934797a44cc6e69bfb5bc8ac4d5 100644 (file)
@@ -1035,10 +1035,13 @@ Cannot perform conditional operation on vectors with different sizes"));
          }
        else
          {
-           /* Also handle EVAL_AVOID_SIDE_EFFECTS.  */
-           return value_struct_elt (&arg1, NULL,
-                                    &exp->elts[pc + 2].string, NULL,
-                                    "structure");
+           struct value *v = value_struct_elt (&arg1, NULL,
+                                               &exp->elts[pc + 2].string, NULL,
+                                               "structure");
+
+           if (noside == EVAL_AVOID_SIDE_EFFECTS)
+             v = value_zero (value_type (v), not_lval);
+           return v;
          }
       }
     default:
index c4a62377100543a35c1a4dae83fce3d795611b0f..fc74fbb6d5e6cc9c281c15813209bf7212836153 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-13  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.base/exprs.exp (test_expr): Add regression test.
+       * gdb.base/exprs.c (null_t_struct): New global.
+
 2013-05-13  Muhammad Bilal  <mbilal@codesourcery.com>
 
        * gdb.base/default.exp: Disable history saving.
index 90c0f25ead84d28eef14123c8f2d30b4c97e958d..e1ad18284224e382909307f46a5df2f7265adde4 100644 (file)
@@ -185,6 +185,7 @@ union tu_link {
 enum colors {red, green, blue} color;
 enum cars {chevy, ford, porsche} clunker;
 
+struct t_struct *null_t_struct;
 
 void dummy()
 {
index fa3cdb449578313f7822e0e61980bfa2318226de..d2e23c9231961bc73337a625149a4cab3019ab16 100644 (file)
@@ -273,3 +273,7 @@ gdb_test "print {short} v_short_array" "$decimal = 42"
 # Regression tests for cast to void.
 gdb_test "print (void) v_int_pointer" " = void"
 gdb_test "print & (void) v_char" "value not located in memory."
+
+# Regression test for "&&".
+gdb_test "print null_t_struct && null_t_struct->v_int_member == 0" \
+    " = 0"
This page took 0.048514 seconds and 4 git commands to generate.