Merge change 24034 into eclair

* changes:
  Improve error message for unknown struct members
This commit is contained in:
Android (Google) Code Review 2009-09-04 15:35:58 -07:00
commit dfd31ee899

View file

@ -4527,7 +4527,7 @@ class Compiler : public ErrorSink {
pGen->forceR0RVal(); pGen->forceR0RVal();
Type* pStruct = pGen->getR0Type(); Type* pStruct = pGen->getR0Type();
if (pStruct->tag == TY_STRUCT) { if (pStruct->tag == TY_STRUCT) {
doStructMember(pStruct); doStructMember(pStruct, true);
} else { } else {
error("expected a struct value to the left of '.'"); error("expected a struct value to the left of '.'");
} }
@ -4536,7 +4536,7 @@ class Compiler : public ErrorSink {
Type* pPtr = pGen->getR0Type(); Type* pPtr = pGen->getR0Type();
if (pPtr->tag == TY_POINTER && pPtr->pHead->tag == TY_STRUCT) { if (pPtr->tag == TY_POINTER && pPtr->pHead->tag == TY_STRUCT) {
pGen->loadR0FromR0(); pGen->loadR0FromR0();
doStructMember(pPtr->pHead); doStructMember(pPtr->pHead, false);
} else { } else {
error("Expected a pointer to a struct to the left of '->'"); error("Expected a pointer to a struct to the left of '->'");
} }
@ -4602,7 +4602,7 @@ class Compiler : public ErrorSink {
} }
} }
void doStructMember(Type* pStruct) { void doStructMember(Type* pStruct, bool isDot) {
Type* pStructElement = lookupStructMember(pStruct, tok); Type* pStructElement = lookupStructMember(pStruct, tok);
if (pStructElement) { if (pStructElement) {
next(); next();
@ -4610,7 +4610,8 @@ class Compiler : public ErrorSink {
} else { } else {
String buf; String buf;
decodeToken(buf, tok, true); decodeToken(buf, tok, true);
error("Expected a struct member to the right of '.', got %s", buf.getUnwrapped()); error("Expected a struct member to the right of '%s', got %s",
isDot ? "." : "->", buf.getUnwrapped());
} }
} }