File: symacc.c

package info (click to toggle)
flang 20181226-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 181,072 kB
  • sloc: cpp: 1,182,685; ansic: 598,652; objc: 103,775; f90: 57,054; python: 15,041; fortran: 13,601; lisp: 10,416; perl: 2,460; asm: 2,148; sh: 1,544; awk: 995; cs: 565; xml: 403; lex: 295; makefile: 225; pascal: 130
file content (697 lines) | stat: -rw-r--r-- 17,303 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/*
 * Copyright (c) 1994-2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

/********************************************************
  FIXME: get rid of this "important notice" and proliferating copies.

             I M P O R T A N T   N O T I C E
       Do not modify this file if it resides in the
       directory src -- modify the copy which is in
       ../utils/symtab and then run copy.sh

********************************************************/
/**
   \file
   \brief Generic access module.  Used by all compilers and
   initialization utility.
 */

/* FIXME: This file is compiled with different gbldefs.h included
   depending on in which part of the build it is recompiled. */
#include "symacc.h"
#ifdef UTILSYMTAB
#include "universal.h"
#define ERR_Fatal 4
#else
#include "error.h"
#endif
#include <stdarg.h>

#ifndef STANDARD_MAXIDLEN
#define STANDARD_MAXIDLEN MAXIDLEN
#endif

#ifdef UTILSYMTAB
STB stb;
GBL gbl;
#else
extern STB stb;
extern GBL gbl;
#endif
static char buff[132];

void
sym_init_first(void)
{
  int i;

  int sizeof_SYM = sizeof(SYM) / sizeof(INT);
#if defined(PGHPF)
  assert(sizeof_SYM == 44, "bad SYM size", sizeof_SYM, ERR_Fatal);
#else
  assert(sizeof_SYM == 36, "bad SYM size", sizeof_SYM, ERR_Fatal);
#endif

  if (stb.stg_base == NULL) {
#ifdef UTILSYMTAB
    stb.stg_size = 1000;
    NEW(stb.stg_base, SYM, stb.stg_size);
    BZERO(stb.stg_base, SYM, stb.stg_size);
    stb.stg_avail = 1;
#else
    STG_ALLOC(stb, 1000);
#endif
    assert(stb.stg_base, "sym_init: no room for symtab", stb.stg_size,
           ERR_Fatal);
#if defined(PGHPF) && !defined(PGF90)
    stb.n_size = 7011;
#else
    stb.n_size = 5024;
#endif
    NEW(stb.n_base, char, stb.n_size);
    assert(stb.n_base, "sym_init: no room for namtab", stb.n_size, ERR_Fatal);
    stb.n_base[0] = 0;
#ifdef UTILSYMTAB
    stb.dt.stg_size = 400;
    NEW(stb.dt.stg_base, ISZ_T, stb.dt.stg_size);
#else
    STG_ALLOC(stb.dt, 400);
#endif
    assert(stb.dt.stg_base, "sym_init: no room for dtypes", stb.dt.stg_size,
           ERR_Fatal);
    /* basically, this is sidecar of dt_base */

#ifdef PGCPLUS
    stb.w_size = 1280;
#else
    stb.w_size = 32;
#endif
    NEW(stb.w_base, INT, stb.w_size);
    assert(stb.w_base, "sym_init: no room for wtab", stb.w_size, ERR_Fatal);
  }
  /* allocate  deepcopy info */
#ifndef UTILSYMTAB
#endif

  stb.namavl = 1;
  stb.wrdavl = 0;
  for (i = 0; i <= HASHSIZE; i++)
    stb.hashtb[i] = SPTR_NULL;

#ifndef INIT
#ifdef PGHPF
  DT_INT = DT_INT4;
  DT_REAL = DT_REAL4;
  DT_CMPLX = DT_CMPLX8;
  DT_LOG = DT_LOG4;
  DT_DBLE = DT_REAL8;
  DT_DCMPLX = DT_CMPLX16;
  DT_PTR = DT_INT4;
#endif
#endif
}

