1 // RUN: %clang_cc1 -fsyntax-only -Wdangling-field -verify -std=c++11 %s
12 int &x
, *y
; // expected-note {{reference member declared here}} \
13 // expected-note {{pointer member declared here}}
15 : x(i
), // expected-warning {{binding reference member 'x' to stack allocated parameter 'i'}}
16 y(&i
) {} // expected-warning {{initializing pointer member 'y' with the stack address of parameter 'i'}}
17 S(int &i
) : x(i
), y(&i
) {} // no-warning: reference parameter
18 S(int *i
) : x(*i
), y(i
) {} // no-warning: pointer parameter
22 const X
&x
; // expected-note {{reference member declared here}}
23 S2(int i
) : x(i
) {} // expected-error {{member 'x' binds to a temporary}}
28 S3(Y y
) : x1(y
), x2(y
) {} // no-warning: conversion operator
31 template <typename T
> struct S4
{
32 T x
; // expected-note {{reference member declared here}}
33 S4(int i
) : x(i
) {} // expected-warning {{binding reference member 'x' to stack allocated parameter 'i'}}
36 template struct S4
<int>; // no warning from this instantiation
37 template struct S4
<int&>; // expected-note {{in instantiation}}
40 const X
&x
; // expected-note {{here}}
42 S5 s5
= { 0 }; // ok, lifetime-extended
45 S5 s5
; // expected-note {{here}}
46 S6() : s5
{ 0 } {} // expected-error {{reference subobject of member 's5' binds to a temporary}}
50 S7() : S5
{ 0 } {} // expected-error {{reference member 'x' binds to a temporary}}
55 S8(int *a
) : p(&a
[0]) {}