aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/declaration.d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2024-01-16 19:57:40 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2024-02-03 00:16:55 +0100
commit838e706fa55b1798fb5f0242dbd90cd4d9817bbe (patch)
treeba9e9519442f8edea295b389e77e1183403d87d8 /gcc/d/dmd/declaration.d
parentcfc6d9ae8143cf0e903384bc63e8d659ca1c9fe7 (diff)
downloadgcc-838e706fa55b1798fb5f0242dbd90cd4d9817bbe.zip
gcc-838e706fa55b1798fb5f0242dbd90cd4d9817bbe.tar.gz
gcc-838e706fa55b1798fb5f0242dbd90cd4d9817bbe.tar.bz2
d: Merge upstream dmd, druntime f1a045928e
D front-end changes: - Import dmd v2.106.1-rc.1. - Unrecognized pragmas are no longer an error by default. D runtime changes: - Import druntime v2.106.1-rc.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd f1a045928e. * dmd/VERSION: Bump version to v2.106.1-rc.1. * gdc.texi (fignore-unknown-pragmas): Update documentation. * d-builtins.cc (covariant_with_builtin_type_p): Update for new front-end interface. * d-lang.cc (d_parse_file): Likewise. * typeinfo.cc (make_frontend_typeinfo): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime f1a045928e. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/stdc/stdatomic.d. * libdruntime/Makefile.in: Regenerate.
Diffstat (limited to 'gcc/d/dmd/declaration.d')
-rw-r--r--gcc/d/dmd/declaration.d287
1 files changed, 0 insertions, 287 deletions
diff --git a/gcc/d/dmd/declaration.d b/gcc/d/dmd/declaration.d
index 0e125fd..bdc91f4 100644
--- a/gcc/d/dmd/declaration.d
+++ b/gcc/d/dmd/declaration.d
@@ -1214,88 +1214,6 @@ extern (C++) class VarDeclaration : Declaration
return v;
}
- override void setFieldOffset(AggregateDeclaration ad, ref FieldState fieldState, bool isunion)
- {
- //printf("VarDeclaration::setFieldOffset(ad = %s) %s\n", ad.toChars(), toChars());
-
- if (aliasTuple)
- {
- // If this variable was really a tuple, set the offsets for the tuple fields
- aliasTuple.foreachVar((s) { s.setFieldOffset(ad, fieldState, isunion); });
- return;
- }
-
- if (!isField())
- return;
- assert(!(storage_class & (STC.static_ | STC.extern_ | STC.parameter)));
-
- //printf("+VarDeclaration::setFieldOffset(ad = %s) %s\n", ad.toChars(), toChars());
-
- /* Fields that are tuples appear both as part of TupleDeclarations and
- * as members. That means ignore them if they are already a field.
- */
- if (offset)
- {
- // already a field
- fieldState.offset = ad.structsize; // https://issues.dlang.org/show_bug.cgi?id=13613
- return;
- }
- for (size_t i = 0; i < ad.fields.length; i++)
- {
- if (ad.fields[i] == this)
- {
- // already a field
- fieldState.offset = ad.structsize; // https://issues.dlang.org/show_bug.cgi?id=13613
- return;
- }
- }
-
- // Check for forward referenced types which will fail the size() call
- Type t = type.toBasetype();
- if (storage_class & STC.ref_)
- {
- // References are the size of a pointer
- t = Type.tvoidptr;
- }
- Type tv = t.baseElemOf();
- if (tv.ty == Tstruct)
- {
- auto ts = cast(TypeStruct)tv;
- assert(ts.sym != ad); // already checked in ad.determineFields()
- if (!ts.sym.determineSize(loc))
- {
- type = Type.terror;
- errors = true;
- return;
- }
- }
-
- // List in ad.fields. Even if the type is error, it's necessary to avoid
- // pointless error diagnostic "more initializers than fields" on struct literal.
- ad.fields.push(this);
-
- if (t.ty == Terror)
- return;
-
- /* If coming after a bit field in progress,
- * advance past the field
- */
- fieldState.inFlight = false;
-
- const sz = t.size(loc);
- assert(sz != SIZE_INVALID && sz < uint.max);
- uint memsize = cast(uint)sz; // size of member
- uint memalignsize = target.fieldalign(t); // size of member for alignment purposes
- offset = placeField(
- fieldState.offset,
- memsize, memalignsize, alignment,
- ad.structsize, ad.alignsize,
- isunion);
-
- //printf("\t%s: memalignsize = %d\n", toChars(), memalignsize);
- //printf(" addField '%s' to '%s' at offset %d, size = %d\n", toChars(), ad.toChars(), offset, memsize);
- }
-
override const(char)* kind() const
{
return "variable";
@@ -1803,211 +1721,6 @@ extern (C++) class BitFieldDeclaration : VarDeclaration
: (1L << (width - 1)) - 1);
return v;
}
-
- override final void setFieldOffset(AggregateDeclaration ad, ref FieldState fieldState, bool isunion)
- {
- enum log = false;
- static if (log)
- {
- printf("BitFieldDeclaration::setFieldOffset(ad: %s, field: %s)\n", ad.toChars(), toChars());
- void print(const ref FieldState fieldState)
- {
- fieldState.print();
- printf(" fieldWidth = %d bits\n", fieldWidth);
- }
- print(fieldState);
- }
-
- Type t = type.toBasetype();
- const bool anon = isAnonymous();
-
- // List in ad.fields. Even if the type is error, it's necessary to avoid
- // pointless error diagnostic "more initializers than fields" on struct literal.
- if (!anon)
- ad.fields.push(this);
-
- if (t.ty == Terror)
- return;
-
- const sz = t.size(loc);
- assert(sz != SIZE_INVALID && sz < uint.max);
- uint memsize = cast(uint)sz; // size of member
- uint memalignsize = target.fieldalign(t); // size of member for alignment purposes
- if (log) printf(" memsize: %u memalignsize: %u\n", memsize, memalignsize);
-
- if (fieldWidth == 0 && !anon)
- error(loc, "named bit fields cannot have 0 width");
- if (fieldWidth > memsize * 8)
- error(loc, "bit field width %d is larger than type", fieldWidth);
-
- const style = target.c.bitFieldStyle;
-
- void startNewField()
- {
- if (log) printf("startNewField()\n");
- uint alignsize;
- if (style == TargetC.BitFieldStyle.Gcc_Clang)
- {
- if (fieldWidth > 32)
- alignsize = memalignsize;
- else if (fieldWidth > 16)
- alignsize = 4;
- else if (fieldWidth > 8)
- alignsize = 2;
- else
- alignsize = 1;
- }
- else
- alignsize = memsize; // not memalignsize
-
- uint dummy;
- offset = placeField(
- fieldState.offset,
- memsize, alignsize, alignment,
- ad.structsize,
- (anon && style == TargetC.BitFieldStyle.Gcc_Clang) ? dummy : ad.alignsize,
- isunion);
-
- fieldState.inFlight = true;
- fieldState.fieldOffset = offset;
- fieldState.bitOffset = 0;
- fieldState.fieldSize = memsize;
- }
-
- if (style == TargetC.BitFieldStyle.Gcc_Clang)
- {
- if (fieldWidth == 0)
- {
- if (!isunion)
- {
- // Use type of zero width field to align to next field
- fieldState.offset = (fieldState.offset + memalignsize - 1) & ~(memalignsize - 1);
- ad.structsize = fieldState.offset;
- }
-
- fieldState.inFlight = false;
- return;
- }
-
- if (ad.alignsize == 0)
- ad.alignsize = 1;
- if (!anon &&
- ad.alignsize < memalignsize)
- ad.alignsize = memalignsize;
- }
- else if (style == TargetC.BitFieldStyle.MS)
- {
- if (ad.alignsize == 0)
- ad.alignsize = 1;
- if (fieldWidth == 0)
- {
- if (fieldState.inFlight && !isunion)
- {
- // documentation says align to next int
- //const alsz = cast(uint)Type.tint32.size();
- const alsz = memsize; // but it really does this
- fieldState.offset = (fieldState.offset + alsz - 1) & ~(alsz - 1);
- ad.structsize = fieldState.offset;
- }
-
- fieldState.inFlight = false;
- return;
- }
- }
- else if (style == TargetC.BitFieldStyle.DM)
- {
- if (anon && fieldWidth && (!fieldState.inFlight || fieldState.bitOffset == 0))
- return; // this probably should be a bug in DMC
- if (ad.alignsize == 0)
- ad.alignsize = 1;
- if (fieldWidth == 0)
- {
- if (fieldState.inFlight && !isunion)
- {
- const alsz = memsize;
- fieldState.offset = (fieldState.offset + alsz - 1) & ~(alsz - 1);
- ad.structsize = fieldState.offset;
- }
-
- fieldState.inFlight = false;
- return;
- }
- }
-
- if (!fieldState.inFlight)
- {
- //printf("not in flight\n");
- startNewField();
- }
- else if (style == TargetC.BitFieldStyle.Gcc_Clang)
- {
- // If the bit-field spans more units of alignment than its type,
- // start a new field at the next alignment boundary.
- if (fieldState.bitOffset == fieldState.fieldSize * 8 &&
- fieldState.bitOffset + fieldWidth > memalignsize * 8)
- {
- if (log) printf("more units of alignment than its type\n");
- startNewField(); // the bit field is full
- }
- else
- {
- // if alignment boundary is crossed
- uint start = fieldState.fieldOffset * 8 + fieldState.bitOffset;
- uint end = start + fieldWidth;
- //printf("%s start: %d end: %d memalignsize: %d\n", ad.toChars(), start, end, memalignsize);
- if (start / (memalignsize * 8) != (end - 1) / (memalignsize * 8))
- {
- if (log) printf("alignment is crossed\n");
- startNewField();
- }
- }
- }
- else if (style == TargetC.BitFieldStyle.DM ||
- style == TargetC.BitFieldStyle.MS)
- {
- if (memsize != fieldState.fieldSize ||
- fieldState.bitOffset + fieldWidth > fieldState.fieldSize * 8)
- {
- //printf("new field\n");
- startNewField();
- }
- }
- else
- assert(0);
-
- offset = fieldState.fieldOffset;
- bitOffset = fieldState.bitOffset;
-
- const pastField = bitOffset + fieldWidth;
- if (style == TargetC.BitFieldStyle.Gcc_Clang)
- {
- auto size = (pastField + 7) / 8;
- fieldState.fieldSize = size;
- //printf(" offset: %d, size: %d\n", offset, size);
- if (isunion)
- {
- const newstructsize = offset + size;
- if (newstructsize > ad.structsize)
- ad.structsize = newstructsize;
- }
- else
- ad.structsize = offset + size;
- }
- else
- fieldState.fieldSize = memsize;
- //printf("at end: ad.structsize = %d\n", cast(int)ad.structsize);
- //print(fieldState);
-
- if (!isunion)
- {
- fieldState.offset = offset + fieldState.fieldSize;
- fieldState.bitOffset = pastField;
- }
-
- //printf("\t%s: offset = %d bitOffset = %d fieldWidth = %d memsize = %d\n", toChars(), offset, bitOffset, fieldWidth, memsize);
- //printf("\t%s: memalignsize = %d\n", toChars(), memalignsize);
- //printf(" addField '%s' to '%s' at offset %d, size = %d\n", toChars(), ad.toChars(), offset, memsize);
- }
}
/***********************************************************