diff mbox

[Fortran,OOP] PR 43207: [OOP] invalid (pointer) assignment to and from abstract non-polymorphic expressions

Message ID CAKwh3qiOL8dRxew0sQ9sV=zmGt4DRYzoZFZ0vrZiQCo4rnjRVg@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil Dec. 2, 2016, 1:37 p.m. UTC
Hi all,

the attached patch fixes the PR in the subject line by introducing a
new check to reject invalid code. It's a slight update of an old patch
that I posted in the PR quite some time ago, using somewhat tighter
checking to avoid side effects on the testsuite.

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus


2016-12-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/43207
    * primary.c (gfc_match_varspec): Reject nonpolymorphic references to
    abstract types.

2016-12-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/43207
    * gfortran.dg/abstract_type_9.f90: New test case.

Comments

Steve Kargl Dec. 3, 2016, 5:03 p.m. UTC | #1
On Fri, Dec 02, 2016 at 02:37:24PM +0100, Janus Weil wrote:
> 
> the attached patch fixes the PR in the subject line by introducing a
> new check to reject invalid code. It's a slight update of an old patch
> that I posted in the PR quite some time ago, using somewhat tighter
> checking to avoid side effects on the testsuite.
> 
> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
> 

OK
Janus Weil Dec. 3, 2016, 6:49 p.m. UTC | #2
2016-12-03 18:03 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> On Fri, Dec 02, 2016 at 02:37:24PM +0100, Janus Weil wrote:
>>
>> the attached patch fixes the PR in the subject line by introducing a
>> new check to reject invalid code. It's a slight update of an old patch
>> that I posted in the PR quite some time ago, using somewhat tighter
>> checking to avoid side effects on the testsuite.
>>
>> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>>
>
> OK

Thanks, committed as r243224.

Cheers,
Janus
diff mbox

Patch

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 243176)
+++ gcc/fortran/primary.c	(working copy)
@@ -2222,7 +2222,15 @@  check_substring:
 	}
     }
 
-  /* F2008, C727.  */
+  /* F08:C611.  */
+  if (primary->ts.type == BT_DERIVED && primary->ref
+      && primary->ts.u.derived && primary->ts.u.derived->attr.abstract)
+    {
+      gfc_error ("Nonpolymorphic reference to abstract type at %C");
+      return MATCH_ERROR;
+    }
+
+  /* F08:C727.  */
   if (primary->expr_type == EXPR_PPC && gfc_is_coindexed (primary))
     {
       gfc_error ("Coindexed procedure-pointer component at %C");