From: Bernhard Heckel <bernhard.heckel@intel.com>
To: qiyaoltc@gmail.com, eliz@gnu.org
Cc: gdb-patches@sourceware.org, Bernhard Heckel <bernhard.heckel@intel.com>
Subject: [PATCH V2 4/5] Fortran: Fix query of address of not-allocated types.
Date: Mon, 04 Jul 2016 09:52:00 -0000 [thread overview]
Message-ID: <1467625943-21294-5-git-send-email-bernhard.heckel@intel.com> (raw)
In-Reply-To: <1467625943-21294-1-git-send-email-bernhard.heckel@intel.com>
2016-06-30 Bernhard Heckel <bernhard.heckel@intel.com>
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" "= <not allocated>"
+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" " = <not allocated>" "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
next prev parent reply other threads:[~2016-07-04 9:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 9:52 [PATCH V2 0/5] Fortran: Resolve target types of pointers Bernhard Heckel
2016-07-04 9:52 ` [PATCH V2 2/5] Fortran: Testsuite, add print of pointer types Bernhard Heckel
2016-07-04 9:52 ` [PATCH V2 3/5] Fortran: Resolve dynamic target types of pointers Bernhard Heckel
2016-07-04 15:01 ` Eli Zaretskii
2016-07-05 14:35 ` Joel Brobecker
2016-07-05 15:31 ` Bernhard Heckel
2016-07-05 15:51 ` Joel Brobecker
2016-07-04 9:52 ` Bernhard Heckel [this message]
2016-07-04 9:52 ` [PATCH V2 5/5] Fortran: Handle cyclic pointers Bernhard Heckel
2016-07-04 9:52 ` [PATCH V2 1/5] Fortran: Typeprint, fix dangling types Bernhard Heckel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467625943-21294-5-git-send-email-bernhard.heckel@intel.com \
--to=bernhard.heckel@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).