Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
Sean Hunt | cf34e75 | 2011-05-16 22:41:40 +0000 | [diff] [blame] | 2 | |
| 3 | struct non_trivial { |
| 4 | non_trivial(); |
| 5 | non_trivial(const non_trivial&); |
| 6 | non_trivial& operator = (const non_trivial&); |
| 7 | ~non_trivial(); |
| 8 | }; |
| 9 | |
| 10 | union u { |
| 11 | non_trivial nt; |
| 12 | }; |
| 13 | |
Richard Smith | b9c64d8 | 2012-02-16 20:41:22 +0000 | [diff] [blame] | 14 | union static_data_member { |
| 15 | static int i; |
| 16 | }; |
| 17 | int static_data_member::i; |
| 18 | |
Sean Hunt | cf34e75 | 2011-05-16 22:41:40 +0000 | [diff] [blame] | 19 | union bad { |
Richard Smith | b9c64d8 | 2012-02-16 20:41:22 +0000 | [diff] [blame] | 20 | int &i; // expected-error {{union member 'i' has reference type 'int &'}} |
Sean Hunt | cf34e75 | 2011-05-16 22:41:40 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | struct s { |
| 24 | union { |
| 25 | non_trivial nt; |
| 26 | }; |
| 27 | }; |