brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · dedc5bd Raw
86 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s2 3// Assignment of function pointers.4 5struct A6{7};8 9struct B1 : A10{11};12 13struct B2 : A14{15};16 17struct D : B1, B218{19};20 21struct P : private A22{23};24 25// Some functions to play with below.26void s1() throw();27void s2() throw(int);28void s3() throw(A);29void s4() throw(B1);30void s5() throw(D);31void s6();32void s7() throw(int, float);33void (*s8())() throw(B1); // s8 returns a pointer to function with spec34void s9(void (*)() throw(B1)); // s9 takes pointer to function with spec35 36void s10() noexcept;37void s11() noexcept(true);38void s12() noexcept(false);39 40void fnptrs()41{42  // Assignment and initialization of function pointers.43  void (*t1)() throw() = &s1;    // valid44  t1 = &s2;                      // expected-error {{not superset}}45  t1 = &s3;                      // expected-error {{not superset}}46  void (&t2)() throw() = s2;     // expected-error {{not superset}}47  void (*t3)() throw(int) = &s2; // valid48  void (*t4)() throw(A) = &s1;   // valid49  t4 = &s3;                      // valid50  t4 = &s4;                      // valid51  t4 = &s5;                      // expected-error {{not superset}}52  void (*t5)() = &s1;            // valid53  t5 = &s2;                      // valid54  t5 = &s6;                      // valid55  t5 = &s7;                      // valid56  t1 = t3;                       // expected-error {{not superset}}57  t3 = t1;                       // valid58  void (*t6)() throw(B1);59  t6 = t4;                       // expected-error {{not superset}}60  t4 = t6;                       // valid61  t5 = t1;                       // valid62  t1 = t5;                       // expected-error {{not superset}}63 64  // return types and arguments must match exactly, no inheritance allowed65  void (*(*t7)())() throw(B1) = &s8;       // valid66  void (*(*t8)())() throw(A) = &s8;        // expected-error {{return types differ}}67  void (*(*t9)())() throw(D) = &s8;        // expected-error {{return types differ}}68  void (*t10)(void (*)() throw(B1)) = &s9; // valid69  void (*t11)(void (*)() throw(A)) = &s9;  // expected-error {{argument types differ}}70  void (*t12)(void (*)() throw(D)) = &s9;  // expected-error {{argument types differ}}71}72 73// Member function stuff74 75struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}}76void Str1::f() // expected-error {{missing exception specification}}77{78}79 80void mfnptr()81{82  void (Str1::*pfn1)() throw(int) = &Str1::f; // valid83  void (Str1::*pfn2)() = &Str1::f; // valid84  void (Str1::*pfn3)() throw() = &Str1::f; // expected-error {{not superset}}85}86