diff options
| author | Jack Palevich <jackpal@google.com> | 2009-09-04 15:34:21 -0700 |
|---|---|---|
| committer | Jack Palevich <jackpal@google.com> | 2009-09-04 15:34:21 -0700 |
| commit | 8fe5dcac3447447bd81501a045560abf1bb9cf98 (patch) | |
| tree | 58b676fa9947ebe70770aaaa14f8089822138ddf | |
| parent | 5fd66ae01e3b4a75307a65d839e4679327f10471 (diff) | |
| download | system_core-8fe5dcac3447447bd81501a045560abf1bb9cf98.tar.gz system_core-8fe5dcac3447447bd81501a045560abf1bb9cf98.tar.bz2 system_core-8fe5dcac3447447bd81501a045560abf1bb9cf98.zip | |
Improve error message for unknown struct members
We now customize the error message to correctly refer to the '.' or
'->' operator , whichever one is actually being used when the error
occurs.
| -rw-r--r-- | libacc/acc.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 7e6dde6a..c52b9922 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -4527,7 +4527,7 @@ class Compiler : public ErrorSink { pGen->forceR0RVal(); Type* pStruct = pGen->getR0Type(); if (pStruct->tag == TY_STRUCT) { - doStructMember(pStruct); + doStructMember(pStruct, true); } else { error("expected a struct value to the left of '.'"); } @@ -4536,7 +4536,7 @@ class Compiler : public ErrorSink { Type* pPtr = pGen->getR0Type(); if (pPtr->tag == TY_POINTER && pPtr->pHead->tag == TY_STRUCT) { pGen->loadR0FromR0(); - doStructMember(pPtr->pHead); + doStructMember(pPtr->pHead, false); } else { 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); if (pStructElement) { next(); @@ -4610,7 +4610,8 @@ class Compiler : public ErrorSink { } else { String buf; 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()); } } |
