This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: fix location in lvalue error


On 01/05/2011 03:11 PM, Tom Tromey wrote:
While playing with a refactoring hack, I noticed that locations in
lvalue errors are sometimes incorrect.

E.g., consider this file:

int q(int x)
{
   (x + 0) = 5;
   (x + 0)
     = 7;
}

One error is reported against the '=', but the other is not:

opsy. gcc --syntax-only q.c
q.c: In function âqâ:
q.c:3:3: error: lvalue required as left operand of assignment
q.c:5:5: error: lvalue required as left operand of assignment


I think it makes sense to report the error using the '=' token. That is what this patch does. The new output is:

opsy. gcc --syntax-only q.c
q.c: In function âqâ:
q.c:3:11: error: lvalue required as left operand of assignment
q.c:5:5: error: lvalue required as left operand of assignment

Interesting, I would have thought that you changed to


gcc --syntax-only q.c
q.c: In function âqâ:
q.c:3:3: error: lvalue required as left operand of assignment
q.c:4:3: error: lvalue required as left operand of assignment

Since that's where the lvalue is.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]