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

Guillot Tony via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 08:06:32 PDT 2023


to268 added inline comments.


================
Comment at: clang/test/Sema/c2x-auto.c:119
+  return x;
+}
----------------
aaron.ballman wrote:
> aaron.ballman wrote:
> > Some additional test cases to consider:
> > ```
> > _Complex auto i = 12.0; // Should be rejected because _Complex is a type specifier; however, 
> >                         // when auto becomes a type specifier, this should be accepted. GCC
> >                         // rejects but if we end up accepting, I won't be sad -- we'll need an
> >                         // extension warning in that case though.
> > 
> > void foo(void) {
> >   extern void foo(int a, int array[({ auto x = 12; x;})]); // This is a use of `auto` within function prototype
> >                                                            // scope, but should still be accepted.
> > }
> > ```
> The suggested comment I have isn't fully correct. It should be rejected because _Complex is a type specifier, but when auto becomes a type specifier, I think _Complex perhaps should still not deduce. Consider this analogous case (which could be a fun test case as well):
> ```
> signed auto a = 1L;
> ```
> `signed` is a type specifier as well, and this is not accepted in C++ (so we don't want to accept it in C either).
> ```
> void foo(void) {
>   extern void foo(int a, int array[({ auto x = 12; x;})]); // This is a use of `auto` within function prototype
>                                                            // scope, but should still be accepted.
> }
> ```

I think you made a mistake there by using the same function name as the outer one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289



More information about the cfe-commits mailing list