xref: /aosp_15_r20/external/clang/test/Sema/implicit-decl.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -verify -fsyntax-only -Werror
2*67e74705SXin Li 
3*67e74705SXin Li typedef int int32_t;
4*67e74705SXin Li typedef unsigned char Boolean;
5*67e74705SXin Li 
6*67e74705SXin Li extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
7*67e74705SXin Li 
func()8*67e74705SXin Li void func() {
9*67e74705SXin Li    int32_t *vector[16];
10*67e74705SXin Li    const char compDesc[16 + 1];
11*67e74705SXin Li    int32_t compCount = 0;
12*67e74705SXin Li    if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
13*67e74705SXin Li          expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
14*67e74705SXin Li    }
15*67e74705SXin Li 
16*67e74705SXin Li    printg("Hello, World!\n"); // expected-error{{implicit declaration of function 'printg' is invalid in C99}} \
17*67e74705SXin Li                               // expected-note{{did you mean 'printf'?}}
18*67e74705SXin Li 
19*67e74705SXin Li   __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}}
20*67e74705SXin Li }
_CFCalendarDecomposeAbsoluteTimeV(const char * componentDesc,int32_t ** vector,int32_t count)21*67e74705SXin Li Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}}
22*67e74705SXin Li  return 0;
23*67e74705SXin Li }
24*67e74705SXin Li 
25*67e74705SXin Li 
26*67e74705SXin Li // Test the typo-correction callback in Sema::ImplicitlyDefineFunction
27*67e74705SXin Li extern int sformatf(char *str, __const char *__restrict __format, ...); // expected-note{{'sformatf' declared here}}
test_implicit()28*67e74705SXin Li void test_implicit() {
29*67e74705SXin Li   int formats = 0;
30*67e74705SXin Li   formatd("Hello, World!\n"); // expected-error{{implicit declaration of function 'formatd' is invalid in C99}} \
31*67e74705SXin Li                               // expected-note{{did you mean 'sformatf'?}}
32*67e74705SXin Li }
33