[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / pointer-forward-declared-class-conversion.cpp
blobaa78be6f5c8f21c7002ae32a601926186efc2249
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 class A1 {};
4 class B1; // expected-note{{'B1' is not defined, but forward declared here; conversion would be valid if it was derived from 'A1'}}
5 B1 *b1;
6 A1 *a1 = b1; // expected-error{{cannot initialize a variable of type 'A1 *' with an lvalue of type 'B1 *'}}
8 template <class C> class A2 {};
9 template <class C> class B2;
10 B2<int> *b2;
11 A2<int> *a2 = b2; // expected-error{{cannot initialize a variable of type 'A2<int> *' with an lvalue of type 'B2<int> *'}}
13 typedef struct S s;
14 const s *f();
15 s *g1() { return f(); } // expected-error{{cannot initialize return object of type 's *' (aka 'S *') with an rvalue of type 'const s *' (aka 'const S *')}}
17 B1 *g2() { return f(); } // expected-error{{cannot initialize return object of type 'B1 *' with an rvalue of type 'const s *' (aka 'const S *')}}