diff --git a/Symbol.pas b/Symbol.pas index 9d60a43..61c4546 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -433,8 +433,12 @@ else end; {if} functionType: - if kind2 = functionType then - CompTypes := CompTypes(t1^.ftype,t2^.ftype) + if kind2 = functionType then begin + if looseTypeChecks or (t1^.prototyped <> t2^.prototyped) then + CompTypes := CompTypes(t1^.ftype,t2^.ftype) + else + CompTypes := StrictCompTypes(t1, t2); + end {if} else if kind2 = pointerType then if t2^.ptype^.kind = functionType then CompTypes := CompTypes(t1, t2^.ptype); diff --git a/cc.notes b/cc.notes index 33ae393..2af217c 100644 --- a/cc.notes +++ b/cc.notes @@ -475,11 +475,13 @@ Bit 2 (a value of 4) controls whether spurious tokens are allowed after an #endi Bit 4 (a value of 16) controls whether ORCA/C follows C99-style rules for declaration placement and block scopes. See "New Language Features," above. -Bit 5 (a value of 32) controls whether type compatibility checks should strictly follow the C standards, or whether looser rules should be used in certain cases. If this bit is set, the looser rules will be followed, matching ORCA/C's historical behavior. Bit 5 is currently set by default, but new code should avoid relying on this. There are two specific situations where bit 5 currently has an effect: +Bit 5 (a value of 32) controls whether type compatibility checks should strictly follow the C standards, or whether looser rules should be used in certain cases. If this bit is set, the looser rules will be followed, matching ORCA/C's historical behavior. Bit 5 is currently set by default, but new code should avoid relying on this. There are three specific situations where bit 5 currently has an effect: First, setting bit 5 causes pointer assignments that discard type qualifiers to be allowed. For example, this affects an assignment from an expression of type "const int *" to a variable of type "int *", because it discards the "const" qualifier from the type pointed to. These assignments are prohibited by the C standards, but ORCA/C historically allowed them. If bit 5 is set it will still allow them, but if bit 5 is clear it will give an error. -Second, setting bit 5 causes the types "char" and "unsigned char" to be treated as compatible with each other for most purposes. These types have the same representation in ORCA/C, but the C standards specify that they are nonetheless two distinct types and are not mutually compatible. Therefore, any standard-conforming C compiler should produce a diagnostic message if these two types or types derived from them are used in a situation where the types are required to be compatible, as in the following example: +Second, setting bit 5 causes type compatibility checks involving function pointers to ignore the prototyped parameter types. If bit 5 is clear, the prototyped parameter types (if available) must be compatible. + +Third, setting bit 5 causes the types "char" and "unsigned char" to be treated as compatible with each other for most purposes. These types have the same representation in ORCA/C, but the C standards specify that they are nonetheless two distinct types and are not mutually compatible. Therefore, any standard-conforming C compiler should produce a diagnostic message if these two types or types derived from them are used in a situation where the types are required to be compatible, as in the following example: unsigned char uc; char *p = &uc; /* &uc has type unsigned char *, incompatible with char *. */