[all-commits] [llvm/llvm-project] 13ffc6: [C2X] N3007 Type inference for object definitions

Guillot Tony via All-commits all-commits at lists.llvm.org
Thu Oct 5 09:16:22 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 13ffc61a4224012ab1abb4e806d03fc149aec91f
      https://github.com/llvm/llvm-project/commit/13ffc61a4224012ab1abb4e806d03fc149aec91f
  Author: Guillot Tony <tony.guillot at protonmail.com>
  Date:   2023-10-05 (Thu, 05 Oct 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Sema/DeclSpec.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaType.cpp
    A clang/test/C/C2x/n3007.c
    A clang/test/CodeGen/auto.c
    A clang/test/Parser/c2x-auto.c
    A clang/test/Sema/c2x-auto.c
    M clang/www/c_status.html

  Log Message:
  -----------
  [C2X] N3007 Type inference for object definitions

Re-landing 5d78b78c8538 which was reverted.

This patches implements the auto keyword from the N3007 standard
specification.
This allows deducing the type of the variable like in C++:
```
auto nb = 1;
auto chr = 'A';
auto str = "String";
```
The list of statements which allows the usage of auto:

    * Basic variables declarations (int, float, double, char, char*...)
    * Macros declaring a variable with the auto type

The list of statements which will not work with the auto keyword:

    * auto arrays
    * sizeof(), alignas()
    * auto parameters, auto return type
    * auto as a struct/typedef member
    * uninitialized auto variables
    * auto in an union
    * auto as a enum type specifier
    * auto casts
    * auto in an compound literals

Differential Revision: https://reviews.llvm.org/D133289




More information about the All-commits mailing list