mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
Fixed an error: When determining where to place initialized data, the compiler
didn't look "deep enough" into nested arrays to determine the constness correctly. git-svn-id: svn://svn.cc65.org/cc65/trunk@5622 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
515661e5f4
commit
724d1b9160
@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2009, Ullrich von Bassewitz */
|
||||
/* (C) 2000-2012, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@ -209,9 +209,7 @@ static void Parse (void)
|
||||
* the element qualifiers, since not the array but its
|
||||
* elements are const.
|
||||
*/
|
||||
if (IsQualConst (Decl.Type) ||
|
||||
(IsTypeArray (Decl.Type) &&
|
||||
IsQualConst (GetElementType (Decl.Type)))) {
|
||||
if (IsQualConst (GetBaseElementType (Decl.Type))) {
|
||||
g_userodata ();
|
||||
} else {
|
||||
g_usedata ();
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2008 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2012, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@ -654,6 +654,20 @@ Type* GetElementType (Type* T)
|
||||
|
||||
|
||||
|
||||
Type* GetBaseElementType (Type* T)
|
||||
/* Return the base element type of a given type. If T is not an array, this
|
||||
* will return. Otherwise it will return the base element type, which means
|
||||
* the element type that is not an array.
|
||||
*/
|
||||
{
|
||||
while (IsTypeArray (T)) {
|
||||
++T;
|
||||
}
|
||||
return T;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SymEntry* GetSymEntry (const Type* T)
|
||||
/* Return a SymEntry pointer from a type */
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||
/* (C) 1998-2012, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@ -640,6 +640,12 @@ void SetElementCount (Type* T, long Count);
|
||||
Type* GetElementType (Type* T);
|
||||
/* Return the element type of the given array type. */
|
||||
|
||||
Type* GetBaseElementType (Type* T);
|
||||
/* Return the base element type of a given type. If T is not an array, this
|
||||
* will return. Otherwise it will return the base element type, which means
|
||||
* the element type that is not an array.
|
||||
*/
|
||||
|
||||
struct SymEntry* GetSymEntry (const Type* T) attribute ((const));
|
||||
/* Return a SymEntry pointer from a type */
|
||||
|
||||
|
@ -359,8 +359,7 @@ static unsigned ParseStaticDecl (Declaration* Decl, unsigned* SC)
|
||||
* For arrays, we need to check the elements of the array for
|
||||
* constness, not the array itself.
|
||||
*/
|
||||
if (IsQualConst (Decl->Type) ||
|
||||
(IsTypeArray (Decl->Type) && IsQualConst (GetElementType (Decl->Type)))) {
|
||||
if (IsQualConst (GetBaseElementType (Decl->Type))) {
|
||||
SymData = AllocLabel (g_userodata);
|
||||
} else {
|
||||
SymData = AllocLabel (g_usedata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user