implicit-decl.c 1.4 KB

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