[PATCH] D130150: [pseudo] Eliminate multiple-specified-types ambiguities in the grammar.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 20 02:07:17 PDT 2022


sammccall planned changes to this revision.
sammccall added a comment.

As discussed offline:

We agree on the goal of disallowing duplicate types in decl-specifier-seq, but the grammar changes are too intrusive if a guard-based approach can work instead.
The concern with guards on `seq` nodes is duplicate work (a tree walk at every level).
Since ForestNodes are immutable and reasonable in number we can introduce fairly cheap caching, e.g. of whether a decl-specifier[-seq] contains an exclusive type definition. This is a reusable building block for guards etc, so we should build it into the contract.

The other idea I was playing with of guarding `simple-declaration := decl-specifier-seq /*no declarators*/ ;` by requiring the decl-specifier-seq to declare a type (disallow "declaration declares nothing") is inferior as a) the code is technically legal, b) it doesn't address `std::string x;` misparsing as `Type{std} Type{::string} Declarator{x};`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130150/new/

https://reviews.llvm.org/D130150



More information about the cfe-commits mailing list