User account creation filtered due to spam.

Bug 54949 - [F03] abstract procedure pointers not rejected
Summary: [F03] abstract procedure pointers not rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: janus
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2012-10-17 13:32 UTC by janus
Modified: 2013-12-16 22:03 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-10-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2012-10-17 13:32:06 UTC
Test case (inspired by https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/F_ROPgBJGpY):

program test
  implicit none
  abstract interface
    subroutine abssub
    end subroutine
  end interface
  pointer :: abssub

  abssub => sub
  
contains

  subroutine sub
  end subroutine

end



This currently gives an

internal compiler error: in fold_convert_loc, at fold-const.c:1979

but should be rejected, since a procedure pointer can not be ABSTRACT.
Comment 1 janus 2012-10-17 13:52:54 UTC
Preliminary patch:

Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(revision 192392)
+++ gcc/fortran/symbol.c	(working copy)
@@ -374,6 +374,7 @@ check_conflict (symbol_attribute *attr, const char
     *cray_pointee = "CRAY POINTEE", *data = "DATA", *value = "VALUE",
     *volatile_ = "VOLATILE", *is_protected = "PROTECTED",
     *is_bind_c = "BIND(C)", *procedure = "PROCEDURE",
+    *proc_pointer = "PROCEDURE POINTER", *abstract = "ABSTRACT",
     *asynchronous = "ASYNCHRONOUS", *codimension = "CODIMENSION",
     *contiguous = "CONTIGUOUS", *generic = "GENERIC";
   static const char *threadprivate = "THREADPRIVATE";
@@ -604,6 +605,8 @@ check_conflict (symbol_attribute *attr, const char
   conf (procedure, asynchronous)
   conf (procedure, entry)
 
+  conf (proc_pointer, abstract)
+
   a1 = gfc_code2string (flavors, attr->flavor);
 
   if (attr->in_namelist
Comment 2 janus 2012-10-17 15:46:03 UTC
(In reply to comment #1)
> Preliminary patch:

... regtests cleanly.
Comment 3 janus 2012-10-17 22:03:29 UTC
(In reply to comment #1)
> Preliminary patch:

Unfortunately, this does not help for the variant, where the POINTER declaration comes before the interface body:

  pointer :: abssub
  abstract interface
    subroutine abssub
    end subroutine
  end interface


Like the original test case, this results in an ICE.
Comment 4 janus 2013-12-16 13:43:46 UTC
Both test cases give an ICE at least with 4.6 on upward, but not with 4.4, so the ICE is technically a regression.
Comment 5 janus 2013-12-16 22:02:00 UTC
Author: janus
Date: Mon Dec 16 22:01:58 2013
New Revision: 206033

URL: http://gcc.gnu.org/viewcvs?rev=206033&root=gcc&view=rev
Log:
2013-12-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/54949
	* symbol.c (check_conflict): Forbid abstract procedure pointers.
	(gfc_add_abstract): Check for attribute conflicts.


2013-12-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/54949
	* gfortran.dg/proc_ptr_44.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_44.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 janus 2013-12-16 22:03:34 UTC
Fixed with r206033. Closing.