arocc
arocc copied to clipboard
Add `__auto_type` support
you may also declare the type of a variable as __auto_type. In that case, the declaration must declare only one variable, whose declarator must just be an identifier, the declaration must be initialized, and the type of the variable is determined by the initializer; the name of the variable is not in scope until after the initializer.
Examples of errors:
test.c:6:17: error: declaration of variable 'x' with deduced type '__auto_type' requires an initializer
__auto_type x;
^
1 error generated.
➜ ~ gcc test.c
test.c:6:21: error: cannot use __auto_type with initializer list in C
__auto_type x = {1,2};
^
1 error generated.
➜ ~ gcc test.c
test.c:6:18: error: 'x' declared as array of '__auto_type'
__auto_type x[2] = {1,2};
^
1 error generated.
The deduced type when a string literal initializer is used is char *
See bottom of this page: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html