brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 208a0fa Raw
134 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn -Wreturn-type2void f() __attribute__((noreturn));3 4template<typename T> void g(T) {5  f();6}7 8template void g<int>(int);9 10template<typename T> struct A {11  void g() {12    f();13  }14};15 16template struct A<int>;17 18struct B {19  template<typename T> void g(T) {20    f();21  }22};23 24template void B::g<int>(int);25 26// We don't want a warning here.27struct X {28  virtual void g() { f(); }29};30 31namespace test1 {32  bool condition();33 34  // We don't want a warning here.35  void foo() {36    while (condition()) {}37  }38}39 40 41// This test case previously had a false "missing return" warning.42struct R7880658 {43  R7880658 &operator++();44  bool operator==(const R7880658 &) const;45  bool operator!=(const R7880658 &) const;46};47 48void f_R7880658(R7880658 f, R7880658 l) {  // no-warning49  for (; f != l; ++f) {50  }51}52 53namespace test2 {54 55  bool g();56  void *h() __attribute__((noreturn));57  void *j();58 59  struct A {60    void *f;61 62    A() : f(0) { }63    A(int) : f(h()) { } // expected-warning {{function 'A' could be declared with attribute 'noreturn'}}64    A(char) : f(j()) { }65    A(bool b) : f(b ? h() : j()) { }66  };67}68 69namespace test3 {70  struct A {71    ~A();72  };73 74  struct B {75    ~B() { }76 77    A a;78  };79 80  struct C : A { 81    ~C() { }82  };83}84 85// Properly handle CFGs with destructors.86struct rdar8875247 {87  ~rdar8875247 ();88};89void rdar8875247_aux();90 91struct rdar8875247_B {92  rdar8875247_B();93  ~rdar8875247_B();94};95 96rdar8875247_B test_rdar8875247_B() {97  rdar8875247_B f;98  return f;99} // no-warning100 101namespace PR10801 {102  struct Foo {103    void wibble() __attribute((__noreturn__));104  };105 106  struct Bar {107    void wibble();108  };109 110  template <typename T> void thingy(T thing) {111    thing.wibble();112  }113 114  void test() {115    Foo f;116    Bar b;117    thingy(f);118    thingy(b);119  }120}121 122namespace GH63009 {123struct S2 {124  [[noreturn]] ~S2();125};126 127int foo();128 129int test_2() {130  S2 s2;131  foo();132}133}134