Skip to content

Commit 6479e3c

Browse files
committed
[clang][Interp] Use proper type for non-primitive reference dummies
1 parent d12c48c commit 6479e3c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

clang/lib/AST/Interp/Program.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ std::optional<unsigned> Program::getOrCreateDummy(const ValueDecl *VD) {
152152
if (std::optional<PrimType> T = Ctx.classify(QT))
153153
Desc = createDescriptor(VD, *T, std::nullopt, true, false);
154154
else
155-
Desc = createDescriptor(VD, VD->getType().getTypePtr(), std::nullopt, true,
156-
false);
155+
Desc = createDescriptor(VD, QT.getTypePtr(), std::nullopt, true, false);
157156
if (!Desc)
158157
Desc = allocateDescriptor(VD);
159158

clang/test/AST/Interp/bitfields.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,24 @@ namespace Compound {
102102
}
103103
static_assert(div() == 1, "");
104104
}
105+
106+
namespace test0 {
107+
extern int int_source();
108+
struct A {
109+
int aField;
110+
int bField;
111+
};
112+
113+
struct B {
114+
int onebit : 2;
115+
int twobit : 6;
116+
int intField;
117+
};
118+
119+
struct C : A, B {
120+
};
121+
122+
void b(C &c) {
123+
c.onebit = int_source();
124+
}
125+
}

0 commit comments

Comments
 (0)