summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2017-11-20 17:12:18 +0000
committerDavid Gibson <david@gibson.dropbear.id.au>2017-11-21 15:07:14 +1100
commitb260c4f610c004c6e9e36c5f7bbb58d23e605bf1 (patch)
tree0179714525d0f72848d9f8d3dffcb497b9df0714
parentfe667e382bac9326eaea304da2ade5ecb10997d3 (diff)
downloaddevice-tree-compiler-b260c4f610c004c6e9e36c5f7bbb58d23e605bf1.tar.gz
Fix ambiguous grammar for devicetree rule
Commit 737b2df3, "overlay: Add syntactic sugar version of overlays" introduced an empty rule for "devicetree" that created ambiguities in the grammar and causes the following warning: BISON dtc-parser.tab.c dtc-parser.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] Fix the grammar by explicitly testing for the condition the new overlay grammar wants to use. This means duplicating a very small amount of grammar processing code, but the alternative seems to be a more invasive reorganization of the devicetree rule. Better to fix it this way now and save the reorg for a separate patch. Signed-off-by: Grant Likely <grant.likely@arm.com> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--dtc-parser.y17
-rw-r--r--dtc.h2
-rw-r--r--livetree.c3
3 files changed, 14 insertions, 8 deletions
diff --git a/dtc-parser.y b/dtc-parser.y
index affc81a..44af170 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -166,7 +166,17 @@ devicetree:
{
$$ = merge_nodes($1, $3);
}
-
+ | DT_REF nodedef
+ {
+ /*
+ * We rely on the rule being always:
+ * versioninfo plugindecl memreserves devicetree
+ * so $-1 is what we want (plugindecl)
+ */
+ if (!($<flags>-1 & DTSF_PLUGIN))
+ ERROR(&@2, "Label or path %s not found", $1);
+ $$ = add_orphan_node(name_node(build_node(NULL, NULL), ""), $2, $1);
+ }
| devicetree DT_LABEL DT_REF nodedef
{
struct node *target = get_node_by_ref($1, $3);
@@ -209,11 +219,6 @@ devicetree:
$$ = $1;
}
- | /* empty */
- {
- /* build empty node */
- $$ = name_node(build_node(NULL, NULL), "");
- }
;
nodedef:
diff --git a/dtc.h b/dtc.h
index 758eb7c..3b18a42 100644
--- a/dtc.h
+++ b/dtc.h
@@ -204,7 +204,7 @@ struct node *build_node_delete(void);
struct node *name_node(struct node *node, char *name);
struct node *chain_node(struct node *first, struct node *list);
struct node *merge_nodes(struct node *old_node, struct node *new_node);
-void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
+struct node *add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
void add_property(struct node *node, struct property *prop);
void delete_property_by_name(struct node *node, char *name);
diff --git a/livetree.c b/livetree.c
index 457d01e..57b7db2 100644
--- a/livetree.c
+++ b/livetree.c
@@ -216,7 +216,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
return old_node;
}
-void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
+struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
{
static unsigned int next_orphan_fragment = 0;
struct node *node;
@@ -236,6 +236,7 @@ void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
name_node(node, name);
add_child(dt, node);
+ return dt;
}
struct node *chain_node(struct node *first, struct node *list)