[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / err_reference_bind_drops_quals.cpp
blob42d7e247a96c3e45a9ffdc8204661ec97870ee7a
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #define restrict __restrict__
4 typedef int* ptr;
5 void test1(ptr p, const ptr cp, restrict ptr rp, const restrict ptr crp,
6 volatile ptr vp, const volatile ptr cvp, restrict volatile ptr rvp,
7 const restrict volatile ptr crvp) {
8 ptr& p1 = p;
9 ptr& p2 = cp; // expected-error {{drops 'const' qualifier}}
10 ptr& p3 = rp; // expected-error {{drops '__restrict' qualifier}}
11 ptr& p4 = crp; // expected-error {{drops 'const __restrict' qualifiers}}
12 ptr& p5 = vp; // expected-error {{drops 'volatile' qualifier}}
13 ptr& p6 = cvp; // expected-error {{drops 'const volatile' qualifiers}}
14 ptr& p7 = rvp; // expected-error {{drops 'volatile __restrict' qualifiers}}
15 ptr& p8 = crvp; // expected-error {{drops 'const volatile __restrict' qualifiers}}
17 const ptr& cp1 = p;
18 const ptr& cp2 = cp;
19 const ptr& cp3 = rp; // expected-error {{drops '__restrict' qualifier}}
20 const ptr& cp4 = crp; // expected-error {{drops '__restrict' qualifier}}
21 const ptr& cp5 = vp; // expected-error {{drops 'volatile' qualifier}}
22 const ptr& cp6 = cvp; // expected-error {{drops 'volatile' qualifier}}
23 const ptr& cp7 = rvp; // expected-error {{drops 'volatile __restrict' qualifiers}}
24 const ptr& cp8 = crvp; // expected-error {{drops 'volatile __restrict' qualifiers}}
26 const volatile ptr& cvp1 = p;
27 const volatile ptr& cvp2 = cp;
28 const volatile ptr& cvp3 = rp; // expected-error {{drops '__restrict' qualifier}}
29 const volatile ptr& cvp4 = crp; // expected-error {{drops '__restrict' qualifier}}
30 const volatile ptr& cvp5 = vp;
31 const volatile ptr& cvp6 = cvp;
32 const volatile ptr& cvp7 = rvp; // expected-error {{drops '__restrict' qualifier}}
33 const volatile ptr& cvp8 = crvp; // expected-error {{drops '__restrict' qualifier}}
35 const restrict volatile ptr& crvp1 = p;
36 const restrict volatile ptr& crvp2 = cp;
37 const restrict volatile ptr& crvp3 = rp;
38 const restrict volatile ptr& crvp4 = crp;
39 const restrict volatile ptr& crvp5 = vp;
40 const restrict volatile ptr& crvp6 = cvp;
41 const restrict volatile ptr& crvp7 = rvp;
42 const restrict volatile ptr& crvp8 = crvp;