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