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