Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / dcl.decl / dcl.init / dcl.init.ref / p5.cpp
blob3e8f18c93077e75986f37f455d8275c41f4a3e62
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 namespace PR5909 {
4 struct Foo {
5 int x : 20;
6 };
8 bool Test(const int& foo);
10 const Foo f = { 0 }; // It compiles without the 'const'.
11 bool z = Test(f.x);
14 namespace PR6264 {
15 typedef int (&T)[3];
16 struct S
18 operator T ();
20 void f()
22 T bar = S();
26 namespace PR6066 {
27 struct B { };
28 struct A : B {
29 operator B*();
30 operator B&(); // expected-warning{{conversion function converting 'PR6066::A' to its base class 'PR6066::B' will never be used}}
33 void f(B&); // no rvalues accepted
34 void f(B*);
36 int g() {
37 f(A()); // calls f(B*)
38 return 0;
42 namespace test3 {
43 struct A {
44 unsigned bitX : 4; // expected-note 3 {{bit-field is declared here}}
45 unsigned bitY : 4; // expected-note {{bit-field is declared here}}
46 unsigned var;
48 void foo();
51 void test(A *a) {
52 unsigned &t0 = a->bitX; // expected-error {{non-const reference cannot bind to bit-field 'bitX'}}
53 unsigned &t1 = (unsigned&) a->bitX; // expected-error {{C-style cast from bit-field lvalue to reference type 'unsigned int &'}}
54 unsigned &t2 = const_cast<unsigned&>(a->bitX); // expected-error {{const_cast from bit-field lvalue to reference type 'unsigned int &'}}
55 unsigned &t3 = (a->foo(), a->bitX); // expected-error {{non-const reference cannot bind to bit-field 'bitX'}}
56 unsigned &t4 = (a->var ? a->bitX : a->bitY); // expected-error {{non-const reference cannot bind to bit-field}}
57 unsigned &t5 = (a->var ? a->bitX : a->bitX); // expected-error {{non-const reference cannot bind to bit-field}}
58 unsigned &t6 = (a->var ? a->bitX : a->var); // expected-error {{non-const reference cannot bind to bit-field}}
59 unsigned &t7 = (a->var ? a->var : a->bitY); // expected-error {{non-const reference cannot bind to bit-field}}
60 unsigned &t8 = (a->bitX = 3); // expected-error {{non-const reference cannot bind to bit-field 'bitX'}}
61 unsigned &t9 = (a->bitY += 3); // expected-error {{non-const reference cannot bind to bit-field 'bitY'}}
65 namespace explicit_ctor {
66 struct A {};
67 struct B { // expected-note 2{{candidate}}
68 explicit B(const A&); // expected-note {{explicit constructor is not a candidate}}
70 A a;
71 const B &b(a); // expected-error {{no viable conversion}}