From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59264 invoked by alias); 4 Jul 2016 09:52:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 59196 invoked by uid 89); 4 Jul 2016 09:52:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=type_code, adapt, sk:value_o, Adapt X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Jul 2016 09:52:47 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 04 Jul 2016 02:52:46 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 04 Jul 2016 02:52:45 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u649qhrh011742; Mon, 4 Jul 2016 10:52:44 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id u649qh9l021656; Mon, 4 Jul 2016 11:52:43 +0200 Received: (from heckel@localhost) by ulvlx001.iul.intel.com with œ id u649qhQP021652; Mon, 4 Jul 2016 11:52:43 +0200 From: Bernhard Heckel To: qiyaoltc@gmail.com, eliz@gnu.org Cc: gdb-patches@sourceware.org, Bernhard Heckel Subject: [PATCH V2 4/5] Fortran: Fix query of address of not-allocated types. Date: Mon, 04 Jul 2016 09:52:00 -0000 Message-Id: <1467625943-21294-5-git-send-email-bernhard.heckel@intel.com> In-Reply-To: <1467625943-21294-1-git-send-email-bernhard.heckel@intel.com> References: <1467625943-21294-1-git-send-email-bernhard.heckel@intel.com> X-IsSubscribed: yes X-SW-Source: 2016-07/txt/msg00035.txt.bz2 2016-06-30 Bernhard Heckel gdb/Changelog: * valops.c (address_of_variable): Throw error on not allocated types. gdb/Testsuite/Changelog: * gdb.fortran/pointers.exp: Dereference temp pointer to a not allocated array. * gdb.fortran/vla-value.exp: Adapt expected output. --- gdb/testsuite/gdb.fortran/pointers.exp | 2 ++ gdb/testsuite/gdb.fortran/vla-value.exp | 2 +- gdb/valops.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp index 310544c..df74743 100644 --- a/gdb/testsuite/gdb.fortran/pointers.exp +++ b/gdb/testsuite/gdb.fortran/pointers.exp @@ -62,6 +62,8 @@ gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" gdb_breakpoint [gdb_get_line_number "Before value assignment"] gdb_continue_to_breakpoint "Before value assignment" gdb_test "print *(twop)%ivla2" "= " +gdb_test "print *((integer*) &intvla)" "Attempt to take address of a not-allocated type." \ + "print temporary pointer, not allocated vla" gdb_breakpoint [gdb_get_line_number "After value assignment"] diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp index 24f2a9f..7cda0d7 100644 --- a/gdb/testsuite/gdb.fortran/vla-value.exp +++ b/gdb/testsuite/gdb.fortran/vla-value.exp @@ -30,7 +30,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"] gdb_continue_to_breakpoint "vla1-init" gdb_test "print vla1" " = " "print non-allocated vla1" gdb_test "print &vla1" \ - " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(:,:,:\\\)\\\)\\\) $hex" \ + "Attempt to take address of a not-allocated type." \ "print non-allocated &vla1" gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \ "print member in non-allocated vla1 (1)" diff --git a/gdb/valops.c b/gdb/valops.c index 5ef0c65..0d9b109 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1314,6 +1314,9 @@ address_of_variable (struct symbol *var, const struct block *b) val = value_of_variable (var, b); type = value_type (val); + if (type_not_allocated (type)) + error (_("Attempt to take address of a not-allocated type.")); + if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) || TYPE_CODE (type) == TYPE_CODE_FUNC) { -- 2.7.1.339.g0233b80