/** \brief Expand symbol storage area when NEWSYM runs out of area.

    It is assumed that stb.stg_avail is 1 more than the index of the current
    symbol being created. */
void
realloc_sym_storage()
{
#ifdef UTILSYMTAB
  symini_errfatal(7);
#else
  DEBUG_ASSERT(stb.stg_avail > stb.stg_size,
               "realloc_sym_storage: call only if necessary");
  if (stb.stg_avail > SPTR_MAX + 1 || stb.stg_base == NULL)
    symini_errfatal(7);
  /* Use unsigned arithmetic to avoid risk of overflow. */
  DEBUG_ASSERT(stb.stg_size > 0,
               "realloc_sym_storage: symbol storage not initialized?");
  STG_NEED(stb);
  DEBUG_ASSERT(stb.stg_avail <= stb.stg_size,
               "realloc_sym_storage: internal error");
#endif
}

/**
   \brief Look up symbol with indicated name.
   \return If there is already such a symbol, the pointer to the
   existing symbol table entry; or 0 if a symbol doesn't exist.
   \param name is a symbol name.
   \param olength is the number of characters in the symbol name.
 */
SPTR
lookupsym(const char *name, int olength)
{
  int length;
  SPTR sptr;   /* pointer to symbol table entry */
  INT hashval; /* index into hashtb. */

  /*
   * Loop thru the appropriate hash link list to see if symbol is
   * already in the table:
   */

  length = olength;
  if (length > MAXIDLEN) {
    length = MAXIDLEN;
  }
  HASH_ID(hashval, name, length);
  for (sptr = stb.hashtb[hashval]; sptr != 0; sptr = HASHLKG(sptr)) {
#if defined(PGHPF) && !defined(INIT)
    if (HIDDENG(sptr))
      continue;
#endif
    if (strncmp(name, SYMNAME(sptr), length) != 0 ||
        *(SYMNAME(sptr) + length) != '\0')
      continue;

    /* matching entry has been found in symbol table. return it: */

    return sptr;
  }
  return SPTR_NULL;
} /* lookupsym */

/** \brief Issue diagnostic for identifer that is too long.

    \param name - identifier (without terminating njull)
    \param olength - length of identifier
    \param max_idlen - maximum allowed length

    Though this routine has only one lexical call site, it is factored
    out to not clutter the common path in installsym_ex.
  */
static void
report_too_long_identifier(const char *name, int olength, int max_idlen)
{
  static char *ebuf;
  static int ebuf_sz = 0;
  char len_buf[12];
  if (ebuf_sz == 0) {
    ebuf_sz = olength + 1;
    NEW(ebuf, char, ebuf_sz);
  } else {
    int ii;
    NEED(olength + 1, ebuf, char, ebuf_sz, olength + 1);
    ii = strlen(ebuf);
    if (ii < olength)
      strcpy(ebuf + (ii - 2), "..."); /* there's room for at least 1 '.'*/
  }
  memcpy(ebuf, name, olength);
  ebuf[olength] = '\0';
  sprintf(len_buf, "%d", max_idlen);
  symini_error(16, 2, gbl.lineno, ebuf, len_buf);
}

/**
   \brief Get the symbol table index for a NUL-terminated name.
 */
SPTR
lookupsymbol(const char *name)
{
  return lookupsym(name, strlen(name));
}

/**
   \brief Construct a name via printf-style formatting and then
   look it up in the symbol table via lookupsymbol().
 */
SPTR
lookupsymf(const char *fmt, ...)
{
  char buffer[MAXIDLEN + 1];
  va_list ap;
  va_start(ap, fmt);
  vsnprintf(buffer, sizeof buffer - 1, fmt, ap);
  va_end(ap);
  buffer[sizeof buffer - 1] = '\0'; /* Windows workaround */
  return lookupsymbol(buffer);
}

