Clang Project

clang_source_code/test/SemaCXX/inline.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -Wc++98-c++11-c++14-compat
4
5// Check that we don't allow illegal uses of inline
6// (checking C++-only constructs here)
7struct c {inline int a;}; // expected-error{{'inline' can only appear on functions}}
8
9void localVar() {
10  inline int a; // expected-error{{inline declaration of 'a' not allowed in block scope}}
11}
12
13// Check that we warn appropriately.
14#if __cplusplus <= 201402L
15inline int a; // expected-warning{{inline variables are a C++17 extension}}
16#else
17inline int a; // expected-warning{{inline variables are incompatible with C++ standards before C++17}}
18#endif
19