public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52552] [OOP] ICE when trying to allocate non-allocatable object giving a dynamic type Date: Thu, 07 Jun 2012 16:26:00 -0000 [thread overview] Message-ID: <bug-52552-4-NmKf3Zxjnl@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-52552-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52552 janus at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |janus at gcc dot gnu.org AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org |gnu.org | --- Comment #4 from janus at gcc dot gnu.org 2012-06-07 16:25:57 UTC --- I think one can avoid the whole problem by reshuffling the order of checks being done in 'gfc_match_allocate', like this: Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 188139) +++ gcc/fortran/match.c (working copy) @@ -3533,6 +3533,28 @@ gfc_match_allocate (void) } } + /* FIXME: disable the checking on derived types and arrays. */ + sym = tail->expr->symtree->n.sym; + b1 = !(tail->expr->ref + && (tail->expr->ref->type == REF_COMPONENT + || tail->expr->ref->type == REF_ARRAY)); + if (sym && sym->ts.type == BT_CLASS && sym->attr.class_ok) + b2 = !(CLASS_DATA (sym)->attr.allocatable + || CLASS_DATA (sym)->attr.class_pointer); + else + b2 = sym && !(sym->attr.allocatable || sym->attr.pointer + || sym->attr.proc_pointer); + b3 = sym && sym->ns && sym->ns->proc_name + && (sym->ns->proc_name->attr.allocatable + || sym->ns->proc_name->attr.pointer + || sym->ns->proc_name->attr.proc_pointer); + if (b1 && b2 && !b3) + { + gfc_error ("Allocate-object at %L is neither a nonprocedure pointer " + "nor an allocatable variable", &tail->expr->where); + goto cleanup; + } + /* The ALLOCATE statement had an optional typespec. Check the constraints. */ if (ts.type != BT_UNKNOWN) @@ -3558,28 +3580,6 @@ gfc_match_allocate (void) if (tail->expr->ts.type == BT_DERIVED) tail->expr->ts.u.derived = gfc_use_derived (tail->expr->ts.u.derived); - /* FIXME: disable the checking on derived types and arrays. */ - sym = tail->expr->symtree->n.sym; - b1 = !(tail->expr->ref - && (tail->expr->ref->type == REF_COMPONENT - || tail->expr->ref->type == REF_ARRAY)); - if (sym && sym->ts.type == BT_CLASS && sym->attr.class_ok) - b2 = !(CLASS_DATA (sym)->attr.allocatable - || CLASS_DATA (sym)->attr.class_pointer); - else - b2 = sym && !(sym->attr.allocatable || sym->attr.pointer - || sym->attr.proc_pointer); - b3 = sym && sym->ns && sym->ns->proc_name - && (sym->ns->proc_name->attr.allocatable - || sym->ns->proc_name->attr.pointer - || sym->ns->proc_name->attr.proc_pointer); - if (b1 && b2 && !b3) - { - gfc_error ("Allocate-object at %L is neither a nonprocedure pointer " - "nor an allocatable variable", &tail->expr->where); - goto cleanup; - } - if (gfc_peek_ascii_char () == '(' && !sym->attr.dimension) { gfc_error ("Shape specification for allocatable scalar at %C"); This patch avoids the segfault and correctly rejects the test case. I hope it does not introduce any other problems (I'll try it on the testsuite soon).
next prev parent reply other threads:[~2012-06-07 16:26 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-03-10 14:58 [Bug fortran/52552] New: Internal compiler error " gccbgz.lionm at xoxy dot net 2012-03-10 19:10 ` [Bug fortran/52552] [OOP] ICE " burnus at gcc dot gnu.org 2012-03-12 11:24 ` burnus at gcc dot gnu.org 2012-03-12 11:30 ` burnus at gcc dot gnu.org 2012-06-07 16:26 ` janus at gcc dot gnu.org [this message] 2012-06-08 7:56 ` janus at gcc dot gnu.org 2012-06-08 17:26 ` janus at gcc dot gnu.org 2012-06-08 17:39 ` janus at gcc dot gnu.org 2012-06-08 18:56 ` gccbgz.lionm at xoxy dot net
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=bug-52552-4-NmKf3Zxjnl@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).