Bug 32715 - improve diagnostics of attempted allocation of non-array
Summary: improve diagnostics of attempted allocation of non-array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2007-07-10 09:34 UTC by Daniel Franke
Modified: 2009-08-23 03:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-08-08 16:44:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Franke 2007-07-10 09:34:59 UTC
$> cat allocate.f90
INTEGER :: i
ALLOCATE(i(3))
end

$>  gfortran-svn -g -Wall allocate.f90
allocate.f90:2.10:

ALLOCATE(i(3))
         1
Error: Syntax error in ALLOCATE statement at (1)


A message as "variable 'i' at (1) not a pointer or allocatable array" would be preferable.
Comment 1 Tobias Burnus 2007-07-19 16:30:07 UTC
In gfc_match_allocate
      m = gfc_match_variable (&tail->expr, 0);
matches successfully, but it fails at:
  if (gfc_match (" )%t") != MATCH_YES)
    goto syntax;

As "i" is scalar, it does not seem to match the "(4)" (or only partially) and thus it does not match " )%t".
Comment 2 kargls 2008-12-11 00:16:26 UTC
The patch I submitted, here:

http://gcc.gnu.org/ml/fortran/2008-12/msg00167.html

gives

troutmask:sgk[224] gfc4x -o z k.f90
k.f90:2.10:

ALLOCATE(i(3))
         1
Error: Allocate-object at (1) is not a nonprocedure pointer or
an allocatable variable
Comment 3 kargls 2009-08-23 03:39:46 UTC
Fixed by revision 151023.
No plans for a back port.