/**
   \brief Enter symbol with indicated name into symbol table,
   initialize the new entry, and return pointer to it.  If there is
   already such a symbol, just return pointer to the existing symbol
   table entry.

   \param name is the symbol name.
   \param olength is the number of characters in the symbol name.
 */
SPTR
installsym_ex(const char *name, int olength, IS_MODE mode)
{
  int length;
  SPTR sptr;   /* pointer to symbol table entry */
  INT hashval; /* index into hashtb. */
  bool toolong;
  int nmptr;
  static int max_idlen = MAXIDLEN;

  /*
   * Trim identifier if it is too long.
   */
  toolong = false;
  length = olength;
#if !defined(PGHPF) && defined(PGFTN) && !defined(UTILSYMTAB)
  if (flg.standard) {
    max_idlen = 31;
  }
#elif defined(PGF90) && !defined(UTILSYMTAB)
  if (flg.standard) {
    max_idlen = STANDARD_MAXIDLEN;
  }
#endif
  if (length > max_idlen) {
    length = max_idlen;
    toolong = true;
  }

  nmptr = 0;
  if (mode != IS_QUICK) {
    /*
     * Loop thru the appropriate hash link list to see if symbol is
     * already in the table.
     */
    HASH_ID(hashval, name, length);
    for (sptr = stb.hashtb[hashval]; sptr != 0; sptr = HASHLKG(sptr)) {
      const char *sname;
      int np = NMPTRG(sptr);
      if (np + length >= stb.namavl)
        continue;
      sname = stb.n_base + np;
      if (sname[0] != name[0] || sname[length] != '\0')
        continue;
      if (strncmp(name, sname, length) != 0)
        continue;
      nmptr = np;
#if defined(PGHPF) && !defined(INIT)
      if (HIDDENG(sptr))
        continue;
#endif

      /* Matching entry has been found in symbol table. Return it. */

      return sptr;
    }
  }

  /* Symbol not found.  Create a new symbol table entry. */

  NEWSYM(sptr);
  if (mode != IS_QUICK) {
    LINKSYM(sptr, hashval);
  }

  if (!nmptr)
    nmptr = putsname(name, length);
  NMPTRP(sptr, nmptr);
#if defined(PGFTN) && !defined(INIT)
  SYMLKP(sptr, NOSYM);
#endif
#if defined(PGHPF) && !defined(INIT)
  SCOPEP(sptr, 0);
#endif
#ifdef LINENOP
  LINENOP(sptr, gbl.lineno);
#endif

  if (toolong) {
    report_too_long_identifier(name, olength, max_idlen);
  }

  return sptr;
}

/**
   \brief Put a string of characters into the symbol names storage
   area and return pointer to the string (relative to
   stb.n_base). This routine is used to enter both symbol names and
   character string constants.

   \param name are the characters to be entered.
   \param length is the number of characters to be entered.
 */
int
putsname(const char *name, int length)
{
  int nptr; /* index into character storage area */
  char *np; /* pointer into character storage area */
  int i;    /* counter */

  nptr = stb.namavl;
  stb.namavl += (length + 1);
  while (stb.namavl > stb.n_size) {
    /* To avoid quadratic behavior, we increase the storage area size
       by a factor, not a constant.  Use unsigned arithmetic here
       to avoid risk of overflow. */
    unsigned n = 2u * stb.n_size;
    if (n > MAX_NMPTR) {
      n = MAX_NMPTR;
      if (stb.namavl > n)
        symini_errfatal(7); /* names table overflow */
    }
    NEED(stb.namavl, stb.n_base, char, stb.n_size, n);
  }
  np = stb.n_base + nptr;
  for (i = 0; i < length; i++)
    *np++ = *name++;
  *np = '\0';

  return nptr;
}

