[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 23 10:23:47 PST 2022


aaron.ballman added a comment.

I spotted some test coverage that I think we should add:

  static_cast<auto>(whatever);
  reinterpret_cast<auto>(whatever);
  const_cast<auto>(whatever);
  dynamic_cast<auto>(whatever);
  (auto)whatever;

I believe all of those should be rejected because of https://eel.is/c++draft/dcl.spec.auto#general-5.sentence-2.

Are there changes needed for the AST printer for this new form of cast notation?

I suppose one other question worth asking: if we're allowing `decltype(auto)(whatever)` as a Clang extension, should we be accepting `__typeof__(auto)(whatever)` as well?



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2396
+def ext_decltype_auto_expr : ExtWarn<
+  "ISO C++23 DIS does not allow functional-style cast to 'decltype(auto)'">,
+  InGroup<DiagGroup<"decltype-auto-cast">>;
----------------
lichray wrote:
> aaron.ballman wrote:
> > Is there a reason this one should be `ExtWarn` instead of `Extension`? (I think we typically only issue this kind of diagnostic when `-pedantic` is specified.)
> I took a look at other warnings. It seems that Clang believes that a portable program can contain `Extension`s; if `ExtWarn` is issued, the program is not likely to be portable.
> 
> I asked GCC folks yesterday to see if they want to implement this extension, and they are not interested. So I guess `ExtWarn` is suitable for now.
Thanks! I think `ExtWarn` is fine based on that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113393



More information about the cfe-commits mailing list