Subject: [PATCH] [Clang 15.0.1] Downgrade implicit int and implicit function
declaration to warning only
The changes in Clang 15.0.0 which enabled these diagnostics as a warning which defaulted to an error caused disruption for people working on distributions such as Gentoo. There was an explicit request to downgrade these to be warning-only in Clang 15.0.1 with the expectation that Clang 16 will default the diagnostics to an error.
See https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213 for more details on the discussion.
- i = also_undeclared(); /* c99untilc2x-error {{call to undeclared function 'also_undeclared'; ISO C99 and later do not support implicit function declarations}}
+ i = also_undeclared(); /* c99untilc2x-warning {{call to undeclared function 'also_undeclared'; ISO C99 and later do not support implicit function declarations}}
c2xandup-error {{use of undeclared identifier 'also_undeclared'}}
- wont_be_found1(); // expected-error{{call to undeclared function 'wont_be_found1'; ISO C99 and later do not support implicit function declarations}} \
- expected-note {{did you mean 'will_be_found1'?}} \
+ wont_be_found1(); // expected-warning{{call to undeclared function 'wont_be_found1'; ISO C99 and later do not support implicit function declarations}}
will_be_found2();
- wont_be_found2(); // expected-error{{call to undeclared function 'wont_be_found2'; ISO C99 and later do not support implicit function declarations}}
+ wont_be_found2(); // expected-warning{{call to undeclared function 'wont_be_found2'; ISO C99 and later do not support implicit function declarations}}
#pragma omp target map(mapper:vv) // expected-error {{expected '(' after 'mapper'}}
{}
-#pragma omp target map(mapper( :vv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}}
+#pragma omp target map(mapper( :vv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-warning {{call to undeclared function 'mapper'}} expected-note {{to match this '('}}
{}
-#pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}}
+#pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-warning {{call to undeclared function 'mapper'}} expected-note {{to match this '('}}
{}
#pragma omp target map(mapper(ab) :vv) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}}
@@ -6,7 +6,7 @@ void f0(); /* expected-warning {{a function declaration without a prototype is d
void f1(int [*]);
void f2(int [const *]);
void f3(int [volatile const*]);
-int f4(*XX)(void); /* expected-error {{cannot return}} expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} */
+int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} */
int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */
char ((((*X))));
@@ -64,9 +64,9 @@ struct xyz test8(void) { return a; } // a should be be marked invalid, no diag.
// Verify that implicit int still works.
-static f; // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
-static g = 4; // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
-static h // expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+static f; // expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+static g = 4; // expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+static h // expected-warning {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
} // expected-error{{expected '__except' or '__finally' block}}
void TEST(void) {
- __except (FilterExpression()) { // expected-error{{call to undeclared function '__except'; ISO C99 and later do not support implicit function declarations}} \
+ __except (FilterExpression()) { // expected-warning{{call to undeclared function '__except'; ISO C99 and later do not support implicit function declarations}} \
// expected-error{{too few arguments to function call, expected 1, have 0}} \
// expected-error{{expected ';' after expression}}
- int n : 1 ? 1 : implicitly_declare_function(); // expected-error {{call to undeclared function 'implicitly_declare_function'; ISO C99 and later do not support implicit function declarations}}
+ int n : 1 ? 1 : implicitly_declare_function(); // expected-warning {{call to undeclared function 'implicitly_declare_function'; ISO C99 and later do not support implicit function declarations}}
- // c-error@-6 {{call to undeclared library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)'); ISO C99 and later do not support implicit function declarations}}
+ // c-warning@-6 {{call to undeclared library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)'); ISO C99 and later do not support implicit function declarations}}
// c-note@-7 {{include the header <setjmp.h> or explicitly provide a declaration for 'setjmp'}}
-__builtin_isinf(...); // expected-error {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{cannot redeclare builtin function '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}
+__builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{cannot redeclare builtin function '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}
- if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-error {{call to undeclared function '_CFCalendarDecomposeAbsoluteTimeV'; ISO C99 and later do not support implicit function declarations}} \
+ if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // werror-error {{call to undeclared function '_CFCalendarDecomposeAbsoluteTimeV'; ISO C99 and later do not support implicit function declarations}} \
+ both-note {{previous implicit declaration}} \
+ expected-warning {{call to undeclared function '_CFCalendarDecomposeAbsoluteTimeV'; ISO C99 and later do not support implicit function declarations}} \
c2x-error {{use of undeclared identifier '_CFCalendarDecomposeAbsoluteTimeV'}}
}
- printg("Hello, World!\n"); // expected-error{{call to undeclared function 'printg'; ISO C99 and later do not support implicit function declarations}} \
- expected-note{{did you mean 'printf'?}} \
+ printg("Hello, World!\n"); // werror-error{{call to undeclared function 'printg'; ISO C99 and later do not support implicit function declarations}} \
+ werror-note{{did you mean 'printf'?}} \
+ expected-warning{{call to undeclared function 'printg'; ISO C99 and later do not support implicit function declarations}} \
c2x-error {{use of undeclared identifier 'printg'; did you mean 'printf'?}}
- __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} \
+ __builtin_is_les(1, 3); // both-error{{use of unknown builtin '__builtin_is_les'}} \
c2x-error {{unknown type name '__builtin_is_les'; did you mean '__builtin_va_list'?}} \
int formats = 0; // c2x-note {{'formats' declared here}}
- formatd("Hello, World!\n"); // expected-error{{call to undeclared function 'formatd'; ISO C99 and later do not support implicit function declarations}} \
- expected-note{{did you mean 'sformatf'?}} \
+ formatd("Hello, World!\n"); // werror-error{{call to undeclared function 'formatd'; ISO C99 and later do not support implicit function declarations}} \
+ werror-note{{did you mean 'sformatf'?}} \
+ expected-warning{{call to undeclared function 'formatd'; ISO C99 and later do not support implicit function declarations}} \
c2x-error {{use of undeclared identifier 'formatd'; did you mean 'formats'?}} \
c2x-error {{called object type 'int' is not a function or function pointer}}
}
void test_suggestion(void) {
- bark(); // expected-error {{call to undeclared function 'bark'; ISO C99 and later do not support implicit function declarations}} \
+ bark(); // werror-error {{call to undeclared function 'bark'; ISO C99 and later do not support implicit function declarations}} \
+ expected-warning {{call to undeclared function 'bark'; ISO C99 and later do not support implicit function declarations}} \
c2x-error {{use of undeclared identifier 'bark'}}
- bork(); // expected-error {{call to undeclared function 'bork'; ISO C99 and later do not support implicit function declarations}} \
+ bork(); // werror-error {{call to undeclared function 'bork'; ISO C99 and later do not support implicit function declarations}} \
+ expected-warning {{call to undeclared function 'bork'; ISO C99 and later do not support implicit function declarations}} \
- (void)_byteswap_ushort(42); // expected-error{{call to undeclared library function '_byteswap_ushort'}} \
+ (void)_byteswap_ushort(42); // expected-warning{{call to undeclared library function '_byteswap_ushort'}} \
// expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_ushort'}}
- (void)_byteswap_uint64(42LL); // expected-error{{call to undeclared library function '_byteswap_uint64'}} \
+ (void)_byteswap_uint64(42LL); // expected-warning{{call to undeclared library function '_byteswap_uint64'}} \
// expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_uint64'}}
}
@@ -21,9 +21,9 @@ void g(void) {
#if defined(__x86_64__)
void h(void) {
- (void)__mulh(21, 2); // expected-error{{call to undeclared library function '__mulh'}} \
+ (void)__mulh(21, 2); // expected-warning{{call to undeclared library function '__mulh'}} \
// expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__mulh'}}
- (void)__umulh(21, 2); // expected-error{{call to undeclared library function '__umulh'}} \
+ (void)__umulh(21, 2); // expected-warning{{call to undeclared library function '__umulh'}} \
// expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__umulh'}}
}
@@ -38,7 +38,7 @@ void i(void) {
#if defined(i386)
void h(void) {
- (void)__mulh(21LL, 2LL); // expected-error{{call to undeclared function '__mulh'; ISO C99 and later do not support implicit function declarations}}
- (void)__umulh(21ULL, 2ULL); // expected-error{{call to undeclared function '__umulh'; ISO C99 and later do not support implicit function declarations}}
+ (void)__mulh(21LL, 2LL); // expected-warning{{call to undeclared function '__mulh'; ISO C99 and later do not support implicit function declarations}}
+ (void)__umulh(21ULL, 2ULL); // expected-warning{{call to undeclared function '__umulh'; ISO C99 and later do not support implicit function declarations}}
// expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
// expected-error {{initializer element is not a compile-time constant}}
@@ -37,7 +37,7 @@ int c11Generic(int arg) {
typedef long long __m128i __attribute__((__vector_size__(16)));
int PR23101(__m128i __x) {
- return foo((__v2di)__x); // expected-error {{call to undeclared function 'foo'; ISO C99 and later do not support implicit function declarations}} \
+ return foo((__v2di)__x); // expected-warning {{call to undeclared function 'foo'; ISO C99 and later do not support implicit function declarations}} \
// expected-error {{use of undeclared identifier '__v2di'}}
int a[ // expected-error {{variable length array in struct}}
- implicitly_declared() // expected-error {{call to undeclared function 'implicitly_declared'; ISO C99 and later do not support implicit function declarations}}
+ implicitly_declared() // expected-warning {{call to undeclared function 'implicitly_declared'; ISO C99 and later do not support implicit function declarations}}
];
};
int (*use_implicitly_declared)(void) = implicitly_declared; // ok, was implicitly declared at file scope
-Class f0(void) { return objc_getClass("a"); } // expected-error {{call to undeclared library function 'objc_getClass' with type 'id (const char *)'}} \
+Class f0(void) { return objc_getClass("a"); } // expected-warning {{call to undeclared library function 'objc_getClass' with type 'id (const char *)'}} \
// expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
// rdar://8735023
-Class f1(void) { return objc_getMetaClass("a"); } // expected-error {{call to undeclared library function 'objc_getMetaClass' with type 'id (const char *)'}} \
+Class f1(void) { return objc_getMetaClass("a"); } // expected-warning {{call to undeclared library function 'objc_getMetaClass' with type 'id (const char *)'}} \
// expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}
-void f2(id val) { objc_enumerationMutation(val); } // expected-error {{call to undeclared library function 'objc_enumerationMutation' with type 'void (id)'}} \
+void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{call to undeclared library function 'objc_enumerationMutation' with type 'void (id)'}} \
// expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_enumerationMutation'}}
-long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-error {{call to undeclared library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
+long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{call to undeclared library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
// expected-note {{include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSend_fpret'}}
id f4(struct objc_super *super, SEL op) { // expected-warning {{declaration of 'struct objc_super' will not be visible outside of this function}}
- return objc_msgSendSuper(super, op); // expected-error {{call to undeclared library function 'objc_msgSendSuper' with type 'id (struct objc_super *, SEL, ...)'}} \
+ return objc_msgSendSuper(super, op); // expected-warning {{call to undeclared library function 'objc_msgSendSuper' with type 'id (struct objc_super *, SEL, ...)'}} \
// expected-note {{include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
}
id f5(id val, id *dest) {
- return objc_assign_strongCast(val, dest); // expected-error {{call to undeclared library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
+ return objc_assign_strongCast(val, dest); // expected-warning {{call to undeclared library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
// expected-note {{include the header <objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
}
int f6(Class exceptionClass, id exception) {
- return objc_exception_match(exceptionClass, exception); // expected-error {{call to undeclared library function 'objc_exception_match' with type 'int (id, id)'}} \
+ return objc_exception_match(exceptionClass, exception); // expected-warning {{call to undeclared library function 'objc_exception_match' with type 'int (id, id)'}} \
// expected-note {{include the header <objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}