mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 16:37: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.
31 lines
856 B
C++
31 lines
856 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
|
|
|
|
// Ensure that we don't crash if errors are suppressed by an error limit.
|
|
// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit=1 %s
|
|
|
|
error e; // expected-error {{unknown type name}}
|
|
|
|
template <typename>
|
|
class Bar {
|
|
Bar<int> *variables_to_modify;
|
|
foo() { // expected-error {{a type specifier is required for all declarations}}
|
|
for (auto *c : *variables_to_modify)
|
|
delete c;
|
|
}
|
|
};
|
|
|
|
void foo() {
|
|
int a;
|
|
struct X; // expected-note {{forward declaration}}
|
|
for (X x // expected-error {{incomplete type}}
|
|
: a) { // expected-error {{range expression of type 'int'}}
|
|
constexpr int n = sizeof(x);
|
|
}
|
|
|
|
struct S { int x, y; };
|
|
for (S [x, y] // expected-error {{must be 'auto'}}
|
|
: a) { // expected-error {{range expression}}
|
|
typename decltype(x)::a b;
|
|
}
|
|
}
|