/**
   \brief Create a local copy of a name known to be stored in the 'stb.n_base'
   area.

   Used when a symbol needs to be created from a name stored in the
   area; a purify umr error could occur if the area is realloc'd.  The
   char pointer to the copy is returned.
 */
char *
local_sname(char *name)
{
  static char *safe_p;
  static int safe_sz = 0;
  int length;

  length = strlen(name) + 2 + 6; /* MW: add one more character,
                                    needed in semfunc2 */
  /* Hongyon: add 6 more for
     _cr and _nm for cref,nomixed */
  if (safe_sz == 0) {
    safe_sz = length + 100;
    NEW(safe_p, char, safe_sz);
  } else {
    NEED(length, safe_p, char, safe_sz, length + 100);
  }

  strcpy(safe_p, name);

  return safe_p;
}

#if !defined(UTILSYMTAB)
void
add_fp_constants(void)
{
  INT tmp[4];
  INT res[4];

  tmp[0] = 0;
#if defined(PGHPF) || defined(PGF90) || defined(PGFTN)
  atoxf("0.0", &tmp[1], 3);
#ifdef DT_REAL4
  /***** Only the f90/hpf front-ends know aobut the sized-real *****/
  /*
   * NOTE (A REMINDER):
   * 1. the order in which the following constants are created can
   *    never changed -- their sptr numbers as well what they denote
   *    is asseumed by the modfile processing.
   * 2. additional predefined constants CANNOT be added unless
   *    we propagate how many more to symtab.c:can_map_initsym() and
   *    symtab.c:map_initsym().
   *    For now, just create them, such as stb.fltm0 and stb.dblm0,
   *    in symtab.c after symtab.c:sym_init() defines stb.firstosym
   */

  stb.flt0 = getcon(tmp, DT_REAL4);
  atoxf("1.0", &tmp[1], 3);
  stb.flt1 = getcon(tmp, DT_REAL4);
  atoxf("2.0", &tmp[1], 3);
  stb.flt2 = getcon(tmp, DT_REAL4);
  atoxf("0.5", &tmp[1], 3);
  stb.flthalf = getcon(tmp, DT_REAL4);

  atoxd("0.0", &tmp[0], 3);
  stb.dbl0 = getcon(tmp, DT_REAL8);
  atoxd("1.0", &tmp[0], 3);
  stb.dbl1 = getcon(tmp, DT_REAL8);
  atoxd("2.0", &tmp[0], 3);
  stb.dbl2 = getcon(tmp, DT_REAL8);
  atoxd("0.5", &tmp[0], 3);
  stb.dblhalf = getcon(tmp, DT_REAL8);

#else
  /***** the f90 backend *****/
  stb.flt0 = getcon(tmp, DT_REAL);
  atoxf("1.0", &tmp[1], 3);
  stb.flt1 = getcon(tmp, DT_REAL);
  atoxf("2.0", &tmp[1], 3);
  stb.flt2 = getcon(tmp, DT_REAL);
  atoxf("0.5", &tmp[1], 3);
  stb.flthalf = getcon(tmp, DT_REAL);

  atoxd("0.0", &tmp[0], 3);
  stb.dbl0 = getcon(tmp, DT_DBLE);
  atoxd("1.0", &tmp[0], 3);
  stb.dbl1 = getcon(tmp, DT_DBLE);
  atoxd("2.0", &tmp[0], 3);
  stb.dbl2 = getcon(tmp, DT_DBLE);
  atoxd("0.5", &tmp[0], 3);
  stb.dblhalf = getcon(tmp, DT_DBLE);

  tmp[0] = 0;
  res[0] = 0;
  tmp[1] = CONVAL2G(stb.flt0);
  xfneg(tmp[1], &res[1]);
  stb.fltm0 = getcon(res, DT_REAL);
  tmp[0] = CONVAL1G(stb.dbl0);
  tmp[1] = CONVAL2G(stb.dbl0);
  xdneg(tmp, res);
  stb.dblm0 = getcon(res, DT_DBLE);
#endif

#else
  /***** the pgcpp backend & pgc *****/
  /* float 0, 1, 2, .5, -0.0 */
  atoxf("0.0", &tmp[1], 3);
  stb.flt0 = getcon(tmp, DT_FLOAT);
  atoxf("1.0", &tmp[1], 3);
  stb.flt1 = getcon(tmp, DT_FLOAT);
  atoxf("2.0", &tmp[1], 3);
  stb.flt2 = getcon(tmp, DT_FLOAT);
  atoxf("0.5", &tmp[1], 3);
  stb.flthalf = getcon(tmp, DT_FLOAT);

  /* 1.0, 2.0, 0.5, -0.0  as double, quad */
  atoxd("0.0", &tmp[0], 3);
  stb.dbl0 = getcon(tmp, DT_DBLE);
  stb.quad0 = getcon(tmp, DT_QUAD); /* quad currently the same as double */
  atoxd("1.0", &tmp[0], 3);
  stb.dbl1 = getcon(tmp, DT_DBLE);
  stb.quad1 = getcon(tmp, DT_QUAD); /* quad currently the same as double */
  atoxd("2.0", &tmp[0], 3);
  stb.dbl2 = getcon(tmp, DT_DBLE);
  stb.quad2 = getcon(tmp, DT_QUAD); /* quad currently the same as double */
  atoxd("0.5", &tmp[0], 3);
  stb.dblhalf = getcon(tmp, DT_DBLE);
  stb.quadhalf = getcon(tmp, DT_QUAD); /* quad currently the same as double */

  tmp[0] = 0;
  res[0] = 0;
  tmp[1] = CONVAL2G(stb.flt0);
  xfneg(tmp[1], &res[1]);
  stb.fltm0 = getcon(res, DT_FLOAT);
  tmp[0] = CONVAL1G(stb.dbl0);
  tmp[1] = CONVAL2G(stb.dbl0);
  xdneg(tmp, res);
  stb.dblm0 = getcon(res, DT_DBLE);
  stb.quadm0 = getcon(res, DT_QUAD); /* quad currently the same as double */
#endif

#ifdef LONG_DOUBLE_X87
  atoxe("0.0", tmp, 3);
  stb.x87_0 = getcon(tmp, DT_X87);
  xeneg(tmp, res);
  stb.x87_m0 = getcon(res, DT_X87);
  atoxe("1.0", tmp, 3);
  stb.x87_1 = getcon(tmp, DT_X87);
  atoxe("2.0", tmp, 3);
  stb.x87_2 = getcon(tmp, DT_X87);
#endif
#ifdef DOUBLE_DOUBLE
  tmp[0] = stb.dbl0;
  tmp[1] = stb.dbl0;
  stb.doubledouble_0 = getcon(tmp, DT_DOUBLEDOUBLE);
  tmp[0] = stb.dblm0;
  tmp[1] = stb.dblm0;
  stb.doubledouble_m0 = getcon(tmp, DT_DOUBLEDOUBLE);
  tmp[0] = stb.dbl1;
  tmp[1] = stb.dbl0;
  stb.doubledouble_1 = getcon(tmp, DT_DOUBLEDOUBLE);
#endif
#ifdef LONG_DOUBLE_FLOAT128
  atoxq("0.0", &tmp[0], 4);
  stb.float128_0 = getcon(tmp, DT_FLOAT128);
  xqneg(tmp, res);
  stb.float128_m0 = getcon(res, DT_FLOAT128);
  atoxq("1.0", &tmp[0], 4);
  stb.float128_1 = getcon(tmp, DT_FLOAT128);
  atoxq("0.5", &tmp[0], 4);
  stb.float128_half = getcon(tmp, DT_FLOAT128);
  atoxq("2.0", &tmp[0], 4);
  stb.float128_2 = getcon(tmp, DT_FLOAT128);
#endif
}

