Bug 37412 - No error on repeated declaration
Summary: No error on repeated declaration
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
: 34527 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-09-07 20:51 UTC by Kristján Jónasson
Modified: 2009-12-08 21:01 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-09-07 21:35:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kristján Jónasson 2008-09-07 20:51:25 UTC
The following program compiles OK with no message that st is being redefined.

function fun() result(st)
  character(2) st
  character(1) st
  st = '1'
end function fun
Comment 1 Dominique d'Humieres 2008-09-07 21:15:00 UTC
Confirmed with 4.2.3 and 4.3.2, with 4.4.0 (trunk) I get:

[ibook-dhum] f90/bug% gfc -Wall pr37412.f90
pr37412.f90:3.17:

  character(1) st
                1
Warning: Symbol 'st' at (1) already has basic type of CHARACTER

Now I am not sure which statement is the winner. Is this defined somewhere?
Comment 2 Tobias Burnus 2008-09-07 21:35:52 UTC
(In reply to comment #1)
> Warning: Symbol 'st' at (1) already has basic type of CHARACTER

I think one should print here an error as the LEN type parameter is different. 

The same issue exists for the KIND type parameter.

> Now I am not sure which statement is the winner. Is this defined somewhere?

I think it is a bug (cf. above) and thus not really defined. However, testing with gfortran 4.3 implies that the latter definition wins.
Comment 3 Dominique d'Humieres 2008-09-07 22:06:26 UTC
With -std=f95 all the gfortran versions I have reject the code with:

[ibook-dhum] f90/bug% gfc -std=f95 pr37412.f90
pr37412.f90:3.17:

  character(1) st
                1
Error: Symbol 'st' at (1) already has basic type of CHARACTER

> I think one should print here an error as the LEN type parameter is different. 
>
> The same issue exists for the KIND type parameter.

I agree this would avoid to wonder which statement is taken into account.
Comment 4 Daniel Kraft 2008-09-08 06:36:13 UTC
IIRC, this behaviour is due to a patch I submitted some time ago.  Maybe I could change this warning into an error even for non-standard conforming mode in case the length or a kind parameter differs.  What do you think?
Comment 5 Daniel Franke 2009-12-08 20:58:30 UTC
*** Bug 34527 has been marked as a duplicate of this bug. ***
Comment 6 Daniel Franke 2009-12-08 21:01:26 UTC
(In reply to comment #4)
> Maybe I could change this warning into an error even for non-standard 
> conforming mode in case the length or a kind parameter differs.  What
> do you think?

I assume, this happened at some point. Current 4.5.0 20091208 gives:

$> gfortran-svn pr37412.f90
pr37412.f90:3.17:

  character(1) st
                 1
Error: Symbol 'st' at (1) already has basic type of CHARACTER

I believe this is correct. Closing.