File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -3080,12 +3080,22 @@ bool ByteCodeExprGen<Emitter>::visitDecl(const VarDecl *VD) {
3080
3080
}
3081
3081
}
3082
3082
3083
- // Return the value
3084
- if (VarT)
3085
- return this ->emitRet (*VarT, VD);
3086
-
3087
- // Return non-primitive values as pointers here.
3088
- return this ->emitRet (PT_Ptr, VD);
3083
+ // Return the value.
3084
+ if (!this ->emitRet (VarT.value_or (PT_Ptr), VD)) {
3085
+ // If the Ret above failed and this is a global variable, mark it as
3086
+ // uninitialized, even everything else succeeded.
3087
+ if (Context::shouldBeGloballyIndexed (VD)) {
3088
+ auto GlobalIndex = P.getGlobal (VD);
3089
+ assert (GlobalIndex);
3090
+ Block *GlobalBlock = P.getGlobal (*GlobalIndex);
3091
+ InlineDescriptor &ID =
3092
+ *reinterpret_cast <InlineDescriptor *>(GlobalBlock->rawData ());
3093
+ ID.IsInitialized = false ;
3094
+ GlobalBlock->invokeDtor ();
3095
+ }
3096
+ return false ;
3097
+ }
3098
+ return true ;
3089
3099
}
3090
3100
3091
3101
template <class Emitter >
You can’t perform that action at this time.
0 commit comments