mewmew / uc

A compiler for the µC language.
58 stars 5 forks source link

sematinc: Implement checks for assignment only to lvalue equivalent type #55

Closed sangisos closed 8 years ago

sangisos commented 8 years ago

from test file incorrect/semantic/se25.c:

/* Test file for semantic errors. Contains exactly one error. */

int main (void) {
  (1 + 2) = 3; //No assignment here!
}

Check assignments for lvalue equivalent type, preferably in a future proof manner. In the future, support for array names and dereferenced pointer expressions to be assigned to will be added.

This should perhaps be done before before type checking, as the error messages will make more sense for files like incorrect/semantic/se11.c:

/* Test file for semantic errors. Contains exactly one error. */

int a(void) {
  a = 1;    // 'a' is not an lval
  return 0;
}

int main(void) {
 a();
}

now giving error message: invalid operation: a = 1 (type mismatch between "int(void)" and "int")

sangisos commented 8 years ago

Request for comment @mewmew

mewmew commented 8 years ago

An initial implementation of isAssignment was added in commit 4120fc5af3879a2cb3982ef67f83c0152033e2cc.

Would be happy to discuss this issue in greater detail next time we meet, as it is a non-trivial one.

sangisos commented 8 years ago

Ok, lets have a meeting tomorrow about these decisions.

mewmew commented 8 years ago

Ok, lets have a meeting tomorrow about these decisions.

Wonderful. Meet up at around 14dk?

sangisos commented 8 years ago

Sure, sounds good.

Med Vänliga Hälsningar Alexander Andersson On 29 Apr 2016 02:09, "Robin Eklind" notifications@github.com wrote:

Ok, lets have a meeting tomorrow about these decisions.

Wonderful. Meet up at around 14dk?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/mewmew/uc/issues/55#issuecomment-215598536

mewmew commented 8 years ago

Closing for now. Re-opened in the future to discuss specific issues with the current implementation, or to further validate the implementation against the C specification.