// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-variable-declarations -std=c++17 %s
// Variable declarations that should trigger a warning.
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
// Variable declarations that should not trigger a warning.
static int vgood1;
extern int vgood2;
int vgood2;
static vgood3;
// Functions should never trigger a warning.
void ;
void
static void
// Structures, namespaces and classes should be unaffected.
;
sgood2;
;
int CGood1::MGood1;
;
// There is also no need to use static in anonymous namespaces.
inline int inline_var = 0;
const int const_var = 0;
constexpr int constexpr_var = 0;
inline constexpr int inline_constexpr_var = 0;
extern const int extern_const_var = 0; // expected-warning {{no previous extern declaration}}
// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
extern constexpr int extern_constexpr_var = 0; // expected-warning {{no previous extern declaration}}
// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
int var_template = 0;
constexpr int const_var_template = 0;
static int static_var_template = 0;
int var_template<T*>;
;
int
;
extern ;
int var_template<int>; // expected-warning {{no previous extern declaration}}
// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}
// FIXME: We give this specialization internal linkage rather than inheriting
// the linkage from the template! We should not warn here.
int static_var_template<int>; // expected-warning {{no previous extern declaration}}
// expected-note@-1{{declare 'static' if the variable is not intended to be used outside of this translation unit}}