struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2681.c
blob0b6b4e8194b6b349d45feed91f78228f9b3fd5f2
1 /** bug-2681.c
2 A bug which resulted in LLVM-compiled SDCC crashing.
3 */
4 #include <testfwk.h>
6 #include <ctype.h>
7 #include <stdlib.h>
9 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Not enough memory
10 float simplified_atof(const char * s)
12 float value, fraction;
13 signed char iexp;
15 for (value=0.0; isdigit(*s); s++)
17 value=10.0*value+(*s-'0');
20 if (*s == '.')
22 s++;
23 for (fraction=0.1; isdigit(*s); s++)
25 value+=(*s-'0')*fraction;
26 fraction*=0.1;
30 if (toupper(*s)=='E')
32 s++;
33 iexp=(signed char)atoi(s);
35 while(iexp!=0)
37 if(iexp<0)
39 value*=0.1;
40 iexp++;
42 else
44 value*=10.0;
45 iexp--;
51 return (value);
53 #endif
55 void testBug(void)
57 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Not enough memory
58 ASSERT(simplified_atof("0.0f") == 0.0f);
59 #endif