Motivating case: foo bar; is not a declaration of nothing with foo and bar
both types.
This is a common and critical ambiguity, and I expect eliminating it in the
grammar is more efficient than using guards (without caching).
Paths
| Differential D130150
[pseudo] Eliminate multiple-specified-types ambiguities in the grammar. Changes PlannedPublic Authored by sammccall on Jul 20 2022, 12:36 AM.
Details
Summary Motivating case: foo bar; is not a declaration of nothing with foo and bar This is a common and critical ambiguity, and I expect eliminating it in the
Diff Detail
Event TimelineComment Actions I'm not sure that eliminating this in the grammar is the right technique vs guards, appreciate your thoughts. On clangd/AST.cpp, this reduces ambiguities from 1748->1400 (20%). Comment Actions 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 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};.
Revision Contents
Diff 446058 clang-tools-extra/pseudo/lib/cxx/cxx.bnf
clang-tools-extra/pseudo/test/cxx/decl-specifier-seq.cpp
clang-tools-extra/pseudo/test/glr.cpp
|