Sun Jul 11 19:01:37 2021 UTC ()
lint: fix shift/reduce conflict for dangling else

The following line no longer occurs in the yacc output:
257: shift/reduce conflict (shift 427, reduce 270) on T_ELSE

No functional change.


(rillig)
diff -r1.311 -r1.312 src/usr.bin/xlint/lint1/cgram.y

cvs diff -r1.311 -r1.312 src/usr.bin/xlint/lint1/cgram.y (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/cgram.y 2021/07/11 18:22:02 1.311
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/11 19:01:37 1.312
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.311 2021/07/11 18:22:02 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.312 2021/07/11 19:01:37 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.311 2021/07/11 18:22:02 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.312 2021/07/11 19:01:37 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -124,7 +124,7 @@
 
 %}
 
-%expect 168
+%expect 167
 
 %union {
 	val_t	*y_val;
@@ -257,6 +257,8 @@
 %token			T_AT_WARN_UNUSED_RESULT
 %token			T_AT_WEAK
 
+%left	T_THEN
+%left	T_ELSE
 %left	T_COMMA
 %right	T_ASSIGN T_OPASSIGN
 %right	T_QUEST T_COLON
@@ -1486,7 +1488,7 @@
 	;
 
 selection_statement:		/* C99 6.8.4 */
-	  if_without_else {
+	  if_without_else %prec T_THEN {
 		save_warning_flags();
 		if2();
 		if3(false);