inline-redef.c 992 B

123456789101112131415161718192021222324
  1. // RUN: %clang_cc1 -std=gnu89 -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -fsyntax-only -verify %s
  3. #if __STDC_VERSION__ >= 199901
  4. #define GNU_INLINE __attribute((__gnu_inline__))
  5. #else
  6. #define GNU_INLINE
  7. #endif
  8. // PR5253
  9. // rdar://9559708 (same extension in C99 mode)
  10. // GNU Extension: check that we can redefine an extern inline function
  11. GNU_INLINE extern inline int f(int a) {return a;}
  12. int f(int b) {return b;} // expected-note{{previous definition is here}}
  13. // And now check that we can't redefine a normal function
  14. int f(int c) {return c;} // expected-error{{redefinition of 'f'}}
  15. // Check that we can redefine an extern inline function as a static function
  16. GNU_INLINE extern inline int g(int a) {return a;}
  17. static int g(int b) {return b;}
  18. // Check that we ensure the types of the two definitions are the same
  19. GNU_INLINE extern inline int h(int a) {return a;} // expected-note{{previous definition is here}}
  20. int h(short b) {return b;} // expected-error{{conflicting types for 'h'}}