aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CodeGen.cc1
-rw-r--r--lib/CodeGen/Designator.cc5
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc
index f12c6ce..dcf665a 100644
--- a/lib/CodeGen/CodeGen.cc
+++ b/lib/CodeGen/CodeGen.cc
@@ -215,6 +215,7 @@ const TypeInfo *CodeGen::getExprTypeInfo(ExprAST *Expr) const {
const RecordPayload *RP = Cur->asRecord();
const RecordFieldInfo *FI = RP ? RP->findField(A.FieldName) : nullptr;
if (!FI) return nullptr;
+ if (!FI->IsPublic) return nullptr;
TypeName = FI->TypeName;
} else if (A.Kind == AccessKind::Deref) {
const PointerPayload *PP = Cur->asPointer();
diff --git a/lib/CodeGen/Designator.cc b/lib/CodeGen/Designator.cc
index 640ca0b..9d14d23 100644
--- a/lib/CodeGen/Designator.cc
+++ b/lib/CodeGen/Designator.cc
@@ -145,6 +145,11 @@ bool CodeGen::emitLValue(ExprAST *E, LValueInfo &Out) {
reportError("Record type %s has no field %s", TypeName.c_str(), A.FieldName.c_str());
return false;
}
+ if (!FI->IsPublic) {
+ reportError("Cannot access private field %s of type %s",
+ A.FieldName.c_str(), TypeName.c_str());
+ return false;
+ }
Addr = Builder->CreateStructGEP(Cur->LLVMType, Addr, FI->Index,
TypeName + "." + A.FieldName);
TypeName = FI->TypeName;