mirror of
https://github.com/cc65/cc65.git
synced 2025-02-08 11:31:34 +00:00
Fixed constness of bit-fields.
This commit is contained in:
parent
5537b61e6a
commit
6434176909
@ -497,8 +497,8 @@ Type* NewPointerTo (const Type* T)
|
|||||||
|
|
||||||
|
|
||||||
Type* NewBitFieldOf (const Type* T, unsigned BitOffs, unsigned BitWidth)
|
Type* NewBitFieldOf (const Type* T, unsigned BitOffs, unsigned BitWidth)
|
||||||
/* Return a type string that is "T : BitWidth" aligned on BitOffs. The type
|
/* Return a type string that is "unqualified T : BitWidth" aligned on BitOffs.
|
||||||
** string is allocated on the heap and may be freed after use.
|
** The type string is allocated on the heap and may be freed after use.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
Type* P;
|
Type* P;
|
||||||
|
@ -435,8 +435,8 @@ Type* NewPointerTo (const Type* T);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Type* NewBitFieldOf (const Type* T, unsigned BitOffs, unsigned BitWidth);
|
Type* NewBitFieldOf (const Type* T, unsigned BitOffs, unsigned BitWidth);
|
||||||
/* Return a type string that is "T : BitWidth" aligned on BitOffs. The type
|
/* Return a type string that is "unqualified T : BitWidth" aligned on BitOffs.
|
||||||
** string is allocated on the heap and may be freed after use.
|
** The type string is allocated on the heap and may be freed after use.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Type* AddressOf (const Type* T);
|
const Type* AddressOf (const Type* T);
|
||||||
|
@ -1023,6 +1023,7 @@ SymEntry* AddBitField (const char* Name, const Type* T, unsigned Offs,
|
|||||||
} else {
|
} else {
|
||||||
Entry->Type = NewBitFieldOf (T, BitOffs, BitWidth);
|
Entry->Type = NewBitFieldOf (T, BitOffs, BitWidth);
|
||||||
}
|
}
|
||||||
|
Entry->Type[0].C |= GetQualifier (T) & T_MASK_QUAL;
|
||||||
|
|
||||||
/* Add the entry to the symbol table */
|
/* Add the entry to the symbol table */
|
||||||
AddSymEntry (FieldTab, Entry);
|
AddSymEntry (FieldTab, Entry);
|
||||||
|
14
test/err/bug2018-bitfield.c
Normal file
14
test/err/bug2018-bitfield.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* Bug #2018 - Compiler has problems with const struct fields */
|
||||||
|
|
||||||
|
typedef union U {
|
||||||
|
int a : 16;
|
||||||
|
const int b : 16;
|
||||||
|
} U;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
U x = { 42 };
|
||||||
|
x.b = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user