Aaron Ballman 2cb2cd242c Change the behavior of implicit int diagnostics
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.
2022-05-04 08:35:47 -04:00

55 lines
1.8 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
template<typename T> class vector2 {};
template<typename T> class vector : vector2<T> {};
template<typename T> void Foo2(vector2<const T*> V) {} // expected-note{{candidate template ignored: cannot deduce a type for 'T' that would make 'const T' equal 'int'}}
template<typename T> void Foo(vector<const T*> V) {} // expected-note {{candidate template ignored: cannot deduce a type for 'T' that would make 'const T' equal 'int'}}
void test() {
Foo2(vector2<int*>()); // expected-error{{no matching function for call to 'Foo2'}}
Foo(vector<int*>()); // expected-error{{no matching function for call to 'Foo'}}
}
namespace rdar13267210 {
template < typename T > class A {
BaseTy; // expected-error{{a type specifier is required for all declarations}}
};
template < typename T, int N > class C: A < T > {};
class B {
C<long, 16> ExternalDefinitions;
C<long, 64> &Record;
void AddSourceLocation(A<long> &R); // expected-note{{passing argument to parameter 'R' here}}
void AddTemplateKWAndArgsInfo() {
AddSourceLocation(Record); // expected-error{{non-const lvalue reference to type}}
}
};
}
namespace PR16292 {
class IncompleteClass; // expected-note{{forward declaration}}
class BaseClass {
IncompleteClass Foo; // expected-error{{field has incomplete type}}
};
template<class T> class DerivedClass : public BaseClass {};
void* p = new DerivedClass<void>;
}
namespace rdar14183893 {
class Typ { // expected-note {{not complete}}
Typ x; // expected-error {{incomplete type}}
};
template <unsigned C> class B : Typ {};
typedef B<0> TFP;
class A {
TFP m_p;
void Enable() { 0, A(); } // expected-warning {{left operand of comma operator has no effect}}
};
}