@@ -1964,3 +1964,39 @@ namespace FieldLifetimeNotStarted {
19641964 // both-note {{declared here}} \
19651965 // both-note {{in implicit default constructor for 'FieldLifetimeNotStarted::R' first required here}}
19661966}
1967+
1968+ namespace EmptyRecords {
1969+ struct E1 {} e1 ;
1970+ union E2 {} e2 ; // both-note 4{{here}}
1971+ struct E3 : E1 {} e3 ;
1972+
1973+ template <typename E>
1974+ constexpr int f (E &a, int kind) {
1975+ switch (kind) {
1976+ case 0 : { E e (a); return 0 ; } // both-note {{read}} \
1977+ // both-note {{in call}}
1978+ case 1 : { E e (static_cast <E&&>(a)); return 0 ; } // both-note {{read}} \
1979+ // both-note {{in call}}
1980+ case 2 : { E e; e = a; return 0 ; } // both-note {{read}} \
1981+ // both-note {{in call}}
1982+ case 3 : { E e; e = static_cast <E&&>(a); return 0 ; } // both-note {{read}} \
1983+ // both-note {{in call}}
1984+ }
1985+ }
1986+ constexpr int test1 = f(e1 , 0 );
1987+ constexpr int test2 = f(e2 , 0 ); // both-error {{constant expression}} \
1988+ // both-note {{in call}}
1989+ constexpr int test3 = f(e3 , 0 );
1990+ constexpr int test4 = f(e1 , 1 );
1991+ constexpr int test5 = f(e2 , 1 ); // both-error {{constant expression}} \
1992+ // both-note {{in call}}
1993+ constexpr int test6 = f(e3 , 1 );
1994+ constexpr int test7 = f(e1 , 2 );
1995+ constexpr int test8 = f(e2 , 2 ); // both-error {{constant expression}} \
1996+ // both-note {{in call}}
1997+ constexpr int test9 = f(e3 , 2 );
1998+ constexpr int testa = f(e1 , 3 );
1999+ constexpr int testb = f(e2 , 3 ); // both-error {{constant expression}} \
2000+ // both-note {{in call}}
2001+ constexpr int testc = f(e3 , 3 );
2002+ }
0 commit comments