From 3449948b4e56bcb37df4f980c71d907118d7a483 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Nov 2019 16:07:42 +0200 Subject: Require attributes to be separated from words and similar on RHS --- libbuild2/parser.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index be1ba0b..6f4b7c0 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -3582,8 +3582,25 @@ namespace build2 next (t, tt); - if (!standalone && (tt == type::newline || tt == type::eos)) - fail (t) << "standalone attributes"; + if (tt == type::newline || tt == type::eos) + { + if (!standalone) + fail (t) << "standalone attributes"; + } + // + // We require attributes to be separated from the following word or + // "word-producing" tokens (`$` for variable expansions/function calls, + // `(` for eval contexts, and `{` for name generation) to reduce the + // possibility of confusing them with wildcard patterns. Consider: + // + // ./: [abc]-foo.txt + // + else if (!t.separated && (tt == type::word || + tt == type::dollar || + tt == type::lparen || + tt == type::lcbrace)) + fail (t) << "whitespace required after attributes" << + info << "add an empty attribute list if this is a wildcard pattern"; return make_pair (has, l); } -- cgit v1.1