Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure special struct TypeInfo members are semantically analyzed before emitting the TypeInfo #3783

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gen/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ void DtoDeclareFunction(FuncDeclaration *fdecl, const bool willDefine) {
Logger::println("Function is inside a linkonce_odr template, will be "
"defined after declaration.");
if (fdecl->semanticRun < PASSsemantic3done) {
// this can e.g. happen for special __xtoHash member functions
Logger::println("Function hasn't had sema3 run yet, running it now.");
const bool semaSuccess = fdecl->functionSemantic3();
(void)semaSuccess;
Expand Down
13 changes: 10 additions & 3 deletions ir/irstruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ LLConstant *IrStruct::getTypeInfoInit() {
IF_LOG Logger::println("Defining TypeInfo for struct: %s", sd->toChars());
LOG_SCOPE;

// we need (dummy) TypeInfos for opaque structs too
const bool isOpaque = !sd->members;

// make sure xtoHash/xopEquals/xopCmp etc. are semantically analyzed
if (!isOpaque && sd->semanticRun < PASSsemantic3done) {
Logger::println(
"Struct hasn't had semantic3 yet, calling semanticTypeInfoMembers()");
sd->semanticTypeInfoMembers();
}

TypeStruct *ts = sd->type->isTypeStruct();

// check declaration in object.d
Expand Down Expand Up @@ -108,9 +118,6 @@ LLConstant *IrStruct::getTypeInfoInit() {

RTTIBuilder b(structTypeInfoType);

// we need (dummy) TypeInfos for opaque structs too
const bool isOpaque = !sd->members;

// string name
if (isOpaque) {
b.push_null_void_array();
Expand Down