Skip to content

Commit 3dc6d0e

Browse files
committed
Decay the object expression of member accesses
Fixes #590 Signed-off-by: Roberto Raggi <[email protected]>
1 parent 30eb1aa commit 3dc6d0e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/parser/cxx/type_checker.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,13 @@ auto TypeChecker::Visitor::check_member_access(MemberExpressionAST* ast)
21192119
auto cv1 = strip_cv(objectType);
21202120

21212121
if (ast->accessOp == TokenKind::T_MINUS_GREATER) {
2122+
if (control()->is_class_or_union(ast->baseExpression->type)) {
2123+
// todo: lookup operator-> in the class
2124+
} else {
2125+
(void)ensure_prvalue(ast->baseExpression);
2126+
objectType = ast->baseExpression->type;
2127+
}
2128+
21222129
auto pointerType = type_cast<PointerType>(objectType);
21232130
if (!pointerType) return false;
21242131

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %cxx -verify -fcheck -freport-missing-types %s
2+
3+
struct X {
4+
int a[1];
5+
};
6+
7+
struct S {
8+
struct X x[2];
9+
};
10+
11+
int main() {
12+
struct S s;
13+
return s.x->a[0];
14+
}

0 commit comments

Comments
 (0)