bison-patches
[Top][All Lists]
Advanced

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

[PATCH 6/7] rule actions cannot be typed


From: Akim Demaille
Subject: [PATCH 6/7] rule actions cannot be typed
Date: Sun, 5 Aug 2018 16:09:58 +0200

Make sure that we cannot apply a type to the (main) action of a rule.

* src/reader.c (grammar_rule_check): Issue the warning.
* tests/input.at (Cannot type action): Check the warning.
---
 src/reader.c   |  5 +++++
 tests/input.at | 22 +++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/reader.c b/src/reader.c
index 7d9e3b06..975f7c8d 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -351,6 +351,11 @@ grammar_rule_check (const symbol_list *r)
       && !r->ruleprec->content->prec)
     complain (&r->location, Wother,
               _("token for %%prec is not defined: %s"), r->ruleprec->tag);
+
+  /* Check that the (main) action was not typed.  */
+  if (r->action_props.type)
+    complain (&r->location, Wother,
+              _("only midrule actions can be typed: %s"), 
r->action_props.type);
 }
 
 
diff --git a/tests/input.at b/tests/input.at
index 44be3942..527c0398 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2193,7 +2193,7 @@ input.y:13.11-21:     previous definition
 
 AT_CLEANUP
 
-##--------------------------- ##
+## -------------------------- ##
 ## Non-deprecated directives. ##
 ## -------------------------- ##
 
@@ -2224,3 +2224,23 @@ AT_BISON_CHECK([[input.y]], [[0]], [[]],
 ]])
 
 AT_CLEANUP
+
+
+## -------------------- ##
+## Cannot type action.  ##
+## -------------------- ##
+
+AT_SETUP([[Cannot type action]])
+
+AT_DATA_GRAMMAR([[input.y]],
+[[%%
+exp: <int> {}
+]])
+
+AT_BISON_CHECK([[-fcaret input.y]], [[0]], [[]],
+[[input.y:10.6-13: warning: only midrule actions can be typed: int [-Wother]
+ exp: <int> {}
+      ^^^^^^^^
+]])
+
+AT_CLEANUP
-- 
2.18.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]