[PATCH] D158718: [Clang] Handle ellipsises in abiguous cast expressions.

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 02:05:17 PDT 2023


cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`(T())(foo)` is a cast expression because `T()`
is treated as a type-id, and the expression is valid.

However, `(T())(foo...)` is not a valid cast-expression,
because `(type-id)(foo...)` is invalid.
Yet, it is a valid postfix expression, ie,
`T().operator()(foo...)`

We previously would uncontitionally consider the whole thing
a cast expression and complained about expecting a
right parenthesis after `foo`.

We do keep track of whether we are in a context where the
type-id is ambiguous to keep the existing diagnostics for
the non ambiguous case (ie `(void)(foo...)`).

Fixes #64926


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158718

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/cxx-ambig-paren-expr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158718.553045.patch
Type: text/x-patch
Size: 4962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230824/1748db29/attachment-0001.bin>


More information about the cfe-commits mailing list