Theo Carr-Brion wrote:
I am using gpc 20010924 with gcc 2.95.3 on UnixWare 7.1 and the following code does not work.
... snip ...
Being annoyed with this, I also found that gpc 2.95.3 under DJGPP finds no fault with it. I then passed the source through PascalP, after making some declaration changes for str10 and string, and removing the "const" in the function parameter declaration. The resultant listing follows (and will be seriously troubled by line wrap)
2001 Oct 11 13:46 PASCAL-P Universal Compiler Ver. 3.1.9T
1000 0:d Program Test(Input, Output); 2000 0:d 3000 0:d Type 4000 0:d Str10 = ARRAY[1..10] OF char; (*String(10);*) 5000 0:d string = ARRAY[1..80] OF char; 6000 0:d 7000 0:d LetterType = (AA, BB, CC, DD); 8000 0:d MyRec = record 9000 0:d LetterName: Array[LetterType] of Str10; 10000 0:d end; 11000 0:d procedure SetIt(var aStr1: String; { const} aStr2: String); 12000 0:d begin 13000 0: 2 aStr1:=aStr2; 14000 12: 2 end; 15000 17: 2 16000 17: 2 var **** ^17 17. Error in declaration part 17000 0:d ThisLetter: LetterType; 18000 2:d ThisRec: MyRec; 19000 42:d 20000 42:d begin 21000 0: 1 for ThisLetter:=AA to DD do 22000 21: 2 SetIt(ThisRec.LetterName[ThisLetter], Chr(Ord(ThisLetter)+Ord('A'))); **** ^68 ^109,68 68. Illegal parameter substitution
109. Attempt to load the address of an expression 23000 60: 1 for ThisLetter:=AA to DD do 24000 76: 2 WriteLn(ThisRec.letterName[ThisLetter]); 25000 118: 1 for ThisLetter:=AA to DD do 26000 134: 2 ThisRec.LetterName[ThisLetter]:=Chr(Ord(ThisLetter)+Ord('A'));
**** ^55 55. Operand type conflict 27000 169: 1 for ThisLetter:=AA to DD do 28000 185: 2 WriteLn(ThisRec.LetterName[ThisLetter]); 29000 227: 1 end.
NO. ERRORS=5 WARNINGS=0 Program size(pcode bytes)=249
PascalP is fairly stringent. My question is: why does GPC fail to pick up these errors? Do I have to do some configuration to get it conformant?