[PATCH] D156728: [Sema] Ignore nullability qualifiers when deducing types for `auto` and `__auto_type`

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 18:42:37 PDT 2023


ahatanak added a comment.

I think we still need to do something like what this patch is doing (i.e., drop the nullability qualifiers) when deducing types for `auto` or `__auto_type`, assuming that's the rule we want and we want to restore the previous behavior.

I agree with you that we should make the warning flow sensitive, but I was thinking we could do that later after fixing the type deduction bug.



================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3933
       //   type are ignored for type deduction.
+      // Ignore top level nullability qualifiers too.
       ArgType = ArgType.getUnqualifiedType();
----------------
gribozavr2 wrote:
> This comment merely duplicates the code. Please add an explanation why it is done.
I guess we were dropping the nullability qualifiers for the same reason we drop cv qualifiers. The new variable declared with `auto` is a separate variable, so it doesn't inherit the qualifiers the argument type.

Of course, I'm assuming that's the rule we want, but I'm not sure as nullability qualifiers aren't part of the C/C++ standards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156728



More information about the cfe-commits mailing list