From c048102f5bcafb9a316bd7532fe3958c99af6b74 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 5 Dec 2007 10:27:04 +1100 Subject: [PATCH] dtc: Generate useful error message for properties after subnodes 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. Signed-off-by: David Gibson --- dtc-parser.y | 5 +++++ tests/prop-after-subnode.dts | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/prop-after-subnode.dts diff --git a/dtc-parser.y b/dtc-parser.y index 2407af4..43182fd 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -276,6 +276,11 @@ subnodes: { $$ = chain_node($1, $2); } + | subnode propdef + { + yyerror("syntax error: properties must precede subnodes\n"); + YYERROR; + } ; subnode: diff --git a/tests/prop-after-subnode.dts b/tests/prop-after-subnode.dts new file mode 100644 index 0000000..6dd0b66 --- /dev/null +++ b/tests/prop-after-subnode.dts @@ -0,0 +1,9 @@ +/dts-v1/; + +/ { + node1 { + }; + prop; + node2 { + }; +};