mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 19:46:06 +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.
32 lines
1.4 KiB
C++
32 lines
1.4 KiB
C++
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
|
|
|
|
|
|
int foo1(int case, int throw, int y) { // expected-error {{invalid parameter name: 'case' is a keyword}} \
|
|
expected-error {{invalid}}
|
|
// Trailing parameters should be recovered.
|
|
y = 1;
|
|
}
|
|
|
|
int foo2(int case = 1); // expected-error {{invalid parameter}}
|
|
int foo3(int const); // ok: without parameter name.
|
|
// ok: override has special meaning when used after method functions. it can be
|
|
// used as name.
|
|
int foo4(int override);
|
|
int foo5(int x const); // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
// FIXME: bad recovery on the case below, "invalid parameter" is desired, the
|
|
// followon diagnostics should be suppressed.
|
|
int foo6(int case __attribute((weak))); // expected-error {{invalid parameter}} \
|
|
// expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
|
|
void test() {
|
|
// FIXME: we shoud improve the dianostics for the following cases.
|
|
int case; // expected-error {{expected unqualified-id}}
|
|
struct X {
|
|
int case; // expected-error {{expected member name or ';'}}
|
|
};
|
|
}
|
|
struct Foo {
|
|
void bar(*decltype(1) aux); // expected-error {{a type specifier is required for all declarations}}. \
|
|
// expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
};
|