rsmith added inline comments.

================
Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1032
+      // the typename-specifier in a function-style cast expression may
+      // be 'auto' since C++2b
       Diag(Tok.getLocation(),
----------------
Quuxplusone wrote:
> rsmith wrote:
> > Nice catch :)
> I see zero hits for `git grep 'decltype[(]auto[^)] clang/`. So it seems this 
> corner of the grammar has been missing any tests for a long time, but I hope 
> this PR will add some.
> ```
> decltype(auto*) i = 42; // should be a syntax error
> decltype(auto(42)) i = 42;  // should be OK 
> decltype(auto()) i = 42;  // should be a syntax error
> ```
> Right now I don't see any tests for this stuff in this PR either. So it needs 
> some.
Some of this is tested in the new file 
test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp (you might need 
to expand it manually; full-page search for `decltype(auto(` might otherwise 
not find it). It looks like we are missing tests for things like 
`decltype(auto*)`. It's not obvious to me what diagnostic would be most useful 
if `decltype(auto` is not followed by `)`, `(`, or `{`, but my guess is that 
"expected `)`" pointing at the `*`, rather than an error on the `auto` token, 
would be the least surprising. So maybe this should be
```
if (Tok.is(tok::kw_auto) && NextToken().isNot(tok::l_paren, tok::l_brace)) {
```
?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113393/new/

https://reviews.llvm.org/D113393

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to