File tree 4 files changed +39
-1
lines changed
4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11
11
12
12
#include " dmd/aggregate.h"
13
13
#include " dmd/declaration.h"
14
+ #include " dmd/errors.h"
14
15
#include " dmd/expression.h"
15
16
#include " dmd/identifier.h"
16
17
#include " dmd/init.h"
@@ -217,8 +218,12 @@ IrAggr::createInitializerConstant(const VarInitMap &explicitInitializers) {
217
218
218
219
// tail padding?
219
220
const size_t structsize = aggrdecl->size (Loc ());
220
- if (offset < structsize)
221
+ if (offset < structsize) {
221
222
add_zeros (constants, offset, structsize);
223
+ } else if (offset > structsize) {
224
+ error (Loc (), " ICE: IR aggregate constant size exceeds the frontend size" );
225
+ fatal ();
226
+ }
222
227
223
228
// get LL field types
224
229
llvm::SmallVector<llvm::Type *, 16 > types;
Original file line number Diff line number Diff line change 12
12
#include " dmd/aggregate.h"
13
13
#include " dmd/declaration.h"
14
14
#include " dmd/dsymbol.h"
15
+ #include " dmd/errors.h"
15
16
#include " dmd/mtype.h"
16
17
#include " dmd/target.h"
17
18
#include " dmd/template.h"
@@ -98,6 +99,12 @@ IrTypeClass *IrTypeClass::get(ClassDeclaration *cd) {
98
99
isaStruct (t->type )->setBody (builder.defaultTypes (), builder.isPacked ());
99
100
t->varGEPIndices = builder.varGEPIndices ();
100
101
102
+ if (!cd->isInterfaceDeclaration () && instanceSize &&
103
+ getTypeAllocSize (t->type ) != instanceSize) {
104
+ error (cd->loc , " ICE: class IR size does not match the frontend size" );
105
+ fatal ();
106
+ }
107
+
101
108
IF_LOG Logger::cout () << " class type: " << *t->type << std::endl;
102
109
103
110
return t;
Original file line number Diff line number Diff line change 11
11
12
12
#include " dmd/aggregate.h"
13
13
#include " dmd/declaration.h"
14
+ #include " dmd/errors.h"
14
15
#include " dmd/init.h"
15
16
#include " dmd/mtype.h"
16
17
#include " dmd/template.h"
@@ -91,6 +92,11 @@ IrTypeStruct *IrTypeStruct::get(StructDeclaration *sd) {
91
92
builder.addTailPadding (sd->structsize );
92
93
isaStruct (t->type )->setBody (builder.defaultTypes (), builder.isPacked ());
93
94
t->varGEPIndices = builder.varGEPIndices ();
95
+
96
+ if (getTypeAllocSize (t->type ) != sd->structsize ) {
97
+ error (sd->loc , " ICE: struct IR size does not match the frontend size" );
98
+ fatal ();
99
+ }
94
100
}
95
101
96
102
IF_LOG Logger::cout () << " final struct type: " << *t->type << std::endl;
Original file line number Diff line number Diff line change
1
+ // RUN: %ldc -c %s
2
+
3
+ align (1 ) struct Item {
4
+ KV v;
5
+ uint i;
6
+ }
7
+
8
+ struct KV {
9
+ align (1 ) S* s;
10
+ uint k;
11
+ }
12
+
13
+ struct S {
14
+ Table table;
15
+ }
16
+
17
+ struct Table {
18
+ char a;
19
+ Item v;
20
+ }
You can’t perform that action at this time.
0 commit comments