Skip to content

Commit 21af6bd

Browse files
committed
Warn about packed structs
1 parent 0cafd31 commit 21af6bd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

visitor/TreeVisitor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ void TreeVisitor::handleUnion(clang::RecordDecl *record, std::string name) {
122122
void TreeVisitor::handleStruct(clang::RecordDecl *record, std::string name) {
123123
std::string newName = "struct_" + name;
124124

125+
if (record->hasAttr<clang::PackedAttr>()) {
126+
llvm::errs() << "Warning: struct " << name << " is packed. "
127+
<< "Packed structs are not supported by Scala Native. "
128+
<< "Access to fields will not work correctly.\n";
129+
llvm::errs().flush();
130+
}
131+
125132
// Replace "struct x" with struct_x in scala
126133
typeTranslator.AddTranslation("struct " + name, newName);
127134

@@ -148,12 +155,6 @@ void TreeVisitor::handleStruct(clang::RecordDecl *record, std::string name) {
148155
llvm::errs().flush();
149156
}
150157

151-
// llvm::errs() << newName << "\n";
152-
// for(auto& s : cycleDetection.dependencies[newName]){
153-
// llvm::errs() << "\t" << s << "\n";
154-
//}
155-
// llvm::errs() << cycleDetection.isCyclic(newName) << "\n";
156-
157158
ir->addStruct(name, fields,
158159
astContext->getTypeSize(record->getTypeForDecl()));
159160
}

0 commit comments

Comments
 (0)