1 /* { dg-do compile } */ 2 /* { dg-options "-Wall" } */ 3 4 /* N1312 7.1.1: The FLOAT_CONST_DECIMAL64 pragma. 5 C99 6.4.4.2a (New). 6 7 Pragma STDC FLOAT_CONST_DECIMAL64 "shall occur either outside external 8 declarations or preceding all explicit declarations and statements 9 inside a compound statement." */ 10 11 #pragma STDC FLOAT_CONST_DECIMAL64 OFF 12 13 #define MAX 200 14 15 #pragma STDC FLOAT_CONST_DECIMAL64 ON 16 17 double a; 18 19 #pragma STDC FLOAT_CONST_DECIMAL64 OFF 20 21 struct S1 { 22 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 23 int i; 24 int j; 25 }; 26 27 struct S2 { 28 int i; 29 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 30 int j; 31 }; 32 33 struct S3 { 34 int i; 35 int j; 36 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 37 }; 38 39 enum E1 { 40 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-error "#pragma" } */ 41 one, 42 two 43 }; 44 45 enum E2 { 46 red, 47 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-error "#pragma" } */ 48 blue 49 }; 50 51 enum E3 { 52 cat, 53 dog 54 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-error "#pragma" } */ 55 }; 56 57 double 58 #pragma STDC FLOAT_CONST_DECIMAL64 OFF /* { dg-error "#pragma" } */ 59 b; 60 61 double f1(void)62f1 (void) 63 { 64 #pragma STDC FLOAT_CONST_DECIMAL64 ON 65 return a; 66 } 67 68 double f2(void)69f2 (void) 70 { 71 double b; 72 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 73 b = 0.5; 74 return a + b; 75 } 76 77 #pragma STDC FLOAT_CONST_DECIMAL64 OFF 78 79 double f3(void)80f3 (void) 81 { 82 typedef double b32; 83 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 84 b32 b = 0.5; 85 return b; 86 } 87 88 double f4(int i)89f4 (int i) 90 { 91 top: 92 #pragma STDC FLOAT_CONST_DECIMAL64 OFF /* { dg-warning "invalid location" } */ 93 if (i == 0) 94 return a; 95 a *= 2.; 96 i = 0; 97 goto top; 98 } 99 100 double f5(int i)101f5 (int i) 102 { 103 a = a * i; 104 #pragma STDC FLOAT_CONST_DECIMAL64 OFF /* { dg-warning "invalid location" } */ 105 return a * 2.; 106 } 107 108 double 109 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-error "#pragma" } */ f6(void)110f6 (void) 111 { 112 return a; 113 } 114 115 double f7(void)116f7 117 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-error "#pragma" } */ 118 (void) /* { dg-error "before" } */ 119 { 120 return a; 121 } 122 123 double f8(void)124f8 (void) 125 { 126 { 127 #pragma STDC FLOAT_CONST_DECIMAL64 OFF 128 } 129 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 130 return a; 131 } 132 133 extern void foo9 (void *); 134 135 double f9(void)136f9 (void) 137 { 138 __label__ here; 139 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 140 foo9 (&&here); 141 here: 142 return a; 143 } 144 145 double f10(void)146f10 (void) 147 { 148 void foo10 (void) /* { dg-warning "defined but not used" } */ 149 { 150 a = 1.0; 151 } 152 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 153 return a; 154 } 155 156 double f11(void)157f11 (void) 158 { 159 __extension__ 160 struct A { 161 struct { char a; }; 162 char b; 163 }; 164 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 165 return a; 166 } 167 168 double f12(void)169f12 (void) 170 { 171 __extension__ ({ a = 0.5; }); 172 #pragma STDC FLOAT_CONST_DECIMAL64 ON /* { dg-warning "invalid location" } */ 173 return a; 174 } 175