void t1() {
extern int& a;
int b = a;
}
void t2(int& a) {
int b = a;
}
int g;
int& gr = g;
int& grr = gr;
void t3() {
int b = gr;
}
struct C { int a; };
void f(const bool&);
void f(const int&);
void f(const _Complex int&);
void f(const C&);
C aggregate_return();
bool& bool_reference_return();
int& int_reference_return();
_Complex int& complex_int_reference_return();
C& aggregate_reference_return();
void test_bool() {
bool a = true;
f(a);
f(true);
bool_reference_return() = true;
a = bool_reference_return();
struct { const bool& b; } b = { true };
}
void test_scalar() {
int a = 10;
f(a);
struct { int bitfield : 3; } s = { 3 };
f(s.bitfield);
f(10);
__attribute((vector_size(16))) typedef int vec4;
f((vec4){1,2,3,4}[0]);
int_reference_return() = 10;
a = int_reference_return();
struct { const int& a; } agg = { 10 };
}
void test_complex() {
_Complex int a = 10i;
f(a);
f(10i);
complex_int_reference_return() = 10i;
a = complex_int_reference_return();
struct { const _Complex int &a; } agg = { 10i };
}
void test_aggregate() {
C c;
f(c);
f(aggregate_return());
aggregate_reference_return().a = 10;
c = aggregate_reference_return();
struct { const C& a; } agg = { C() };
}
int& reference_return() {
return g;
}
int reference_decl() {
int& a = g;
const int& b = 1;
return a+b;
}
struct A {
int& b();
};
void f(A* a) {
int b = a->b();
}
void *foo = 0;
void * const & kFoo = foo;
struct D : C { D(); ~D(); };
void h() {
const C& c = D();
}
namespace T {
struct A {
A();
~A();
};
struct B {
B();
~B();
A f();
};
void f() {
const A& a = B().f();
f();
}
}
namespace PR5227 {
void f(int &a) {
(a = 10) = 20;
}
}
struct s0;
struct s1 { struct s0 &s0; };
void f0(s1 a) { s1 b = a; }
const int &f2() { return 0; }
namespace N1 {
const int foo = 1;
void test(const int& arg = foo) {
const int* const args_array[] = { &arg };
}
}
namespace N2 {
class X {
public:
X(const X&);
X &operator=(const X&);
~X();
};
struct P {
X first;
};
P getP();
void f(int i) {
const X& xr = getP().first;
i = 17;
}
struct SpaceWaster {
int i, j;
};
struct ReallyHasX {
X x;
};
struct HasX : ReallyHasX { };
struct HasXContainer {
HasX has;
};
struct Y : SpaceWaster, HasXContainer { };
struct Z : SpaceWaster, Y { };
Z getZ();
void g(int i) {
const X &xr = getZ().has.x;
i = 19;
}
}
namespace N3 {
struct A {
explicit A(int);
~A();
};
const A &sA123 = A(123);
}
namespace N4 {
struct A {
A();
~A();
};
void f() {
static const A& ar = A();
}
}
namespace N5 {
struct AnyS { bool b; };
void f(const bool&);
AnyS g();
void h() {
f(g().b);
}
}
namespace PR9565 {
struct a { int a : 10, b : 10; };
void f() {
a x = { 0, 0 };
x.a = 17;
const int &y = x.a;
x.b = 19;
}
}
namespace N6 {
extern struct x {char& x;}y;
int a() { return y.x; }
}