From patchwork Tue Nov 27 18:31:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Basierski X-Patchwork-Id: 30324 Received: (qmail 13247 invoked by alias); 27 Nov 2018 19:40:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 13147 invoked by uid 89); 27 Nov 2018 19:40:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_FAIL autolearn=ham version=3.3.2 spammy=4000, 987, prop, 983 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Nov 2018 19:40:08 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2018 11:40:06 -0800 Received: from ubuntu.imu.intel.com ([10.217.246.11]) by FMSMGA003.fm.intel.com with ESMTP; 27 Nov 2018 11:40:06 -0800 From: Sebastian Basierski To: gdb-patches@sourceware.org Subject: [PATCH 02/11] Fortran: Fix negative bounds for dynamic allocated arrays. Date: Tue, 27 Nov 2018 19:31:30 +0100 Message-Id: <20181127183139.71170-3-sbasierski@pl.sii.eu> In-Reply-To: <20181127183139.71170-1-sbasierski@pl.sii.eu> References: <20181127183139.71170-1-sbasierski@pl.sii.eu> From: Bernhard Heckel Fortran arrays might have negative bounds. Take this into consideration when evaluating dynamic bound properties. Bernhard Heckel gdb/Changelog: * gdbtypes.c (resolve_dynamic_range): Call dwarf2_evaluate_property_signed to resolve dynamic bounds. gdb/Testsuite/Changelog: * gdb.fortran/vla.f90: Extend by an array with negative bounds. * gdb/testsuite/gdb.fortran/vla-sizeof.exp: Test array with negative bounds. * gdb/testsuite/gdb.fortran/vla-ptype.exp: Test array with negative bounds. --- gdb/gdbtypes.c | 4 ++-- gdb/testsuite/gdb.fortran/vla-ptype.exp | 4 ++++ gdb/testsuite/gdb.fortran/vla-sizeof.exp | 4 ++++ gdb/testsuite/gdb.fortran/vla.f90 | 10 ++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9e87b8f4c5..8adf899f9a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1995,7 +1995,7 @@ resolve_dynamic_range (struct type *dyn_range_type, gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE); prop = &TYPE_RANGE_DATA (dyn_range_type)->low; - if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) + if (dwarf2_evaluate_property_signed (prop, NULL, addr_stack, &value, 1)) { low_bound.kind = PROP_CONST; low_bound.data.const_val = value; @@ -2007,7 +2007,7 @@ resolve_dynamic_range (struct type *dyn_range_type, } prop = &TYPE_RANGE_DATA (dyn_range_type)->high; - if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) + if (dwarf2_evaluate_property_signed (prop, NULL, addr_stack, &value, 1)) { high_bound.kind = PROP_CONST; high_bound.data.const_val = value; diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp index 5f367348b0..5351a0aa2e 100644 --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp @@ -98,3 +98,7 @@ gdb_test "ptype vla2" "type = " "ptype vla2 not allocated" gdb_test "ptype vla2(5, 45, 20)" \ "no such vector element \\\(vector not allocated\\\)" \ "ptype vla2(5, 45, 20) not allocated" + +gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds"] +gdb_continue_to_breakpoint "vla1-neg-bounds" +gdb_test "ptype vla1" "type = $real \\(-2:1,-5:4,-3:-1\\)" "ptype vla1 negative bounds" diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp index 3113983ba4..83bc849619 100644 --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp @@ -44,3 +44,7 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla" gdb_breakpoint [gdb_get_line_number "pvla-associated"] gdb_continue_to_breakpoint "pvla-associated" gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla" + +gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds"] +gdb_continue_to_breakpoint "vla1-neg-bounds" +gdb_test "print sizeof(vla1)" " = 480" "print sizeof vla1 negative bounds" diff --git a/gdb/testsuite/gdb.fortran/vla.f90 b/gdb/testsuite/gdb.fortran/vla.f90 index 508290a36e..d87f59b92b 100644 --- a/gdb/testsuite/gdb.fortran/vla.f90 +++ b/gdb/testsuite/gdb.fortran/vla.f90 @@ -54,4 +54,14 @@ program vla allocate (vla3 (2,2)) ! vla2-deallocated vla3(:,:) = 13 + + allocate (vla1 (-2:1, -5:4, -3:-1)) + l = allocated(vla1) + + vla1(:, :, :) = 1 + vla1(-2, -3, -1) = -231 + + deallocate (vla1) ! vla1-neg-bounds + l = allocated(vla1) + end program vla