tests/lint: demonstrate bug in chained assignment (since 2021-07-15)

Since cgram.y 1.325 from 2021-07-15, lint has been parsing assignment
expressions correctly.  It got the associativity wrong.
This commit is contained in:
rillig 2021-07-26 17:09:46 +00:00
parent e145d99d7c
commit 036149f3ba
2 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: expr_precedence.c,v 1.3 2021/07/15 17:48:10 rillig Exp $ */
/* $NetBSD: expr_precedence.c,v 1.4 2021/07/26 17:09:46 rillig Exp $ */
# 3 "expr_precedence.c"
/*
@ -36,3 +36,15 @@ void __attribute__((format(printf,
/* Syntactically ok, must be a constant expression though. */
var > 0 ? 2 : 1)))
my_printf(const char *, ...);
void
assignment_associativity(int arg)
{
int left, right;
/* FIXME */
/* expect+1: error: left operand of '=' must be lvalue [114] */
left = right = arg;
left = arg;
}

View File

@ -2,3 +2,4 @@ expr_precedence.c(15): error: syntax error '4' [249]
expr_precedence.c(18): error: non-constant initializer [177]
expr_precedence.c(35): error: 'var' undefined [99]
expr_precedence.c(35): error: syntax error '=' [249]
expr_precedence.c(47): error: left operand of '=' must be lvalue [114]