Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: do not allow assignment-expression...



details:   https://anonhg.NetBSD.org/src/rev/c4027161eeac
branches:  trunk
changeset: 953394:c4027161eeac
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 07 20:06:48 2021 +0000

description:
lint: do not allow assignment-expression for constant-expression

It's a funny idea to do something like 'case a = 13:', but since any
compiler will reject this code, there is no point in lint supporting it.

No functional change since everywhere the grammar allows a constant
expression, there is no ambiguity where an assignment could be
interpreted differently.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r debf2ac95d4f -r c4027161eeac usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Mar 07 19:57:46 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Mar 07 20:06:48 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.168 2021/03/07 19:57:46 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.169 2021/03/07 20:06:48 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.168 2021/03/07 19:57:46 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.169 2021/03/07 20:06:48 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1787,8 +1787,8 @@
          }
        ;
 
-constant_expr:
-         expr                          %prec T_COMMA {
+constant_expr:                 /* C99 6.6 */
+         expr                          %prec T_ASSIGN {
                  $$ = $1;
          }
        ;



Home | Main Index | Thread Index | Old Index