diff --git a/Header.pas b/Header.pas index ad434a8..065cc2c 100644 --- a/Header.pas +++ b/Header.pas @@ -872,7 +872,8 @@ procedure EndInclude {chPtr: ptr}; | (ord(allowLongIntChar) << 1) | (ord(allowTokensAfterEndif) << 2) | (ord(allowSlashSlashComments) << 3) - | (ord(allowMixedDeclarations) << 4)); + | (ord(allowMixedDeclarations) << 4) + | (ord(looseCharTypeChecks) << 5)); p_segment: begin for i := 1 to 10 do begin @@ -1524,6 +1525,7 @@ var allowSlashSlashComments := odd(i >> 3); allowMixedDeclarations := odd(i >> 4); c99Scope := allowMixedDeclarations; + looseCharTypeChecks := odd(i >> 5); end; p_segment: begin diff --git a/Scanner.pas b/Scanner.pas index d5f0ece..fd28a16 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -89,6 +89,7 @@ var {Note: The following two are set together} allowMixedDeclarations: boolean; {allow mixed declarations & stmts (C99)?} c99Scope: boolean; {follow C99 rules for block scopes?} + looseCharTypeChecks: boolean; {treat char and unsigned char as compatible?} {---------------------------------------------------------------} @@ -2981,6 +2982,7 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin allowTokensAfterEndif := odd(val >> 2); allowSlashSlashComments := odd(val >> 3); allowMixedDeclarations := odd(val >> 4); + looseCharTypeChecks := odd(val >> 5); if allowMixedDeclarations <> c99Scope then begin if doingFunction then Error(126) @@ -3672,6 +3674,7 @@ allowTokensAfterEndif := false; {allow tokens after #endif} allowSlashSlashComments := true; {allow // comments} allowMixedDeclarations := true; {allow mixed declarations & stmts (C99)} c99Scope := true; {follow C99 rules for block scopes} +looseCharTypeChecks := true; {make char and unsigned char compatible} foundFunction := false; {no functions found so far} fileList := nil; {no included files} gettingFileName := false; {not in GetFileName} diff --git a/Symbol.pas b/Symbol.pas index 8d2215f..081d8ce 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -383,9 +383,14 @@ else case kind1 of scalarType: - if kind2 = scalarType then - CompTypes := - (t1^.baseType = t2^.baseType) and (t1^.cType = t2^.cType) + if kind2 = scalarType then begin + CompTypes := t1^.baseType = t2^.baseType; + if t1^.cType <> t2^.cType then + if not (looseCharTypeChecks + and (t1^.cType in [ctChar, ctUChar]) + and (t2^.cType in [ctChar, ctUChar])) then + CompTypes := false; + end {if} else if kind2 = enumType then CompTypes := (t1^.baseType = cgWord) and (t1^.cType = ctInt);