Fortran: fix ALLOCATE with SOURCE of deferred character length [PR114019]
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / bitint-5.c
blob2e1b0797ca6178b4b56ca752175ee799459ade35
1 /* PR c/102989 */
2 /* { dg-do run { target bitint } } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
4 /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */
5 /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
7 #if __BITINT_MAXWIDTH__ >= 135
8 struct S135 { unsigned _BitInt(135) c, d; } s135[2];
9 unsigned _BitInt(135) v135;
11 __attribute__((noipa)) void
12 test135 (unsigned _BitInt(135) a, unsigned _BitInt(135) *b, int i, int *j)
14 s135[0].c = a + (b[0] - b[i + 1]) + (b[2] << 7) - (b[3] + 42);
15 s135[i].d = (a | (b[4] & b[5])) ^ b[6 + i];
16 j[0] = s135[1 - i].d == 0;
17 j[1] = b[7] == 41066216447087484049564603714591595841626uwb;
18 if (b[8] != (b[9] << 25))
19 b[10] = -1;
20 v135 = b[11] + 42953568208323086417402824216666875252142uwb;
21 b[12] = ~b[13];
22 b[14] = -b[i + 13];
25 __attribute__((noipa)) void
26 check135 (void)
28 static unsigned _BitInt(135) b[] = {
29 8463654185126215364154304684888703364649uwb,
30 13658636853650784933344312223424772115066uwb,
31 18390507727765446703890200284988625150777uwb,
32 39889350586873865111357164950780819590308uwb,
33 33022475220127125972541408550886872946157uwb,
34 11333291582071369827887273502665555805026uwb,
35 3902203683482045798302423557190uwb,
36 41066216447087484049564603714591595841626uwb,
37 16784965627356370497109555127280042979599uwb,
38 7643716056186238617582842123439581326016uwb,
39 19836147734043931654921333860970539101678uwb,
40 12432610573803574406235637996243202359232uwb,
41 21082105046139319624321070809125021432333uwb,
42 4451745762839330307043673589610uwb,
43 0uwb
45 int j[2];
46 unsigned _BitInt(135) a
47 = 31187320352518101815881924683645645881322uwb;
48 s135[1].d = 11834999377838661704814127001992153922683uwb;
49 test135 (a, b, 0, &j[0]);
50 if (s135[0].c != 31612399059450309097747051855757230322507uwb
51 || s135[0].d != 42086989921663500164906031508060611173292uwb
52 || j[0] != 0
53 || j[1] != 1
54 || v135 != 11830035816246537500326512461643746545006uwb
55 || b[10] != (unsigned _BitInt(135)) -1wb
56 || b[12] != 43556142961428377560472619444222657476757uwb
57 || b[14] != 43556142961428377560472619444222657476758uwb)
58 __builtin_abort ();
59 static unsigned _BitInt(135) c[] = {
60 1551285959809994210151290388254024769929uwb,
61 9215997233892929635003694907344971975862uwb,
62 39194975204437258458997572112485704553492uwb,
63 30855703323230132032090704189294312024903uwb,
64 21369469779496743410402906224964849075932uwb,
65 14841665908022079679702934181971886622844uwb,
66 19630534803796254511661738870561125391241uwb,
67 43019675483091641860333234580998356788381uwb,
68 39970634580048249544562112517644333613056uwb,
69 1191217737795360372798505798508058uwb,
70 37946572714876419093215575675176896482623uwb,
71 4232750244223021640360996638731476646770uwb,
72 4052758609491127849063467754379555742566uwb,
73 39722275064055273051470447567883559006300uwb,
74 0uwb
76 a = 24657112304265243122405775577311943535949uwb;
77 s135[1].d = 0;
78 test135 (a, c, 0, &j[0]);
79 if (s135[0].c != 37693225764587199559589625622735125586095uwb
80 || s135[0].d != 28346681648428908942498835305586873104084uwb
81 || j[0] != 1
82 || j[1] != 0
83 || v135 != 3630175486665984734451871104132020832544uwb
84 || c[10] != 37946572714876419093215575675176896482623uwb
85 || c[12] != 3833867901824850271841502183382772060067uwb
86 || c[14] != 3833867901824850271841502183382772060068uwb)
87 __builtin_abort ();
89 #endif
91 #if __BITINT_MAXWIDTH__ >= 192
92 struct S192 { unsigned _BitInt(192) c, d; } s192[2];
93 unsigned _BitInt(192) v192;
95 __attribute__((noipa)) void
96 test192 (unsigned _BitInt(192) a, unsigned _BitInt(192) *b, int i, int *j)
98 s192[0].c = a + (b[0] - b[i + 1]) + (b[2] << 7) - (b[3] + 42);
99 s192[i].d = (a | (b[4] & b[5])) ^ b[6 + i];
100 j[0] = s192[1 - i].d == (unsigned _BitInt(192)) -1;
101 j[1] = (b[7] - b[6]) == 255187001951392025884741936737034599050205342889367592965uwb;
102 if (b[8] != (b[9] << 25))
103 b[10] = -1;
104 v192 = b[11] + 2163738967454769289750177070635481073128375537642482578981uwb;
105 b[12] = ~b[13];
106 b[14] = -b[i + 13];
109 __attribute__((noipa)) void
110 check192 (void)
112 static unsigned _BitInt(192) b[] = {
113 3228866936540682691868394180939247213045089209876303887643uwb,
114 3908758529346495655434258047388434965374712986050611884354uwb,
115 1851532482363341717513713701170081412289228794495066903175uwb,
116 5975293786133775194483789296663647337052708600272963495919uwb,
117 2820057475559560607299380550839942093606275933232105346229uwb,
118 5362817792426405848910790868188776921236918437924704229050uwb,
119 979877290520863780830672004560233786791511895586353138705uwb,
120 1235064292472255806715413941297268385841717238475720731670uwb,
121 5829209170873343132786365572649959801760991694267006189140uwb,
122 3298265737098071024465207026022448799296008756143231498035uwb,
123 940670103332613157768642186014034108249816638700548072517uwb,
124 2237128221585286673265910175884786455449703050136766895084uwb,
125 5343797638430338971087457378870861887867024738000778783665uwb,
126 2529390643742992876667887597532819348219532837015437654241uwb,
127 0uwb
129 int j[2];
130 unsigned _BitInt(192) a
131 = 2618661874473674031833709426402867675358124955059180091771uwb;
132 s192[1].d = 3240880288967057869631914892069482190385384187140994012855uwb;
133 test192 (a, b, 0, &j[0]);
134 if (s192[0].c != 706870028734637453615201354376795963209926828811195228347uwb
135 || s192[0].d != 2285738979037264170090375369163685923831632419516523901418uwb
136 || j[0] != 0
137 || j[1] != 1
138 || v192 != 4400867189040055963016087246520267528578078587779249474065uwb
139 || b[10] != 6277101735386680763835789423207666416102355444464034512895uwb
140 || b[12] != 3747711091643687887167901825674847067882822607448596858654uwb
141 || b[14] != 3747711091643687887167901825674847067882822607448596858655uwb)
142 __builtin_abort ();
143 static unsigned _BitInt(192) c[] = {
144 5056545299578942817419004982927444283363838129353580295745uwb,
145 3531417693480247808623806953213145420554761387079781845903uwb,
146 344995382910742860278210827312297947555943126346350032667uwb,
147 1665878021517466104406447387862080652541968946313097848513uwb,
148 3702336991937894056852499403052128743722086447309795810459uwb,
149 3047176269106908247893091430981158526415914935872745232818uwb,
150 5837808927599143324365016946161962633699774149391236391641uwb,
151 616230573526655023040079960385747061734409792273035529358uwb,
152 4899745987387470009167824739532983626288828402149586108416uwb,
153 146023809533937871729368708715825784989858520095038uwb,
154 1818078651877174878773673167465776979421635253130676590402uwb,
155 708253875247724856385503140762213862078700660051492170198uwb,
156 1918646725296468312732447651696775312079697668357127231420uwb,
157 3407896467949241097221562008023866460487016701943186636216uwb,
158 0uwb
160 a = 4334425031127766761089651540568319387961460796342206894467uwb;
161 s192[1].d = -1;
162 test192 (a, c, 0, &j[0]);
163 if (s192[0].c != 4413371480577316434238862115941009972672800653387470086858uwb
164 || s192[0].d != 2226914616394806622299956064802345362767073196810043931466uwb
165 || j[0] != 1
166 || j[1] != 0
167 || v192 != 2871992842702494146135680211397694935207076197693974749179uwb
168 || c[10] != 1818078651877174878773673167465776979421635253130676590402uwb
169 || c[12] != 2869205267437439666614227415183799955615338742520847876679uwb
170 || c[14] != 2869205267437439666614227415183799955615338742520847876680uwb)
171 __builtin_abort ();
173 #endif
175 #if __BITINT_MAXWIDTH__ >= 255
176 struct S255 { unsigned _BitInt(255) c, d; } s255[2];
177 unsigned _BitInt(255) v255;
179 __attribute__((noipa)) void
180 test255 (unsigned _BitInt(255) a, unsigned _BitInt(255) *b, int i, int *j)
182 s255[0].c = a + (b[0] - b[i + 1]) + (b[2] << 12) - (b[3] + 42);
183 s255[i].d = (a | (b[4] & b[5])) ^ b[6 + i];
184 j[0] = s255[1 - i].d == 255187001951392025884741936737034599050205342889367592965uwb;
185 j[1] = (b[7] - b[6]) == 35079516404010817908112229771536766101092256322770268596592519563335917296247uwb;
186 if (b[8] != (b[9] << 42))
187 b[10] = -1;
188 v255 = b[11] + 9589198606702369375056479928174941699714421508271337355764754830579779054882uwb;
189 b[12] = ~b[13];
190 b[14] = -b[i + 13];
193 __attribute__((noipa)) void
194 check255 (void)
196 static unsigned _BitInt(255) b[] = {
197 3861714047960214860503769476754636024261469188339866686856553775336008577557uwb,
198 51175255900783946984470019707544472774211315503709121319713624735134204561369uwb,
199 17345603833958095509660462595097262634109622426516669177449315775424443341657uwb,
200 42823701374562019745772585881781652129981403461863690469883912594099541433080uwb,
201 51319674321995616727877469124404951867658380853042706770000900262120757183208uwb,
202 52906636245432908656398520278306560145122955700637871390327152110192649720972uwb,
203 17358815113825560149028333410813032121665286465083593038209986169266901681646uwb,
204 52438331517836378057140563182349798222757542787853861634802505732602818977893uwb,
205 2788004462553513100609800852000190119799062917794460119684836482863393638874uwb,
206 1371934028037182110859712841210549299053627214483532073119322938817156900802uwb,
207 27446425677305660137811201333992510946884519570968084003836788091973600281223uwb,
208 26953886320773144921523720569352939441073773759009802807981124464100414571230uwb,
209 4136701104931368824349366292837727313467036617036788061778000290667287672703uwb,
210 16284209316703094594160217903483772091891615489911326105642136930965810318850uwb,
211 0uwb
213 int j[2];
214 unsigned _BitInt(255) a
215 = 43671209527014657031076032832534182807479171149570250544322965577348390656271uwb;
216 s255[1].d = 255187001951392025884741936737034599050205342889367592965uwb;
217 test255 (a, b, 0, &j[0]);
218 if (s255[0].c != 20576567717160318081578175912662929186060780346948500086480401311222111385641uwb
219 || s255[0].d != 39177534735914878791230670587295539597881897796949856541813587771063479852129uwb
220 || j[0] != 1
221 || j[1] != 1
222 || v255 != 36543084927475514296580200497527881140788195267281140163745879294680193626112uwb
223 || b[10] != 57896044618658097711785492504343953926634992332820282019728792003956564819967uwb
224 || b[12] != 41611835301955003117625274600860181834743376842908955914086655072990754501117uwb
225 || b[14] != 41611835301955003117625274600860181834743376842908955914086655072990754501118uwb)
226 __builtin_abort ();
227 static unsigned _BitInt(255) c[] = {
228 7981769630282326956199854914771456697123750044016665635797085873395082876412uwb,
229 53388853971156757275720047407967538568298021437528793620790412040317130403689uwb,
230 26701828432251973964608431737798795253412436987727543352462415534788835630812uwb,
231 5440780860746561756714149436754163126067503344036226572647314943619048388690uwb,
232 33986332817169953208946609849689345925961381637863140695485139248791268070886uwb,
233 4100939267210968649446715463008507186522717252282546996073651959494281461390uwb,
234 51781097727624204498405281053756240112648760803686514440326944560679935060229uwb,
235 39871871446047940023148355012724181415135167919226806605949531421611900671463uwb,
236 22669501989113495379481452050938385508947296877470428714787872701608093548544uwb,
237 5154447987732395490520832948036146605988346181554886405771838486uwb,
238 22291959629998533921508247788279156576466986919969930954212934913917085206989uwb,
239 1961549937179049997528355604457213261448618818592679790977249627688612403787uwb,
240 41836060567948575115843842705609341074148894754978250388257622994608010108015uwb,
241 21250627322648087754897420116830444064785267321586891615233932456372363316960uwb,
242 0uwb
244 a = 4334425031127766761089651540568319387961460796342206894467uwb;
245 s255[1].d = 41611835301955003117625274600860181834743376842908955914086655072990754501117uwb;
246 test255 (a, c, 0, &j[0]);
247 if (s255[0].c != 12109153275975887113226632923657866254324254170345083268415546710877474684826uwb
248 || s255[0].d != 55850175013735185955402882706756822737483750660992935334535260602616242125954uwb
249 || j[0] != 0
250 || j[1] != 0
251 || v255 != 11550748543881419372584835532632154961163040326864017146742004458268391458669uwb
252 || c[10] != 22291959629998533921508247788279156576466986919969930954212934913917085206989uwb
253 || c[12] != 36645417296010009956888072387513509861849725011233390404494859547584201503007uwb
254 || c[14] != 36645417296010009956888072387513509861849725011233390404494859547584201503008uwb)
255 __builtin_abort ();
257 #endif
259 #if __BITINT_MAXWIDTH__ >= 256
260 struct S256 { unsigned _BitInt(256) c, d; } s256[2];
261 unsigned _BitInt(256) v256;
263 __attribute__((noipa)) void
264 test256 (unsigned _BitInt(256) a, unsigned _BitInt(256) *b, int i, int *j)
266 s256[0].c = a + (b[0] - b[i + 1]) + (b[2] << 15) - (b[3] - 135wb);
267 s256[i].d = (a | (b[4] & b[5])) ^ b[6 + i];
268 j[0] = s256[1 - i].d == 53206656141818470791424256353006269277597513345110510288076840335108990485400uwb;
269 j[1] = (b[7] - b[6]) == 100099038883167575868168369054142100716577408309486879759875338591874183239821uwb;
270 if (b[8] != (b[9] << 63))
271 b[10] = -1;
272 v256 = b[11] + 105302399496355811946682562261964785380738245520086820947909580844925217183297uwb;
273 b[12] = ~b[13];
274 b[14] = -b[i + 13];
277 __attribute__((noipa)) void
278 check256 (void)
280 static unsigned _BitInt(256) b[] = {
281 32009310487117026679674626072407603367594653139936438287667930528262453801915uwb,
282 65176902468824044453790267089157089693737812535360753024943201863160377679656uwb,
283 82344070090465165315955757521075336622529332575448066816076316414765425718982uwb,
284 1700965766421539490938858830624234600098958435316757520284868641071726580981uwb,
285 43634292917714777985622413899887802700784049405471615230478960221105984199159uwb,
286 100631692904819207373422601372327472587552135350288379476708675217470156851657uwb,
287 110129860579524893207321038633598210672223454232798756477691416433717017519769uwb,
288 22023582511300831410026311598353795806875331462942548421790016502461571529072uwb,
289 40138510211986216232290944684699787930583492725766883760868504701674647977984uwb,
290 4351825997216706075548423101456944800498099170105917024323uwb,
291 169752993639582224244050634348149779190985669780902142577260914458554153598uwb,
292 32145284966541819913159374355840318160537667734553997019437196071417771295134uwb,
293 54664388217936175028491213294153178079954834597579823229832063212225827892844uwb,
294 20191860868728322538097431032697551245493230687142770900578302601765403775815uwb,
295 0uwb
297 int j[2];
298 unsigned _BitInt(256) a
299 = 35032284611123531672148181265368654016291603806765316452453041084857012399819uwb;
300 s256[1].d = 18495552704607464237917826961539803493777535452633922395016139213747075459320uwb;
301 test256 (a, b, 0, &j[0]);
302 if (s256[0].c != 63389043283546287594263459568996583234036639501854425943006627750610451754736uwb
303 || s256[0].d != 85940937558229637292496709413287085767649546821453763197795096316568198990162uwb
304 || j[0] != 0
305 || j[1] != 0
306 || v256 != 21655595225581436436270951609117195688005928589000253927889192908429858838495uwb
307 || b[10] != 169752993639582224244050634348149779190985669780902142577260914458554153598uwb
308 || b[12] != 95600228368587872885473553975990356607776753978497793138879281406147725864120uwb
309 || b[14] != 95600228368587872885473553975990356607776753978497793138879281406147725864121uwb)
310 __builtin_abort ();
311 static unsigned _BitInt(256) c[] = {
312 32343204662160194495085563951007642761735079004830363200819846414562640245919uwb,
313 24084137699661809462548106377371635219349193031343667516905836190779613998386uwb,
314 101379688603662938586655900818791548427393428573101695287405037352360497544008uwb,
315 49527008749469396581891560939525147311301744659706134394761856095820111704400uwb,
316 78611633605884634807198913241948438916640856307470257529328762903676002499180uwb,
317 7725329946357185150163578923822973618563365182619444740561512924522337085644uwb,
318 87230734821522736453376619836617027268082314423737558813724810260551555679101uwb,
319 71537684467374116897974003882071220131389738067583874534142564844512609278986uwb,
320 52523168514171623670932664104908233302972408272520282168521737371661091576905uwb,
321 55534995177165851478287456502449363262630885721301994816018615193922251275498uwb,
322 36185028875353330724983116385242607835574307465276274632872421166901316306305uwb,
323 105156498492189914423239302852802412965634513221765962480547101568217183385322uwb,
324 107291868576624602610288559845636897859595852848306710447908839132037475007641uwb,
325 31763533437617266501468240129359520348601211969709950732394000355828663205766uwb,
326 0uwb
328 a = 9837521119254571559208641097198297536765546083418356216057243384350911670458uwb;
329 s256[1].d = 53206656141818470791424256353006269277597513345110510288076840335108990485400uwb;
330 test256 (a, c, 0, &j[0]);
331 if (s256[0].c != 18957614795124660722423653645379624133127098231408367194845756641321108143966uwb
332 || s256[0].d != 96521194298766978603491920349693757511095007817895085416680901426339418123139uwb
333 || j[0] != 1
334 || j[1] != 1
335 || v256 != 94666808751229530946350880106079290493102774076212219388999098405229270928683uwb
336 || c[10] != 115792089237316195423570985008687907853269984665640564039457584007913129639935uwb
337 || c[12] != 84028555799698928922102744879328387504668772695930613307063583652084466434169uwb
338 || c[14] != 84028555799698928922102744879328387504668772695930613307063583652084466434170uwb)
339 __builtin_abort ();
341 #endif
344 main ()
346 #if __BITINT_MAXWIDTH__ >= 135
347 check135 ();
348 #endif
349 #if __BITINT_MAXWIDTH__ >= 192
350 check192 ();
351 #endif
352 #if __BITINT_MAXWIDTH__ >= 255
353 check255 ();
354 #endif
355 #if __BITINT_MAXWIDTH__ >= 256
356 check256 ();
357 #endif
358 return 0;