1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
2eff2cd58a897379c7fc46e83447d4619d6f6e9caSeo Sanghyeon
38c4bfe52e528d6c9810cfb0c59859bca9ddc41f0Abramo Bagnaraunion u { int i; unsigned : 3; };
4eff2cd58a897379c7fc46e83447d4619d6f6e9caSeo Sanghyeonvoid f(union u);
5eff2cd58a897379c7fc46e83447d4619d6f6e9caSeo Sanghyeon
6eff2cd58a897379c7fc46e83447d4619d6f6e9caSeo Sanghyeonvoid test(int x) {
780a8eb76a0043271adcfee5cb1e643ce3927fcbfEli Friedman  f((union u)x); // expected-warning {{cast to union type is a GNU extension}}
8eff2cd58a897379c7fc46e83447d4619d6f6e9caSeo Sanghyeon  f((union u)&x); // expected-error {{cast to union type from type 'int *' not present in union}}
98c4bfe52e528d6c9810cfb0c59859bca9ddc41f0Abramo Bagnara  f((union u)2U); // expected-error {{cast to union type from type 'unsigned int' not present in union}}
10eff2cd58a897379c7fc46e83447d4619d6f6e9caSeo Sanghyeon}
116ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopes
1280a8eb76a0043271adcfee5cb1e643ce3927fcbfEli Friedmanunion u w = (union u)2; // expected-warning {{cast to union type is a GNU extension}}
136ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopesunion u ww = (union u)1.0; // expected-error{{cast to union type from type 'double' not present in union}}
1408a41901e18aeb91b87d031b93df70374af02564Douglas Gregorunion u x = 7; // expected-error{{initializing 'union u' with an expression of incompatible type 'int'}}
156ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopesint i;
1680a8eb76a0043271adcfee5cb1e643ce3927fcbfEli Friedmanunion u zz = (union u)i; // expected-error{{initializer element is not a compile-time constant}}  expected-warning {{cast to union type is a GNU extension}}
176ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopes
186ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopesstruct s {int a, b;};
196ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopesstruct s y = { 1, 5 };
206ed2ef8281e44fdd8f002d1cbe11668068d3e530Nuno Lopesstruct s z = (struct s){ 1, 5 };
21