This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Handle ellipsises in abiguous cast expressions.
AbandonedPublic

Authored by cor3ntin on Aug 24 2023, 2:05 AM.

Details

Reviewers
aaron.ballman
Summary

(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

Diff Detail

Event Timeline

cor3ntin created this revision.Aug 24 2023, 2:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 2:05 AM
cor3ntin requested review of this revision.Aug 24 2023, 2:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 2:05 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin abandoned this revision.Aug 25 2023, 6:45 AM

As described here, clang is actually conforming, there is an open core issue with unclear resolution and that ""fix"" doesn't cover all the ambiguous use cases
https://github.com/llvm/llvm-project/issues/64926