Fix a few cases that were incorrectly parsed as unary-expressions
authorRichard Smith <richard@metafoo.co.uk>
Mon, 29 Jun 2020 21:12:14 +0000 (14:12 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Mon, 29 Jun 2020 21:33:21 +0000 (14:33 -0700)
commit4d1b7e9820ee9c87541619ce4dd41e92dc43cd9c
tree846228c085e7e02a937351bc4c163fe0744e635d
parent25055a4fb90292e49f44a0a708390a730cd1116e
Fix a few cases that were incorrectly parsed as unary-expressions
instead of postfix-expressions, and improve error recovery for postfix
operators after unary-expressions.

This covers nullptr, __null, and some calls to type traits with special
parsing rules. We would previously not parse a postfix-expression suffix
for these expressions, so would reject expressions such as
__is_trivial(int)["foo"].

For the case where a postfix-expression suffix is *not* permitted after
a unary-expression (for example, after a new-expression or sizeof
expression), produce a diagnostic if one appears there anyway. That's
always ill-formed, but previously produced very bad diagnostics.
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExpr.cpp
clang/test/Parser/expressions.cpp [new file with mode: 0644]