]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix pointer decay in compile print.
authorPhil Muldoon <pmuldoon@redhat.com>
Fri, 20 Jan 2017 15:34:28 +0000 (15:34 +0000)
committerPhil Muldoon <pmuldoon@redhat.com>
Fri, 20 Jan 2017 15:34:28 +0000 (15:34 +0000)
Right now the assignment for an "auto" generated variable decays in
cases where auto is a pointer. This renders further operations on it,
like sizeof, or decltype inoperable. Revert back to using decltype
directly on the input over the "auto" variable. Also, fix up some
compile print cases in the testsuite that pass a ;. This will cause a
syntax error in decltype.

This commit also breaks string literals as they are declared as
lvalues.

gdb/compile/compile-c-support.c
gdb/testsuite/gdb.compile/cp-simple-inherit.exp
gdb/testsuite/gdb.compile/cp-simple-method.exp
gdb/testsuite/gdb.compile/cp-simple-ns.exp

index de2a67548afca0916d933e996c5969acad0bb1a1..3a3ed45d7e31a8a75c9db6ae5c85aba1304e4020 100644 (file)
@@ -490,13 +490,13 @@ struct cplus_add_input
        fprintf_unfiltered
          (buf,
           "auto " COMPILE_I_EXPR_VAL " = %s;\n"
-          "decltype (" COMPILE_I_EXPR_VAL ") *" COMPILE_I_EXPR_PTR_TYPE ";\n"
+          "decltype ( %s ) *" COMPILE_I_EXPR_PTR_TYPE ";\n"
           "std::memcpy (" COMPILE_I_PRINT_OUT_ARG ", %s ("
           COMPILE_I_EXPR_VAL "),\n"
-          "sizeof (" COMPILE_I_EXPR_VAL "));\n"
-          ,input,
+          "sizeof (decltype(%s)));\n"
+          ,input, input,
           (type == COMPILE_I_PRINT_ADDRESS_SCOPE
-           ? "std::__addressof" : ""));
+           ? "std::__addressof" : ""), input);
        break;
 
       default:
index 8293ccbe8539d6c56eb95bdc35e8512b40d7d499..f4561bc09dd1aac01d7e13cef33ec5da6d65c067 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2015, 2016 Free Software Foundation, Inc.
+# Copyright 2015, 2016, 2017 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -47,6 +47,6 @@ CompileExpression::test "d.a_" 1
 CompileExpression::test "d.b_" 2
 CompileExpression::test "d.c_" 3
 CompileExpression::test "d.d_" 4
-CompileExpression::test "d.A::do_it (1);" 2
-CompileExpression::test "d.B::do_it (1);" 1
-CompileExpression::test "d.C::do_it (1);" 3
+CompileExpression::test "d.A::do_it (1)" 2
+CompileExpression::test "d.B::do_it (1)" 1
+CompileExpression::test "d.C::do_it (1)" 3
index 9387c8fb9801e21481bfe0c612d810f9e64186b8..506dca605bd7b048801c147143c1752fa807ef79 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2015-2016 Free Software Foundation, Inc.
+# Copyright 2015-2017 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -43,20 +43,20 @@ gdb_breakpoint [gdb_get_line_number "break here" $srcfile]
 gdb_continue_to_breakpoint "testing location"
 
 CompileExpression::new "var"
-CompileExpression::test "a->get_var ();" 21
-CompileExpression::test "a->get_var (static_cast<unsigned long> (1));" 100
-CompileExpression::test "a->get_var (static_cast<int> (1));" 101
-CompileExpression::test "a->get_var (static_cast<float> (1));" 102
-CompileExpression::test "a->get_var (static_cast<void *> (a));" 103
-CompileExpression::test "a->get_var (*a);" 104
-CompileExpression::test "a->get_var (*ac);" 105
-CompileExpression::test "a->get_var1 (1);" 42
-CompileExpression::test "a->get_var2 (1, 2);" 88
-CompileExpression::test "A::get_1 (1);" 2
-CompileExpression::test "A::get_2 (1, 2);" 5
-CompileExpression::test "A::get_1 (a->get_var ());" 22
-CompileExpression::test "a->get_var1 (a->get_var () - 16);" 672
-CompileExpression::test "a->get_var2 (a->get_var (), A::get_1 (2));" 336
+CompileExpression::test "a->get_var ()" 21
+CompileExpression::test "a->get_var (static_cast<unsigned long> (1))" 100
+CompileExpression::test "a->get_var (static_cast<int> (1))" 101
+CompileExpression::test "a->get_var (static_cast<float> (1))" 102
+CompileExpression::test "a->get_var (static_cast<void *> (a))" 103
+CompileExpression::test "a->get_var (*a)" 104
+CompileExpression::test "a->get_var (*ac)" 105
+CompileExpression::test "a->get_var1 (1)" 42
+CompileExpression::test "a->get_var2 (1, 2)" 88
+CompileExpression::test "A::get_1 (1)" 2
+CompileExpression::test "A::get_2 (1, 2)" 5
+CompileExpression::test "A::get_1 (a->get_var ())" 22
+CompileExpression::test "a->get_var1 (a->get_var () - 16)" 672
+CompileExpression::test "a->get_var2 (a->get_var (), A::get_1 (2))" 336
 CompileExpression::test "get_value ()" 200
 CompileExpression::test "get_value (a)" 21
 CompileExpression::test "get_value (get_value ())" 200
index 0c5ff1d0e7f136f4c8dfd0ed3b876c11ed4f077f..216621bd1364e4ebebb29b988c6bac5deb340785 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2015, 2016 Free Software Foundation, Inc.
+# Copyright 2015, 2016, 2017 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -41,8 +41,8 @@ gdb_breakpoint [gdb_get_line_number "break here" $srcfile]
 gdb_continue_to_breakpoint "testing location"
 
 CompileExpression::new "var"
-CompileExpression::test "N1::N2::N3::N4::n4static;" 400
-CompileExpression::test "N1::N2::N3::N4::S4::s4static;" 40
-CompileExpression::test "s.s4int_;" 4
-CompileExpression::test "N1::N2::N3::N4::S4::get_svar ();" 40
-CompileExpression::test "s.get_var ();" 4
+CompileExpression::test "N1::N2::N3::N4::n4static" 400
+CompileExpression::test "N1::N2::N3::N4::S4::s4static" 40
+CompileExpression::test "s.s4int_" 4
+CompileExpression::test "N1::N2::N3::N4::S4::get_svar ()" 40
+CompileExpression::test "s.get_var ()" 4