1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
test0()3 void test0() {
4 char variable = (void)0;
5 // expected-error@-1{{cannot initialize a variable}}
6 }
7
test1(int x=(void)0)8 void test1(int x = (void)0) {}
9 // expected-error@-1{{cannot initialize a parameter}}
10 // expected-note@-2{{here}}
11
test2()12 int test2() {
13 return (void)0;
14 // expected-error@-1{{cannot initialize return object}}
15 }
16
17 struct S4 {
S4S418 S4() : x((void)0) {};
19 // expected-error@-1{{cannot initialize a member subobject}}
20 int x;
21 };
22
test5()23 void test5() {
24 int foo[2] = {1, (void)0};
25 // expected-error@-1{{cannot initialize an array element}}
26 }
27
test6()28 void test6() {
29 new int((void)0);
30 // expected-error@-1{{cannot initialize a new value}}
31 }
32
33 typedef short short2 __attribute__ ((__vector_size__ (2)));
test10()34 void test10() {
35 short2 V = { (void)0 };
36 // expected-error@-1{{cannot initialize a vector element}}
37 }
38
39 typedef float float2 __attribute__((ext_vector_type(2)));
40 typedef float float4 __attribute__((ext_vector_type(4)));
41
test14(const float2 in,const float2 out)42 void test14(const float2 in, const float2 out) {
43 const float4 V = (float4){ in, out };
44 // expected-error@-1{{cannot initialize a compound literal initializer}}
45 }
46
47 namespace template_test {
48 class S {
49 public:
50 void foo(int);
51 };
52
53 template <class P> struct S2 {
54 void (P::*a)(const int &);
55 };
56
test_15()57 void test_15() {
58 S2<S> X = {&S::foo};
59 // expected-error-re@-1{{cannot initialize a member subobject of type 'void (template_test::S::*)(const int &){{( __attribute__\(\(thiscall\)\))?}}' with an rvalue of type 'void (template_test::S::*)(int){{( __attribute__\(\(thiscall\)\))?}}': type mismatch at 1st parameter ('const int &' vs 'int')}}
60 }
61 }
62