Bug 52652 - call to gfc_match_asynchronous for allocatable at parse.c line 164
Summary: call to gfc_match_asynchronous for allocatable at parse.c line 164
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-03-21 09:45 UTC by Brian Ames
Modified: 2012-03-28 20:51 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-03-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Ames 2012-03-21 09:45:26 UTC
parse.c line 164:

Is:
      match ("allocatable", gfc_match_asynchronous, ST_ATTR_DECL);

Should be?

      match ("allocatable", gfc_match_allocatable, ST_ATTR_DECL);
Comment 1 Tobias Burnus 2012-03-21 13:21:35 UTC
Confirmed - and well spotted. Thanks for the bug report!

 * * *

The code has been added for PR 25829 comment 16 (Rev. 155732), however, it wasn't working before either - thus, it is not a regression. (I had an example to test the parsing in the patch submittal - but as  I didn't use "allocate()" it "successfully" compiled.)

 * * *

Test case: It's valid, but rejected with
  Error: Allocate-object at (1) is not a nonprocedure pointer
         or an allocatable variable


module m
  type t
  end type t
end module m

type(t) function bar()
  use m
  allocatable :: bar
  allocate (bar)
end

Untested patch:

--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -3574,4 +3574,4 @@ gfc_match_allocate (void)
        {
-         gfc_error ("Allocate-object at %L is not a nonprocedure pointer "
-                    "or an allocatable variable", &tail->expr->where);
+         gfc_error ("Allocate-object at %L is neither a nonprocedure pointer "
+                    "nor an allocatable variable", &tail->expr->where);
          goto cleanup;
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -163,3 +163,3 @@ decode_specification_statement (void)
             ST_INTERFACE);
-      match ("allocatable", gfc_match_asynchronous, ST_ATTR_DECL);
+      match ("allocatable", gfc_match_allocatable, ST_ATTR_DECL);
       match ("asynchronous", gfc_match_asynchronous, ST_ATTR_DECL);

--- a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_1.f90
+++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_1.f90
@@ -27 +27 @@ program a
-  allocate(err) ! { dg-error "nonprocedure pointer or an allocatable" }
+  allocate(err) ! { dg-error "neither a nonprocedure pointer nor an allocatable" }
--- a/gcc/testsuite/gfortran.dg/allocate_class_1.f90
+++ b/gcc/testsuite/gfortran.dg/allocate_class_1.f90
@@ -10 +10 @@
- allocate(x)     ! { dg-error "is not a nonprocedure pointer or an allocatable variable" }
+ allocate(x)     ! { dg-error "is neither a nonprocedure pointer nor an allocatable variable" }
--- a/gcc/testsuite/gfortran.dg/allocate_with_typespec_4.f90
+++ b/gcc/testsuite/gfortran.dg/allocate_with_typespec_4.f90
@@ -24 +24 @@ subroutine not_an_f03_intrinsic
-   allocate(double complex :: d1) ! { dg-error "not a nonprocedure pointer or an allocatable" }
+   allocate(double complex :: d1) ! { dg-error "neither a nonprocedure pointer nor an allocatable" }
--- a/gcc/testsuite/gfortran.dg/deallocate_alloc_opt_1.f90
+++ b/gcc/testsuite/gfortran.dg/deallocate_alloc_opt_1.f90
@@ -27 +27 @@ program a
-  deallocate(err) ! { dg-error "nonprocedure pointer or an allocatable" }
+  deallocate(err) ! { dg-error "nonprocedure pointer nor an allocatable" }
Comment 2 Paul Thomas 2012-03-28 20:45:30 UTC
Author: pault
Date: Wed Mar 28 20:45:16 2012
New Revision: 185924

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185924
Log:
2012-03-28  Paul Thomas  <pault@gcc.gnu.org>
	Tobias Burnus  <burnus@gcc.gnu.org>

	PR fortran/52652
	* match.c (gfc_match_allocate, gfc_match_deallocate): Change
	"not.. or" to "neither.. nor".
	* parse.c (decode_specification_statement): Correct error in
	chpice of matching function for "allocatable". 

2012-03-28  Paul Thomas  <pault@gcc.gnu.org>
	Tobias Burnus  <burnus@gcc.gnu.org>

	PR fortran/52652
	* gfortran.dg/allocate_class_1.f90 : Change error test.
	* gfortran.dg/allocate_with_typespec_4.f90 : Change error test.
	* gfortran.dg/allocate_alloc_opt_1.f90 : Change error test.
	* gfortran.dg/deallocate_alloc_opt_1.f90 : Change error test.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/allocate_alloc_opt_1.f90
    trunk/gcc/testsuite/gfortran.dg/allocate_class_1.f90
    trunk/gcc/testsuite/gfortran.dg/allocate_with_typespec_4.f90
    trunk/gcc/testsuite/gfortran.dg/deallocate_alloc_opt_1.f90
Comment 3 Paul Thomas 2012-03-28 20:51:02 UTC
Thanks for the good call, Brian!

Fixed on trunk

Paul