mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 21:06:05 +00:00

C89 allowed a type specifier to be elided with the resulting type being int, aka implicit int behavior. This feature was subsequently removed in C99 without a deprecation period, so implementations continued to support the feature. Now, as with implicit function declarations, is a good time to reevaluate the need for this support. This patch allows -Wimplicit-int to issue warnings in C89 mode (off by default), defaults the warning to an error in C99 through C17, and disables support for the feature entirely in C2x. It also removes a warning about missing declaration specifiers that really was just an implicit int warning in disguise and other minor related cleanups.
44 lines
2.1 KiB
C
44 lines
2.1 KiB
C
/* RUN: %clang_cc1 -fsyntax-only -std=c89 -Wimplicit-int %s -verify -Wno-strict-prototypes
|
|
RUN: %clang_cc1 -fsyntax-only -std=c99 %s -verify=ext -Wno-strict-prototypes
|
|
RUN: %clang_cc1 -fsyntax-only -std=c2x %s -verify=unsupported
|
|
*/
|
|
|
|
foo(void) { /* expected-warning {{type specifier missing, defaults to 'int'}} \
|
|
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
|
|
unsupported-error {{a type specifier is required for all declarations}} */
|
|
return 0;
|
|
}
|
|
|
|
y; /* expected-warning {{type specifier missing, defaults to 'int'}} \
|
|
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
|
|
unsupported-error {{a type specifier is required for all declarations}} */
|
|
|
|
/* rdar://6131634 */
|
|
void f((x)); /* expected-warning {{type specifier missing, defaults to 'int'}} \
|
|
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
|
|
unsupported-error {{a type specifier is required for all declarations}} */
|
|
|
|
/* PR3702 */
|
|
#define PAD(ms10) { \
|
|
register i; \
|
|
}
|
|
|
|
#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
|
|
|
|
void
|
|
h19_insline(n) /* ext-error {{parameter 'n' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \
|
|
unsupported-error {{unknown type name 'n'}} */
|
|
{
|
|
ILPAD(); /* expected-warning {{type specifier missing, defaults to 'int'}} \
|
|
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
|
|
unsupported-error {{a type specifier is required for all declarations}} */
|
|
|
|
}
|
|
|
|
struct foo {
|
|
__extension__ __attribute__((packed)) x : 4; /* expected-warning {{type specifier missing, defaults to 'int'}} \
|
|
ext-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
|
|
unsupported-error {{unknown type name 'x'}} */
|
|
|
|
};
|