
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.
27 lines
947 B
C++
27 lines
947 B
C++
// RUN: %clang_cc1 -verify %s
|
|
// RUN: %clang_cc1 -verify %s -std=c++98
|
|
// RUN: %clang_cc1 -verify %s -std=c++11
|
|
// RUN: %clang_cc1 -verify %s -std=c++1z
|
|
|
|
// PR25946
|
|
// We had an off-by-one error in an assertion when annotating A<int> below. Our
|
|
// error recovery checks if A<int> is a constructor declarator, and opens a
|
|
// TentativeParsingAction. Then we attempt to annotate the token at the exact
|
|
// position that we want to possibly backtrack to, and this used to crash.
|
|
|
|
template <typename T> class A {};
|
|
|
|
// expected-error@+1 {{expected '{' after base class list}}
|
|
template <typename T> class B : T // not ',' or '{'
|
|
#if __cplusplus < 201103L
|
|
// expected-error@+8 {{expected ';' after top level declarator}}
|
|
#endif
|
|
#if __cplusplus <= 201402L
|
|
// expected-error@+5 {{a type specifier is required for all declarations}}
|
|
#else
|
|
// expected-error@+3 {{expected unqualified-id}}
|
|
#endif
|
|
// expected-error@+1 {{expected ';' after class}}
|
|
A<int> {
|
|
};
|