1 // RUN: %clang_cc1 %s -verify -fsyntax-only 2 struct xx { int bitf:1; }; 3 4 struct entry { struct xx *whatever; 5 int value; 6 int bitf:1; }; 7 void add_one(int *p) { (*p)++; } 8 9 void test() { 10 register struct entry *p; 11 add_one(&p->value); 12 struct entry pvalue; 13 add_one(&p->bitf); // expected-error {{address of bit-field requested}} 14 add_one(&pvalue.bitf); // expected-error {{address of bit-field requested}} 15 add_one(&p->whatever->bitf); // expected-error {{address of bit-field requested}} 16 } 17 18 void foo() { 19 register int x[10]; 20 &x[10]; // expected-error {{address of register variable requested}} 21 22 register int *y; 23 24 int *x2 = &y; // expected-error {{address of register variable requested}} 25 int *x3 = &y[10]; 26 } 27 28 void testVectorComponentAccess() { 29 typedef float v4sf __attribute__ ((vector_size (16))); 30 static v4sf q; 31 float* r = &q[0]; // expected-error {{address of vector element requested}} 32 } 33 34 typedef __attribute__(( ext_vector_type(4) )) float float4; 35 36 float *testExtVectorComponentAccess(float4 x) { 37 return &x.w; // expected-error {{address of vector element requested}} 38 } 39 40 void f0() { 41 register int *x0; 42 int *_dummy0 = &(*x0); 43 44 register int *x1; 45 int *_dummy1 = &(*(x1 + 1)); 46 } 47 48 // FIXME: The checks for this function are broken; we should error 49 // on promoting a register array to a pointer! (C99 6.3.2.1p3) 50 void f1() { 51 register int x0[10]; 52 int *_dummy00 = x0; // fixme-error {{address of register variable requested}} 53 int *_dummy01 = &(*x0); // fixme-error {{address of register variable requested}} 54 55 register int x1[10]; 56 int *_dummy1 = &(*(x1 + 1)); // fixme-error {{address of register variable requested}} 57 58 register int *x2; 59 int *_dummy2 = &(*(x2 + 1)); 60 61 register int x3[10][10][10]; 62 int (*_dummy3)[10] = &x3[0][0]; // expected-error {{address of register variable requested}} 63 64 register struct { int f0[10]; } x4; 65 int *_dummy4 = &x4.f0[2]; // expected-error {{address of register variable requested}} 66 } 67 68 void f2() { 69 register int *y; 70 71 int *_dummy0 = &y; // expected-error {{address of register variable requested}} 72 int *_dummy1 = &y[10]; 73 } 74 75 void f3() { 76 extern void f4(); 77 void (*_dummy0)() = &****f4; 78 } 79 80 void f4() { 81 register _Complex int x; 82 83 int *_dummy0 = &__real__ x; // expected-error {{address of register variable requested}} 84 } 85 86 void f5() { 87 register int arr[2]; 88 89 /* This is just here because if we happened to support this as an 90 lvalue we would need to give a warning. Note that gcc warns about 91 this as a register before it warns about it as an invalid 92 lvalue. */ 93 int *_dummy0 = &(int*) arr; // expected-error {{cannot take the address of an rvalue}} 94 int *_dummy1 = &(arr + 1); // expected-error {{cannot take the address of an rvalue}} 95 } 96 97 void f6(register int x) { 98 int * dummy0 = &x; // expected-error {{address of register variable requested}} 99 } 100 101 char* f7() { 102 register struct {char* x;} t1 = {"Hello"}; 103 char* dummy1 = &(t1.x[0]); 104 105 struct {int a : 10;} t2; 106 int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}} 107 108 void* t3 = &(*(void*)0); 109 } 110 111 void f8() { 112 void *dummy0 = &f8(); // expected-error {{cannot take the address of an rvalue of type 'void'}} 113 114 extern void v; 115 void *dummy1 = &(1 ? v : f8()); // expected-error {{cannot take the address of an rvalue of type 'void'}} 116 117 void *dummy2 = &(f8(), v); // expected-error {{cannot take the address of an rvalue of type 'void'}} 118 119 void *dummy3 = &({ ; }); // expected-error {{cannot take the address of an rvalue of type 'void'}} 120 } 121