bool
is_flt0(SPTR sptr)
{
  if (sptr == stb.flt0 || sptr == stb.fltm0)
    return true;
  return false;
}

bool
is_dbl0(SPTR sptr)
{
  if (sptr == stb.dbl0 || sptr == stb.dblm0)
    return true;
  return false;
}

bool
is_quad0(SPTR sptr)
{
  if (sptr == stb.quad0 || sptr == stb.quadm0)
    return true;
  return false;
}

#ifdef LONG_DOUBLE_X87
bool
is_x87_0(SPTR sptr)
{
  return sptr == stb.x87_0 || sptr == stb.x87_m0;
}

bool
is_cmplx_x87_0(SPTR sptr)
{
  if (is_x87_0(CONVAL1G(sptr)) && is_x87_0(CONVAL2G(sptr)))
    return true;
  return false;
}
#endif /* LONG_DOUBLE_X87 */

#ifdef DOUBLE_DOUBLE
bool
is_doubledouble_0(SPTR sptr)
{
  return sptr == stb.doubledouble_0 || sptr == stb.doubledouble_m0;
}

bool
is_cmplx_doubledouble_0(SPTR sptr)
{
  return is_doubledouble_0(CONVAL1G(sptr)) && is_doubledouble_0(CONVAL2G(sptr));
}
#endif /* DOUBLE_DOUBLE */

