Allow auto(x) to appear in a parenthesis
expression.
The pattern (auto( can appear as part of a declarator,
so the parser is modified to avoid the ambiguity,
in a way consistent with the proposed resolution to CWG1223.
Paths
| Differential D149276
[Clang] Fix parsing of `(auto(x))`. ClosedPublic Authored by cor3ntin on Apr 26 2023, 11:13 AM.
Details
Summary Allow auto(x) to appear in a parenthesis The pattern (auto( can appear as part of a declarator,
Diff Detail
Event Timeline
aaron.ballman edited reviewers, added: hubert.reinterpretcast, Restricted Project; removed: jdoerfert.Apr 27 2023, 10:51 AM Comment ActionsThe changes generally LGTM, but:
What are the chances that CWG changes their mind and picks a different direction? Comment Actions
CWG acts in mysterious ways, so it's hard to tell. but i think anything else than this resolution could potentially break code?
Comment Actions I see that we do have an issue but so far the examples in the tests don't feel very natural and so I would like to understand if there is a larger motivation here. Comment Actions
The context is that a user realized we fail to implement P0849 https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0849r8.html Comment Actions @aaron.ballman this won;t get approve by core un
They were happy with the direction friday when we looked at it ( not the wording though). I think we should go ahead, waiting until after issaquah might be a bit too late (and if we are claiming auto(x) is implemented we should merge that in 17) Comment Actions
We don't have to wait for the wording to be final so long as the direction is in line with what you've done here, so LGTM! Thank you! This revision is now accepted and ready to land.May 15 2023, 4:48 AM Closed by commit rGef47318ec361: [Clang] Fix parsing of `(auto(x))`. (authored by cor3ntin). · Explain WhyMay 15 2023, 11:14 PM This revision was automatically updated to reflect the committed changes. Comment Actions hi! this seem to have regressed compilation for some valid C++ code: struct Bar { const char *name(); }; struct Baz { static Bar *method(); }; struct Foo { Foo(const char *); }; template <typename T> void bar() { Foo _(T::method()->name()); } void foo() { bar<Baz>(); } compiles fine without this change, starting with this it produces the following error: a.cc:11:55: error: expected unqualified-id template <typename T> void bar() { Foo _(T::method()->name()); } ^ a.cc:11:40: error: no matching constructor for initialization of 'Foo' template <typename T> void bar() { Foo _(T::method()->name()); } ^ a.cc:12:14: note: in instantiation of function template specialization 'bar<Baz>' requested here void foo() { bar<Baz>(); } ^ a.cc:8:3: note: candidate constructor not viable: requires 1 argument, but 0 were provided Foo(const char *); ^ a.cc:7:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided struct Foo { ^ a.cc:7:8: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided https://github.com/llvm/llvm-project/issues/62733 is the bug report that triggered the investigation. cor3ntin added a reverting change: rGd4a6e4c1eec0: Revert "[Clang] Fix parsing of `(auto(x))`.".May 16 2023, 4:56 AM This revision is now accepted and ready to land.May 16 2023, 11:58 PM Comment Actions
This revision was landed with ongoing or failed builds.May 20 2023, 4:23 AM Closed by commit rG1b0ba1c12fcc: [Clang] Fix parsing of `(auto(x))`. (authored by cor3ntin). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 524023 clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Parse/Parser.cpp
clang/test/CXX/drs/dr12xx.cpp
clang/test/Parser/cxx-ambig-decl-expr.cpp
clang/test/Parser/cxx1z-decomposition.cpp
clang/test/Parser/cxx2b-auto-x.cpp
|