Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / warn-missing-prototypes.cpp
blob2880514ee02b7b4c539dfb7f2ff370301957ba29
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-prototypes -std=c++11 %s
2 // RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
4 void f() { } // expected-warning {{no previous prototype for function 'f'}}
5 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
6 // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:1-[[@LINE-2]]:1}:"static "
8 namespace NS {
9 void f() { } // expected-warning {{no previous prototype for function 'f'}}
10 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
13 namespace {
14 // Don't warn about functions in anonymous namespaces.
15 void f() { }
16 // Even if they're in nested namespaces within an anonymous namespace.
17 namespace NS {
18 void f() { }
22 struct A {
23 // Don't warn about member functions.
24 void f() { }
27 // Don't warn about inline functions.
28 inline void g() { }
30 // Don't warn about function templates.
31 template<typename> void h() { }
33 // Don't warn when instantiating function templates.
34 template void h<int>();
36 // PR9519: don't warn about friend functions.
37 class I {
38 friend void I_friend() {}
41 // Don't warn on explicitly deleted functions.
42 void j() = delete;
44 extern void k() {} // expected-warning {{no previous prototype for function 'k'}}
45 // expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
46 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
48 namespace {
49 struct anon { };
52 // No warning because this has internal linkage despite not being declared
53 // explicitly 'static', owing to the internal linkage parameter.
54 void l(anon) {
57 void *operator new(decltype(sizeof(3)) size, const anon &) throw() {
58 return nullptr;