[PATCH] D133289: [C2X] N3007 Type inference for object definitions

Guillot Tony via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 27 22:12:12 PDT 2022


to268 updated this revision to Diff 463415.
to268 marked 3 inline comments as done.
to268 added a comment.

I've fixed the diagnostic message and all of the bad TODOs comments from the Sema test.
I've explained in details why i'm only able to handle `auto` in compound literals.

In D133289#3784117 <https://reviews.llvm.org/D133289#3784117>, @aaron.ballman wrote:

> One thought that occurred to me is that the way C has this specified is awfully effectively the same way implicit int worked. It may be worth exploring a change to our implicit int functionality to instead generate an implicit `auto` type when in C2x mode.

That's something is was trying to do a few weeks earlier, so i'll work on that too.

In D133289#3784117 <https://reviews.llvm.org/D133289#3784117>, @aaron.ballman wrote:

> I've been thinking about this more and I'm starting to make myself a bit uncomfortable with the current approach, at least in terms of how we're handling it on the parsing side of things. I think it's reasonable for us to form an `AutoType` when we eventually get down to forming the type. But I'm uncomfortable with not modeling the language when parsing. e.g., I think we want to parse `auto` as a storage class specifier rather than a type specifier, and we want to rely on the lack of a type specifier coupled with use of `auto` as a storage class specifier to determine the situations where we want to infer a type. The resulting semantics should be basically equivalent, but this ensures that we're properly parsing as the language expects which helps us be forwards-compatible with future changes in C that build on top of this being a storage class specifier rather than a type.

I agree, that's a better approach to design it like that, i'll change my approach when i'll be able to generate an implicit `auto`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133289.463415.patch
Type: text/x-patch
Size: 18208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220928/ecede2c0/attachment-0001.bin>


More information about the cfe-commits mailing list