fix for -O gen-C++ dealing with type constants of unnamed compound types

This commit is contained in:
Vern Paxson 2025-05-31 12:49:37 -07:00
parent 224519c11a
commit e165e64fa5
3 changed files with 8 additions and 11 deletions

View file

@ -299,9 +299,12 @@ void FuncConstInfo::InitializerVals(std::vector<std::string>& ivs) const {
}
}
void TypeConstInfo::InitializerVals(std::vector<std::string>& ivs) const {
auto& t = tv->GetType()->AsTypeType()->GetType();
ivs.emplace_back(Fmt(t->Tag()));
TypeConstInfo::TypeConstInfo(CPPCompile* _c, ValPtr v) : CompoundItemInfo(_c, v) {
auto tv = v->AsTypeVal();
auto t = tv->GetType()->AsTypeType()->GetType();
auto gi = c->RegisterType(t);
type = c->TypeOffset(t);
init_cohort = max(init_cohort, gi->InitCohort() + 1);
}
AttrInfo::AttrInfo(CPPCompile* _c, const AttrPtr& attr) : CompoundItemInfo(_c) {

View file

@ -469,12 +469,7 @@ private:
class TypeConstInfo : public CompoundItemInfo {
public:
TypeConstInfo(CPPCompile* _c, ValPtr v) : CompoundItemInfo(_c, v), tv(v->AsTypeVal()) {}
void InitializerVals(std::vector<std::string>& ivs) const override;
private:
TypeVal* tv;
TypeConstInfo(CPPCompile* _c, ValPtr v);
};
// Initialization information for single attributes and sets of attributes.

View file

@ -154,8 +154,7 @@ void CPP_IndexedInits<T>::Generate(InitsManager* im, std::vector<FuncValPtr>& iv
template<class T>
void CPP_IndexedInits<T>::Generate(InitsManager* im, std::vector<TypeValPtr>& ivec, int offset,
ValElemVec& init_vals) const {
auto bt = base_type(static_cast<TypeTag>(init_vals[0]));
auto t = make_intrusive<TypeType>(bt);
auto t = make_intrusive<TypeType>(im->Types(init_vals[0]));
ivec[offset] = make_intrusive<TypeVal>(t);
}