Skip to contentSkip to conversation

dtc: Generate useful error message for properties after subnodes

PATCH Applied David Gibson 2 participants 2 messages Dec 4, 2007 – Dec 5, 2007

lore
Share & tools
lore
#0 lore raw

On several occasions, I've accidentally put properties after subnodes in a dts file. I've then spent ages thinking that the resulting syntax error was because of something else.

This patch arranges for this specific syntax error to generate a more specific and useful error message.

tests/prop-after-subnode.dts new file +9 -0
Index: dtc/tests/prop-after-subnode.dts
===================================================================
@@ -0,0 +1,9 @@
+/dts-v1/;
+
+/ {
+	node1 {
+	};
+	prop;
+	node2 {
+	};
+};
dtc-parser.y +5 -0
Index: dtc/dtc-parser.y
===================================================================
@@ -276,6 +276,11 @@
 		{
 			$$ = chain_node($1, $2);
 		}
+	| subnode propdef
+		{
+			yyerror("syntax error: properties must precede subnodes\n");
+			YYERROR;
+		}
 	;
 
 subnode:
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Applied
#1 lore raw

So, like, the other day David Gibson mumbled:

Quoted 8 lines

On several occasions, I've accidentally put properties after subnodes in a dts file. I've then spent ages thinking that the resulting syntax error was because of something else.

This patch arranges for this specific syntax error to generate a more specific and useful error message.

Applied.

jdl