From ac1ca910d74d5bd1d2800cb190659c9e3043a904 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 13 May 2013 16:51:52 +0000 Subject: [PATCH] PR exp/15364: * eval.c (evaluate_subexp_standard) : 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 | 9 +++++++++ gdb/eval.c | 12 ++++++++---- gdb/opencl-lang.c | 11 +++++++---- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/exprs.c | 1 + gdb/testsuite/gdb.base/exprs.exp | 4 ++++ 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e3c2c4be84..deefda944f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2013-05-13 Tom Tromey + + PR exp/15364: + * eval.c (evaluate_subexp_standard) : 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 * rs6000-aix-tdep.c (rs6000_push_dummy_call): Convert diff --git a/gdb/eval.c b/gdb/eval.c index f04baeee8e..cf1fda96b6 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -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: diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index d7e66c4658..4720e2b194 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -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: diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c4a6237710..fc74fbb6d5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-13 Tom Tromey + + * gdb.base/exprs.exp (test_expr): Add regression test. + * gdb.base/exprs.c (null_t_struct): New global. + 2013-05-13 Muhammad Bilal * gdb.base/default.exp: Disable history saving. diff --git a/gdb/testsuite/gdb.base/exprs.c b/gdb/testsuite/gdb.base/exprs.c index 90c0f25ead..e1ad182842 100644 --- a/gdb/testsuite/gdb.base/exprs.c +++ b/gdb/testsuite/gdb.base/exprs.c @@ -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() { diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp index fa3cdb4495..d2e23c9231 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -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" -- 2.34.1