blob: 37dba8c38218c54e16f50848500e5b0a12c92bfe [file] [log] [blame]
Eli Friedmaneca3ed72011-06-13 23:56:42 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Eli Friedman85a53192009-04-07 19:37:57 +00002
3// Check that we don't allow illegal uses of inline
4inline int a; // expected-error{{'inline' can only appear on functions}}
5typedef inline int b; // expected-error{{'inline' can only appear on functions}}
6int d(inline int a); // expected-error{{'inline' can only appear on functions}}
Jordan Rose106af9e2012-06-15 18:19:48 +00007
8
9// Check the use of static variables in non-static inline functions.
10static int staticVar; // expected-note 2 {{'staticVar' declared here}}
11static int staticFunction(); // expected-note 2 {{'staticFunction' declared here}}
12
13inline int useStatic () { // expected-note 2 {{use 'static' to give inline function 'useStatic' internal linkage}}
14 staticFunction(); // expected-warning{{function 'staticFunction' has internal linkage but is used in an inline function with external linkage}}
15 return staticVar; // expected-warning{{variable 'staticVar' has internal linkage but is used in an inline function with external linkage}}
16}
17
18extern inline int useStaticFromExtern () { // no suggestions
19 staticFunction(); // expected-warning{{function 'staticFunction' has internal linkage but is used in an inline function with external linkage}}
20 return staticVar; // expected-warning{{variable 'staticVar' has internal linkage but is used in an inline function with external linkage}}
21}
22
23static inline int useStaticFromStatic () {
24 staticFunction(); // no-warning
25 return staticVar; // no-warning
26}