One of my programs works fine with GPC2.1/gcc2.95.3 it does not compile with 2003/03/23
I could isolate the problem (out of a 5000 lines source) to two small units (see below) The original unit declaz contains global variables and procedure common to almost all the rest of the program. Ttwo of its (public) variables are masked in the implementation part of another unit by a variable with the same name (not a bug). There is a warning for this situation: fine, but not so fine, all the variables declared after the warning are ignored, and trigger errors when they appear later.
To see it happen, copy the two sources below as gdeclaz.pas and gimpragr.pas, and try gpc --automake -c gimpragr.pas I get
jp@brea:~/agreg/src/pascal> gpc --automake -c gimpragr.pas gimpragr.pas:21: redeclaration of `l132' gdeclaz.pas:6: previous declaration gimpragr.pas: In procedure `presidence': gimpragr.pas:23: undeclared identifier `president' (first use in this routine) gimpragr.pas:23: (Each undeclared identifier is reported only once gimpragr.pas:23: for each routine it appears in.) gimpragr.pas:23: undeclared identifier `presidente' (first use in this routine)
***************************************************************************** unit gdeclaz; interface var l132 : boolean; implementation END. ********************************************************************************* Unit gimpragr; Interface Procedure impression; Implementation Uses gdeclaz; Var l132, president,presidente,chrono: Boolean;
Procedure presidence; Begin If Not (president Or presidente) Then Begin write('La présidence est elle tenue par un homme ou une femme H/F ? '); End; End; { presidence } procedure impression; Begin writeln('impression'); end; END. ******************************************************************************************
Jean-Pierre Vial wrote:
One of my programs works fine with GPC2.1/gcc2.95.3 it does not compile with 2003/03/23
I could isolate the problem (out of a 5000 lines source) to two small units (see below) The original unit declaz contains global variables and procedure common to almost all the rest of the program. Ttwo of its (public) variables are masked in the implementation part of another unit by a variable with the same name (not a bug). There is a warning for this situation: fine, but not so fine, all the variables declared after the warning are ignored, and trigger errors when they appear later.
To see it happen, copy the two sources below as gdeclaz.pas and gimpragr.pas, and try gpc --automake -c gimpragr.pas I get
jp@brea:~/agreg/src/pascal> gpc --automake -c gimpragr.pas gimpragr.pas:21: redeclaration of `l132' gdeclaz.pas:6: previous declaration gimpragr.pas: In procedure `presidence': gimpragr.pas:23: undeclared identifier `president' (first use in this routine) gimpragr.pas:23: (Each undeclared identifier is reported only once gimpragr.pas:23: for each routine it appears in.) gimpragr.pas:23: undeclared identifier `presidente' (first use in this routine)
So, where's a warning?
Frank
Le Dimanche 13 Avril 2003 19:29, vous avez écrit :
So, where's a warning?
I thought that this was a warning :
gimpragr.pas:21: redeclaration of `l132' gdeclaz.pas:6: previous declaration
maybe it is an error and not a warning, but that is not better. Is masking previous definitions now illegal ?
Jean-Pierre Vial wrote:
Le Dimanche 13 Avril 2003 19:29, vous avez écrit :
So, where's a warning?
I thought that this was a warning :
gimpragr.pas:21: redeclaration of `l132' gdeclaz.pas:6: previous declaration
maybe it is an error and not a warning, but that is not better.
It explains why the program won't compile.
Is masking previous definitions now illegal ?
Not supporting the same global identifier in different modules is one of the most well-known GPC bugs (in the context of missing "qualified identifiers"). Maybe such things work in some occasions in some GPC versions, but generally this can not be expected to work.
Frank