#ifdef LONG_DOUBLE_FLOAT128
bool
is_float128_0(SPTR sptr)
{
  return sptr == stb.float128_0 || sptr == stb.float128_m0;
}
#endif /* LONG_DOUBLE_FLOAT128 */

bool
is_cmplx_flt0(SPTR sptr)
{
  if (CONVAL1G(sptr) == CONVAL2G(stb.flt0) ||
      CONVAL1G(sptr) == CONVAL2G(stb.fltm0)) {
    if (CONVAL2G(sptr) == CONVAL2G(stb.flt0) ||
        CONVAL2G(sptr) == CONVAL2G(stb.fltm0)) {
      return true;
    }
  }
  return false;
}

bool
is_creal_flt0(SPTR sptr)
{
  if (CONVAL1G(sptr) == CONVAL2G(stb.flt0) ||
      CONVAL1G(sptr) == CONVAL2G(stb.fltm0))
    return true;
  return false;
}

bool
is_cimag_flt0(SPTR sptr)
{
  if (CONVAL2G(sptr) == CONVAL2G(stb.flt0) ||
      CONVAL2G(sptr) == CONVAL2G(stb.fltm0))
    return true;
  return false;
}

bool
is_cmplx_dbl0(SPTR sptr)
{
  return is_dbl0(SymConval1(sptr)) && is_dbl0(SymConval2(sptr));
}

bool
is_cmplx_quad0(SPTR sptr)
{
  return is_quad0(SymConval1(sptr)) && is_quad0(SymConval2(sptr));
}

#endif

void
symini_errfatal(int n)
{
#ifdef UTILSYMTAB
  sprintf(buff, "Fatal error number %d", n);
  symini_error(n, 4, gbl.lineno, CNULL, CNULL);
#else
  errfatal((error_code_t)n);
#endif
}

void
symini_error(int n, int s, int l, const char *c1, const char *c2)
{
#ifdef UTILSYMTAB
  if (c1 == NULL)
    c1 = "";
  if (c2 == NULL)
    c2 = "";
  sprintf(buff, "Error number %d, line %d, params %s %s\n", n, l, c1, c2);
  fputs(buff, stderr);
  if (s == 4)
    exit(1);
#else
  error((error_code_t)n, (enum error_severity)s, l, c1, c2);
#endif
}

void
symini_interr(const char *txt, int val, int sev)
{
  char buff[8];

  sprintf(buff, "%7d", val);
  symini_error(0, sev, gbl.lineno, txt, buff);
}