* sh.c (prepare_move_operand): Check if operand 0 is an invalid
[official-gcc.git] / gcc / f / intdoc.c
blob0ad83e4428ecaf34cf74a9a1145b4d9366791d66
1 /* intdoc.c
2 Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by James Craig Burley.
5 This file is part of GNU Fortran.
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 /* From f/proj.h, which uses #error -- not all C compilers
23 support that, and we want *this* program to be compilable
24 by pretty much any C compiler. */
25 #include "bconfig.h"
26 #include "system.h"
27 #include "coretypes.h"
28 #include "tm.h"
29 #include "assert.h"
31 /* Pull in the intrinsics info, but only the doc parts. */
32 #define FFEINTRIN_DOC 1
33 #include "intrin.h"
35 const char *family_name (ffeintrinFamily family);
36 static void dumpif (ffeintrinFamily fam);
37 static void dumpendif (void);
38 static void dumpclearif (void);
39 static void dumpem (void);
40 static void dumpgen (int menu, const char *name, const char *name_uc,
41 ffeintrinGen gen);
42 static void dumpspec (int menu, const char *name, const char *name_uc,
43 ffeintrinSpec spec);
44 static void dumpimp (int menu, const char *name, const char *name_uc, size_t genno, ffeintrinFamily family,
45 ffeintrinImp imp, ffeintrinSpec spec);
46 static const char *argument_info_ptr (ffeintrinImp imp, int argno);
47 static const char *argument_info_string (ffeintrinImp imp, int argno);
48 static const char *argument_name_ptr (ffeintrinImp imp, int argno);
49 static const char *argument_name_string (ffeintrinImp imp, int argno);
50 #if 0
51 static const char *elaborate_if_complex (ffeintrinImp imp, int argno);
52 static const char *elaborate_if_maybe_complex (ffeintrinImp imp, int argno);
53 static const char *elaborate_if_real (ffeintrinImp imp, int argno);
54 #endif
55 static void print_type_string (const char *c);
57 int
58 main (int argc, char **argv ATTRIBUTE_UNUSED)
60 if (argc != 1)
62 fprintf (stderr, "\
63 Usage: intdoc > intdoc.texi\n\
64 Collects and dumps documentation on g77 intrinsics\n\
65 to the file named intdoc.texi.\n");
66 exit (1);
69 dumpem ();
70 return 0;
73 struct _ffeintrin_name_
75 const char *const name_uc;
76 const char *const name_lc;
77 const char *const name_ic;
78 const ffeintrinGen generic;
79 const ffeintrinSpec specific;
82 struct _ffeintrin_gen_
84 const char *const name; /* Name as seen in program. */
85 const ffeintrinSpec specs[2];
88 struct _ffeintrin_spec_
90 const char *const name; /* Uppercase name as seen in source code,
91 lowercase if no source name, "none" if no
92 name at all (NONE case). */
93 const bool is_actualarg; /* Ok to pass as actual arg if -pedantic. */
94 const ffeintrinFamily family;
95 const ffeintrinImp implementation;
98 struct _ffeintrin_imp_
100 const char *const name; /* Name of implementation. */
101 const char *const control;
104 static const struct _ffeintrin_name_ names[] = {
105 #define DEFNAME(UPPER,LOWER,MIXED,GEN,SPEC) \
106 { UPPER, LOWER, MIXED, FFEINTRIN_ ## GEN, FFEINTRIN_ ## SPEC },
107 #define DEFGEN(CODE,NAME,SPEC1,SPEC2)
108 #define DEFSPEC(CODE,NAME,CALLABLE,FAMILY,IMP)
109 #define DEFIMP(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL)
110 #define DEFIMPY(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL,Y2KBAD)
111 #include "intrin.def"
112 #undef DEFNAME
113 #undef DEFGEN
114 #undef DEFSPEC
115 #undef DEFIMP
116 #undef DEFIMPY
119 static const struct _ffeintrin_gen_ gens[] = {
120 #define DEFNAME(UPPER,LOWER,MIXED,GEN,SPEC)
121 #define DEFGEN(CODE,NAME,SPEC1,SPEC2) \
122 { NAME, { SPEC1, SPEC2, }, },
123 #define DEFSPEC(CODE,NAME,CALLABLE,FAMILY,IMP)
124 #define DEFIMP(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL)
125 #define DEFIMPY(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL,Y2KBAD)
126 #include "intrin.def"
127 #undef DEFNAME
128 #undef DEFGEN
129 #undef DEFSPEC
130 #undef DEFIMP
131 #undef DEFIMPY
134 static const struct _ffeintrin_imp_ imps[] = {
135 #define DEFNAME(UPPER,LOWER,MIXED,GEN,SPEC)
136 #define DEFGEN(CODE,NAME,SPEC1,SPEC2)
137 #define DEFSPEC(CODE,NAME,CALLABLE,FAMILY,IMP)
138 #define DEFIMP(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL) \
139 { NAME, CONTROL },
140 #define DEFIMPY(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL,Y2KBAD) \
141 { NAME, CONTROL },
142 #include "intrin.def"
143 #undef DEFNAME
144 #undef DEFGEN
145 #undef DEFSPEC
146 #undef DEFIMP
147 #undef DEFIMPY
150 static const struct _ffeintrin_spec_ specs[] = {
151 #define DEFNAME(UPPER,LOWER,MIXED,GEN,SPEC)
152 #define DEFGEN(CODE,NAME,SPEC1,SPEC2)
153 #define DEFSPEC(CODE,NAME,CALLABLE,FAMILY,IMP) \
154 { NAME, CALLABLE, FAMILY, IMP, },
155 #define DEFIMP(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL)
156 #define DEFIMPY(CODE,NAME,GFRTDIRECT,GFRTF2C,GFRTGNU,CONTROL,Y2KBAD)
157 #include "intrin.def"
158 #undef DEFGEN
159 #undef DEFSPEC
160 #undef DEFIMP
161 #undef DEFIMPY
164 struct cc_pair { const ffeintrinImp imp; const char *const text; };
166 static const char *descriptions[FFEINTRIN_imp] = { 0 };
167 static const struct cc_pair cc_descriptions[] = {
168 #define DEFDOC(IMP,SUMMARY,DESCRIPTION) { FFEINTRIN_imp ## IMP, DESCRIPTION },
169 #include "intdoc.h0"
170 #undef DEFDOC
173 static const char *summaries[FFEINTRIN_imp] = { 0 };
174 static const struct cc_pair cc_summaries[] = {
175 #define DEFDOC(IMP,SUMMARY,DESCRIPTION) { FFEINTRIN_imp ## IMP, SUMMARY },
176 #include "intdoc.h0"
177 #undef DEFDOC
180 const char *
181 family_name (ffeintrinFamily family)
183 switch (family)
185 case FFEINTRIN_familyF77:
186 return "familyF77";
188 case FFEINTRIN_familyASC:
189 return "familyASC";
191 case FFEINTRIN_familyMIL:
192 return "familyMIL";
194 case FFEINTRIN_familyGNU:
195 return "familyGNU";
197 case FFEINTRIN_familyF90:
198 return "familyF90";
200 case FFEINTRIN_familyVXT:
201 return "familyVXT";
203 case FFEINTRIN_familyFVZ:
204 return "familyFVZ";
206 case FFEINTRIN_familyF2C:
207 return "familyF2C";
209 case FFEINTRIN_familyF2U:
210 return "familyF2U";
212 case FFEINTRIN_familyBADU77:
213 return "familyBADU77";
215 default:
216 assert ("bad family" == NULL);
217 return "??";
221 static int in_ifset = 0;
222 static ffeintrinFamily latest_family = FFEINTRIN_familyNONE;
224 static void
225 dumpif (ffeintrinFamily fam)
227 assert (fam != FFEINTRIN_familyNONE);
228 if ((in_ifset != 2)
229 || (fam != latest_family))
231 if (in_ifset == 2)
232 printf ("@end ifset\n");
233 latest_family = fam;
234 printf ("@ifset %s\n", family_name (fam));
236 in_ifset = 1;
239 static void
240 dumpendif ()
242 in_ifset = 2;
245 static void
246 dumpclearif ()
248 if ((in_ifset == 2)
249 || (latest_family != FFEINTRIN_familyNONE))
250 printf ("@end ifset\n");
251 latest_family = FFEINTRIN_familyNONE;
252 in_ifset = 0;
255 static void
256 dumpem ()
258 int i;
260 for (i = 0; ((size_t) i) < ARRAY_SIZE (cc_descriptions); ++i)
262 assert (descriptions[cc_descriptions[i].imp] == NULL);
263 descriptions[cc_descriptions[i].imp] = cc_descriptions[i].text;
266 for (i = 0; ((size_t) i) < ARRAY_SIZE (cc_summaries); ++i)
268 assert (summaries[cc_summaries[i].imp] == NULL);
269 summaries[cc_summaries[i].imp] = cc_summaries[i].text;
272 printf ("@c This file is automatically derived from intdoc.c, intdoc.in,\n");
273 printf ("@c ansify.c, intrin.def, and intrin.h. Edit those files instead.\n");
274 printf ("@menu\n");
275 for (i = 0; ((size_t) i) < ARRAY_SIZE (names); ++i)
277 if (names[i].generic != FFEINTRIN_genNONE)
278 dumpgen (1, names[i].name_ic, names[i].name_uc,
279 names[i].generic);
280 if (names[i].specific != FFEINTRIN_specNONE)
281 dumpspec (1, names[i].name_ic, names[i].name_uc,
282 names[i].specific);
284 dumpclearif ();
286 printf ("@end menu\n\n");
288 for (i = 0; ((size_t) i) < ARRAY_SIZE (names); ++i)
290 if (names[i].generic != FFEINTRIN_genNONE)
291 dumpgen (0, names[i].name_ic, names[i].name_uc,
292 names[i].generic);
293 if (names[i].specific != FFEINTRIN_specNONE)
294 dumpspec (0, names[i].name_ic, names[i].name_uc,
295 names[i].specific);
297 dumpclearif ();
300 static void
301 dumpgen (int menu, const char *name, const char *name_uc, ffeintrinGen gen)
303 size_t i;
304 int total = 0;
306 if (!menu)
308 for (i = 0; i < ARRAY_SIZE (gens[gen].specs); ++i)
310 if (gens[gen].specs[i] != FFEINTRIN_specNONE)
311 ++total;
315 for (i = 0; i < ARRAY_SIZE (gens[gen].specs); ++i)
317 ffeintrinSpec spec;
318 size_t j;
320 if ((spec = gens[gen].specs[i]) == FFEINTRIN_specNONE)
321 continue;
323 dumpif (specs[spec].family);
324 dumpimp (menu, name, name_uc, i, specs[spec].family, specs[spec].implementation,
325 spec);
326 if (!menu && (total > 0))
328 if (total == 1)
330 printf ("\
331 For information on another intrinsic with the same name:\n");
333 else
335 printf ("\
336 For information on other intrinsics with the same name:\n");
338 for (j = 0; j < ARRAY_SIZE (gens[gen].specs); ++j)
340 if (j == i)
341 continue;
342 if ((spec = gens[gen].specs[j]) == FFEINTRIN_specNONE)
343 continue;
344 printf ("@xref{%s Intrinsic (%s)}.\n",
345 name, specs[spec].name);
347 printf ("\n");
349 dumpendif ();
353 static void
354 dumpspec (int menu, const char *name, const char *name_uc, ffeintrinSpec spec)
356 dumpif (specs[spec].family);
357 dumpimp (menu, name, name_uc, 0, specs[spec].family, specs[spec].implementation,
358 FFEINTRIN_specNONE);
359 dumpendif ();
362 static void
363 dumpimp (int menu, const char *name, const char *name_uc, size_t genno,
364 ffeintrinFamily family, ffeintrinImp imp, ffeintrinSpec spec)
366 const char *c;
367 bool subr;
368 const char *argc;
369 const char *argi;
370 int colon;
371 int argno;
373 assert ((imp != FFEINTRIN_impNONE) || !genno);
375 if (menu)
377 printf ("* %s Intrinsic",
378 name);
379 if (spec != FFEINTRIN_specNONE)
380 printf (" (%s)", specs[spec].name); /* See XYZZY1 below */
381 printf ("::");
382 #define INDENT_SUMMARY 24
383 if ((imp == FFEINTRIN_impNONE)
384 || (summaries[imp] != NULL))
386 int spaces = INDENT_SUMMARY - 14 - strlen (name);
387 const char *c;
389 if (spec != FFEINTRIN_specNONE)
390 spaces -= (3 + strlen (specs[spec].name)); /* See XYZZY1 above */
391 if (spaces < 1)
392 spaces = 1;
393 while (spaces--)
394 fputc (' ', stdout);
396 if (imp == FFEINTRIN_impNONE)
398 printf ("(Reserved for future use.)\n");
399 return;
402 for (c = summaries[imp]; c[0] != '\0'; ++c)
404 if (c[0] == '@' && ISDIGIT (c[1]))
406 int argno = c[1] - '0';
408 c += 2;
409 while (ISDIGIT (c[0]))
411 argno = 10 * argno + (c[0] - '0');
412 ++c;
414 assert (c[0] == '@');
415 if (argno == 0)
416 printf ("%s", name);
417 else if (argno == 99)
418 { /* Yeah, this is a major kludge. */
419 printf ("\n");
420 spaces = INDENT_SUMMARY + 1;
421 while (spaces--)
422 fputc (' ', stdout);
424 else
425 printf ("%s", argument_name_string (imp, argno - 1));
427 else
428 fputc (c[0], stdout);
431 printf ("\n");
432 return;
435 printf ("@node %s Intrinsic", name);
436 if (spec != FFEINTRIN_specNONE)
437 printf (" (%s)", specs[spec].name);
438 printf ("\n@subsubsection %s Intrinsic", name);
439 if (spec != FFEINTRIN_specNONE)
440 printf (" (%s)", specs[spec].name);
441 printf ("\n@cindex %s intrinsic\n@cindex intrinsics, %s\n",
442 name, name);
444 if (imp == FFEINTRIN_impNONE)
446 printf ("\n\
447 This intrinsic is not yet implemented.\n\
448 The name is, however, reserved as an intrinsic.\n\
449 Use @samp{EXTERNAL %s} to use this name for an\n\
450 external procedure.\n\
453 name);
454 return;
457 c = imps[imp].control;
458 subr = (c[0] == '-');
459 colon = (c[2] == ':') ? 2 : 3;
461 printf ("\n\
462 @noindent\n\
463 @example\n\
464 %s%s(",
465 (subr ? "CALL " : ""), name);
467 fflush (stdout);
469 for (argno = 0; ; ++argno)
471 argc = argument_name_ptr (imp, argno);
472 if (argc == NULL)
473 break;
474 if (argno > 0)
475 printf (", ");
476 printf ("@var{%s}", argc);
477 argi = argument_info_string (imp, argno);
478 if ((argi[0] == '*')
479 || (argi[0] == 'n')
480 || (argi[0] == '+')
481 || (argi[0] == 'p'))
482 printf ("-1, @var{%s}-2, @dots{}, @var{%s}-n",
483 argc, argc);
486 printf (")\n\
487 @end example\n\
491 if (!subr)
493 int other_arg;
494 const char *arg_string;
495 const char *arg_info;
497 if (ISDIGIT (c[colon + 1]))
499 other_arg = c[colon + 1] - '0';
500 arg_string = argument_name_string (imp, other_arg);
501 arg_info = argument_info_string (imp, other_arg);
503 else
505 other_arg = -1;
506 arg_string = NULL;
507 arg_info = NULL;
510 printf ("\
511 @noindent\n\
512 %s: ", name);
513 print_type_string (c);
514 printf (" function");
516 if ((c[0] == 'R')
517 && (c[1] == 'C'))
519 assert (other_arg >= 0);
521 if ((arg_info[0] == '?') || (arg_info[0] == '!') || (arg_info[0] == '+')
522 || (arg_info[0] == '*') || (arg_info[0] == 'n') || (arg_info[0] == 'p'))
523 ++arg_info;
524 if ((arg_info[0] == 'F') || (arg_info[0] == 'N'))
525 printf (".\n\
526 The exact type is @samp{REAL(KIND=1)} when argument @var{%s} is\n\
527 any type other than @code{COMPLEX}, or when it is @code{COMPLEX(KIND=1)}.\n\
528 When @var{%s} is any @code{COMPLEX} type other than @code{COMPLEX(KIND=1)},\n\
529 this intrinsic is valid only when used as the argument to\n\
530 @code{REAL()}, as explained below.\n\n",
531 arg_string,
532 arg_string);
533 else
534 printf (".\n\
535 This intrinsic is valid when argument @var{%s} is\n\
536 @code{COMPLEX(KIND=1)}.\n\
537 When @var{%s} is any other @code{COMPLEX} type,\n\
538 this intrinsic is valid only when used as the argument to\n\
539 @code{REAL()}, as explained below.\n\n",
540 arg_string,
541 arg_string);
543 #if 0
544 else if ((c[0] == 'I')
545 && (c[1] == '7'))
546 printf (", the exact type being wide enough to hold a pointer\n\
547 on the target system (typically @code{INTEGER(KIND=1)} or @code{INTEGER(KIND=4)}).\n\n");
548 #endif
549 else if (c[1] == '=' && ISDIGIT (c[colon + 1]))
551 assert (other_arg >= 0);
553 if ((arg_info[0] == '?') || (arg_info[0] == '!') || (arg_info[0] == '+')
554 || (arg_info[0] == '*') || (arg_info[0] == 'n') || (arg_info[0] == 'p'))
555 ++arg_info;
557 if (((c[0] == arg_info[0])
558 && ((c[0] == 'A') || (c[0] == 'C') || (c[0] == 'I')
559 || (c[0] == 'L') || (c[0] == 'R')))
560 || ((c[0] == 'R')
561 && (arg_info[0] == 'C'))
562 || ((c[0] == 'C')
563 && (arg_info[0] == 'R')))
564 printf (", the @samp{KIND=} value of the type being that of argument @var{%s}.\n\n",
565 arg_string);
566 else if ((c[0] == 'S')
567 && ((arg_info[0] == 'C')
568 || (arg_info[0] == 'F')
569 || (arg_info[0] == 'N')))
570 printf (".\n\
571 The exact type depends on that of argument @var{%s}---if @var{%s} is\n\
572 @code{COMPLEX}, this function's type is @code{REAL}\n\
573 with the same @samp{KIND=} value as the type of @var{%s}.\n\
574 Otherwise, this function's type is the same as that of @var{%s}.\n\n",
575 arg_string, arg_string, arg_string, arg_string);
576 else
577 printf (", the exact type being that of argument @var{%s}.\n\n",
578 arg_string);
580 else if ((c[1] == '=')
581 && (c[colon + 1] == '*'))
582 printf (", the exact type being the result of cross-promoting the\n\
583 types of all the arguments.\n\n");
584 else if (c[1] == '=')
585 assert ("?0:?:" == NULL);
586 else
587 printf (".\n\n");
590 for (argno = 0, argc = &c[colon + 3]; *argc != '\0'; ++argno)
592 char optionality = '\0';
593 char extra = '\0';
594 char basic;
595 char kind;
596 int length;
597 int elements;
599 printf ("\
600 @noindent\n\
601 @var{");
602 for (; ; ++argc)
604 if (argc[0] == '=')
605 break;
606 printf ("%c", *argc);
608 printf ("}: ");
610 ++argc;
611 if ((*argc == '?')
612 || (*argc == '!')
613 || (*argc == '*')
614 || (*argc == '+')
615 || (*argc == 'n')
616 || (*argc == 'p'))
617 optionality = *(argc++);
618 basic = *(argc++);
619 kind = *(argc++);
620 if (*argc == '[')
622 length = *++argc - '0';
623 if (*++argc != ']')
624 length = 10 * length + (*(argc++) - '0');
625 ++argc;
627 else
628 length = -1;
629 if (*argc == '(')
631 elements = *++argc - '0';
632 if (*++argc != ')')
633 elements = 10 * elements + (*(argc++) - '0');
634 ++argc;
636 else if (*argc == '&')
638 elements = -1;
639 ++argc;
641 else
642 elements = 0;
643 if ((*argc == '&')
644 || (*argc == 'i')
645 || (*argc == 'w')
646 || (*argc == 'x'))
647 extra = *(argc++);
648 if (*argc == ',')
649 ++argc;
651 switch (basic)
653 case '-':
654 switch (kind)
656 case '*':
657 printf ("Any type");
658 break;
660 default:
661 assert ("kind arg" == NULL);
662 break;
664 break;
666 case 'A':
667 assert ((kind == '1') || (kind == '*'));
668 printf ("@code{CHARACTER");
669 if (length != -1)
670 printf ("*%d", length);
671 printf ("}");
672 break;
674 case 'C':
675 switch (kind)
677 case '*':
678 printf ("@code{COMPLEX}");
679 break;
681 case '1': case '2': case '3': case '4': case '5':
682 case '6': case '7': case '8': case '9':
683 printf ("@code{COMPLEX(KIND=%d)}", (kind - '0'));
684 break;
686 case 'A':
687 printf ("Same @samp{KIND=} value as for @var{%s}",
688 argument_name_string (imp, 0));
689 break;
691 default:
692 assert ("Ca" == NULL);
693 break;
695 break;
697 case 'I':
698 switch (kind)
700 case '*':
701 printf ("@code{INTEGER}");
702 break;
704 case '1': case '2': case '3': case '4': case '5':
705 case '6': case '7': case '8': case '9':
706 printf ("@code{INTEGER(KIND=%d)}", (kind - '0'));
707 break;
709 case 'A':
710 printf ("@code{INTEGER} with same @samp{KIND=} value as for @var{%s}",
711 argument_name_string (imp, 0));
712 break;
714 case 'N':
715 printf ("@code{INTEGER} not wider than the default kind");
716 break;
718 default:
719 assert ("Ia" == NULL);
720 break;
722 break;
724 case 'L':
725 switch (kind)
727 case '*':
728 printf ("@code{LOGICAL}");
729 break;
731 case '1': case '2': case '3': case '4': case '5':
732 case '6': case '7': case '8': case '9':
733 printf ("@code{LOGICAL(KIND=%d)}", (kind - '0'));
734 break;
736 case 'A':
737 printf ("@code{LOGICAL} with same @samp{KIND=} value as for @var{%s}",
738 argument_name_string (imp, 0));
739 break;
741 case 'N':
742 printf ("@code{LOGICAL} not wider than the default kind");
743 break;
745 default:
746 assert ("La" == NULL);
747 break;
749 break;
751 case 'R':
752 switch (kind)
754 case '*':
755 printf ("@code{REAL}");
756 break;
758 case '1': case '2': case '3': case '4': case '5':
759 case '6': case '7': case '8': case '9':
760 printf ("@code{REAL(KIND=%d)}", (kind - '0'));
761 break;
763 case 'A':
764 printf ("@code{REAL} with same @samp{KIND=} value as for @var{%s}",
765 argument_name_string (imp, 0));
766 break;
768 default:
769 assert ("Ra" == NULL);
770 break;
772 break;
774 case 'B':
775 switch (kind)
777 case '*':
778 printf ("@code{INTEGER} or @code{LOGICAL}");
779 break;
781 case '1': case '2': case '3': case '4': case '5':
782 case '6': case '7': case '8': case '9':
783 printf ("@code{INTEGER(KIND=%d)} or @code{LOGICAL(KIND=%d)}",
784 (kind - '0'), (kind - '0'));
785 break;
787 case 'A':
788 printf ("Same type and @samp{KIND=} value as for @var{%s}",
789 argument_name_string (imp, 0));
790 break;
792 case 'N':
793 printf ("@code{INTEGER} or @code{LOGICAL} not wider than the default kind");
794 break;
796 default:
797 assert ("Ba" == NULL);
798 break;
800 break;
802 case 'F':
803 switch (kind)
805 case '*':
806 printf ("@code{REAL} or @code{COMPLEX}");
807 break;
809 case '1': case '2': case '3': case '4': case '5':
810 case '6': case '7': case '8': case '9':
811 printf ("@code{REAL(KIND=%d)} or @code{COMPLEX(KIND=%d)}",
812 (kind - '0'), (kind - '0'));
813 break;
815 case 'A':
816 printf ("Same type as @var{%s}",
817 argument_name_string (imp, 0));
818 break;
820 default:
821 assert ("Fa" == NULL);
822 break;
824 break;
826 case 'N':
827 switch (kind)
829 case '*':
830 printf ("@code{INTEGER}, @code{REAL}, or @code{COMPLEX}");
831 break;
833 case '1': case '2': case '3': case '4': case '5':
834 case '6': case '7': case '8': case '9':
835 printf ("@code{INTEGER(KIND=%d)}, @code{REAL(KIND=%d)}, or @code{COMPLEX(KIND=%d)}",
836 (kind - '0'), (kind - '0'), (kind - '0'));
837 break;
839 default:
840 assert ("N1" == NULL);
841 break;
843 break;
845 case 'S':
846 switch (kind)
848 case '*':
849 printf ("@code{INTEGER} or @code{REAL}");
850 break;
852 case '1': case '2': case '3': case '4': case '5':
853 case '6': case '7': case '8': case '9':
854 printf ("@code{INTEGER(KIND=%d)} or @code{REAL(KIND=%d)}",
855 (kind - '0'), (kind - '0'));
856 break;
858 case 'A':
859 printf ("@code{INTEGER} or @code{REAL} with same @samp{KIND=} value as for @var{%s}",
860 argument_name_string (imp, 0));
861 break;
863 default:
864 assert ("Sa" == NULL);
865 break;
867 break;
869 case 'g':
870 printf ("@samp{*@var{label}}, where @var{label} is the label\n\
871 of an executable statement");
872 break;
874 case 's':
875 printf ("Signal handler (@code{INTEGER FUNCTION} or @code{SUBROUTINE})\n\
876 or dummy/global @code{INTEGER(KIND=1)} scalar");
877 break;
879 default:
880 assert ("arg type?" == NULL);
881 break;
884 switch (optionality)
886 case '\0':
887 break;
889 case '!':
890 printf ("; OPTIONAL (must be omitted if @var{%s} is @code{COMPLEX})",
891 argument_name_string (imp, argno-1));
892 break;
894 case '?':
895 printf ("; OPTIONAL");
896 break;
898 case '*':
899 printf ("; OPTIONAL");
900 break;
902 case 'n':
903 case '+':
904 break;
906 case 'p':
907 printf ("; at least two such arguments must be provided");
908 break;
910 default:
911 assert ("optionality!" == NULL);
912 break;
915 switch (elements)
917 case -1:
918 break;
920 case 0:
921 if ((basic != 'g')
922 && (basic != 's'))
923 printf ("; scalar");
924 break;
926 default:
927 assert (extra != '\0');
928 printf ("; DIMENSION(%d)", elements);
929 break;
932 switch (extra)
934 case '\0':
935 if ((basic != 'g')
936 && (basic != 's'))
937 printf ("; INTENT(IN)");
938 break;
940 case 'i':
941 break;
943 case '&':
944 printf ("; cannot be a constant or expression");
945 break;
947 case 'w':
948 printf ("; INTENT(OUT)");
949 break;
951 case 'x':
952 printf ("; INTENT(INOUT)");
953 break;
956 printf (".\n\n");
959 printf ("\
960 @noindent\n\
961 Intrinsic groups: ");
962 switch (family)
964 case FFEINTRIN_familyF77:
965 printf ("(standard FORTRAN 77).");
966 break;
968 case FFEINTRIN_familyGNU:
969 printf ("@code{gnu}.");
970 break;
972 case FFEINTRIN_familyASC:
973 printf ("@code{f2c}, @code{f90}.");
974 break;
976 case FFEINTRIN_familyMIL:
977 printf ("@code{mil}, @code{f90}, @code{vxt}.");
978 break;
980 case FFEINTRIN_familyF90:
981 printf ("@code{f90}.");
982 break;
984 case FFEINTRIN_familyVXT:
985 printf ("@code{vxt}.");
986 break;
988 case FFEINTRIN_familyFVZ:
989 printf ("@code{f2c}, @code{vxt}.");
990 break;
992 case FFEINTRIN_familyF2C:
993 printf ("@code{f2c}.");
994 break;
996 case FFEINTRIN_familyF2U:
997 printf ("@code{unix}.");
998 break;
1000 case FFEINTRIN_familyBADU77:
1001 printf ("@code{badu77}.");
1002 break;
1004 default:
1005 assert ("bad family" == NULL);
1006 printf ("@code{???}.");
1007 break;
1009 printf ("\n\n");
1011 if (descriptions[imp] != NULL)
1013 const char *c = descriptions[imp];
1015 printf ("\
1016 @noindent\n\
1017 Description:\n\
1018 \n");
1020 while (c[0] != '\0')
1022 if (c[0] == '@' && ISDIGIT (c[1]))
1024 int argno = c[1] - '0';
1026 c += 2;
1027 while (ISDIGIT (c[0]))
1029 argno = 10 * argno + (c[0] - '0');
1030 ++c;
1032 assert (c[0] == '@');
1033 if (argno == 0)
1034 printf ("%s", name_uc);
1035 else
1036 printf ("%s", argument_name_string (imp, argno - 1));
1038 else
1039 fputc (c[0], stdout);
1040 ++c;
1043 printf ("\n");
1047 static const char *
1048 argument_info_ptr (ffeintrinImp imp, int argno)
1050 const char *c = imps[imp].control;
1051 static char arginfos[8][32];
1052 static int argx = 0;
1053 int i;
1055 if (c[2] == ':')
1056 c += 5;
1057 else
1058 c += 6;
1060 while (argno--)
1062 while ((c[0] != ',') && (c[0] != '\0'))
1063 ++c;
1064 if (c[0] != ',')
1065 break;
1066 ++c;
1069 if (c[0] == '\0')
1070 return NULL;
1072 for (; (c[0] != '=') && (c[0] != '\0'); ++c)
1075 assert (c[0] == '=');
1077 for (i = 0, ++c; (c[0] != ',') && (c[0] != '\0'); ++c, ++i)
1078 arginfos[argx][i] = c[0];
1080 arginfos[argx][i] = '\0';
1082 c = &arginfos[argx][0];
1083 ++argx;
1084 if (((size_t) argx) >= ARRAY_SIZE (arginfos))
1085 argx = 0;
1087 return c;
1090 static const char *
1091 argument_info_string (ffeintrinImp imp, int argno)
1093 const char *p;
1095 p = argument_info_ptr (imp, argno);
1096 assert (p != NULL);
1097 return p;
1100 static const char *
1101 argument_name_ptr (ffeintrinImp imp, int argno)
1103 const char *c = imps[imp].control;
1104 static char argnames[8][32];
1105 static int argx = 0;
1106 int i;
1108 if (c[2] == ':')
1109 c += 5;
1110 else
1111 c += 6;
1113 while (argno--)
1115 while ((c[0] != ',') && (c[0] != '\0'))
1116 ++c;
1117 if (c[0] != ',')
1118 break;
1119 ++c;
1122 if (c[0] == '\0')
1123 return NULL;
1125 for (i = 0; (c[0] != '=') && (c[0] != '\0'); ++c, ++i)
1126 argnames[argx][i] = c[0];
1128 assert (c[0] == '=');
1129 argnames[argx][i] = '\0';
1131 c = &argnames[argx][0];
1132 ++argx;
1133 if (((size_t) argx) >= ARRAY_SIZE (argnames))
1134 argx = 0;
1136 return c;
1139 static const char *
1140 argument_name_string (ffeintrinImp imp, int argno)
1142 const char *p;
1144 p = argument_name_ptr (imp, argno);
1145 assert (p != NULL);
1146 return p;
1149 static void
1150 print_type_string (const char *c)
1152 char basic = c[0];
1153 char kind = c[1];
1155 switch (basic)
1157 case 'A':
1158 assert ((kind == '1') || (kind == '='));
1159 if (c[2] == ':')
1160 printf ("@code{CHARACTER*1}");
1161 else
1163 assert (c[2] == '*');
1164 printf ("@code{CHARACTER*(*)}");
1166 break;
1168 case 'C':
1169 switch (kind)
1171 case '=':
1172 printf ("@code{COMPLEX}");
1173 break;
1175 case '1': case '2': case '3': case '4': case '5':
1176 case '6': case '7': case '8': case '9':
1177 printf ("@code{COMPLEX(KIND=%d)}", (kind - '0'));
1178 break;
1180 default:
1181 assert ("Ca" == NULL);
1182 break;
1184 break;
1186 case 'I':
1187 switch (kind)
1189 case '=':
1190 printf ("@code{INTEGER}");
1191 break;
1193 case '1': case '2': case '3': case '4': case '5':
1194 case '6': case '7': case '8': case '9':
1195 printf ("@code{INTEGER(KIND=%d)}", (kind - '0'));
1196 break;
1198 default:
1199 assert ("Ia" == NULL);
1200 break;
1202 break;
1204 case 'L':
1205 switch (kind)
1207 case '=':
1208 printf ("@code{LOGICAL}");
1209 break;
1211 case '1': case '2': case '3': case '4': case '5':
1212 case '6': case '7': case '8': case '9':
1213 printf ("@code{LOGICAL(KIND=%d)}", (kind - '0'));
1214 break;
1216 default:
1217 assert ("La" == NULL);
1218 break;
1220 break;
1222 case 'R':
1223 switch (kind)
1225 case '=':
1226 printf ("@code{REAL}");
1227 break;
1229 case '1': case '2': case '3': case '4': case '5':
1230 case '6': case '7': case '8': case '9':
1231 printf ("@code{REAL(KIND=%d)}", (kind - '0'));
1232 break;
1234 case 'C':
1235 printf ("@code{REAL}");
1236 break;
1238 default:
1239 assert ("Ra" == NULL);
1240 break;
1242 break;
1244 case 'B':
1245 switch (kind)
1247 case '=':
1248 printf ("@code{INTEGER} or @code{LOGICAL}");
1249 break;
1251 case '1': case '2': case '3': case '4': case '5':
1252 case '6': case '7': case '8': case '9':
1253 printf ("@code{INTEGER(KIND=%d)} or @code{LOGICAL(KIND=%d)}",
1254 (kind - '0'), (kind - '0'));
1255 break;
1257 default:
1258 assert ("Ba" == NULL);
1259 break;
1261 break;
1263 case 'F':
1264 switch (kind)
1266 case '=':
1267 printf ("@code{REAL} or @code{COMPLEX}");
1268 break;
1270 case '1': case '2': case '3': case '4': case '5':
1271 case '6': case '7': case '8': case '9':
1272 printf ("@code{REAL(KIND=%d)} or @code{COMPLEX(KIND=%d)}",
1273 (kind - '0'), (kind - '0'));
1274 break;
1276 default:
1277 assert ("Fa" == NULL);
1278 break;
1280 break;
1282 case 'N':
1283 switch (kind)
1285 case '=':
1286 printf ("@code{INTEGER}, @code{REAL}, or @code{COMPLEX}");
1287 break;
1289 case '1': case '2': case '3': case '4': case '5':
1290 case '6': case '7': case '8': case '9':
1291 printf ("@code{INTEGER(KIND=%d)}, @code{REAL(KIND=%d)}, or @code{COMPLEX(KIND=%d)}",
1292 (kind - '0'), (kind - '0'), (kind - '0'));
1293 break;
1295 default:
1296 assert ("N1" == NULL);
1297 break;
1299 break;
1301 case 'S':
1302 switch (kind)
1304 case '=':
1305 printf ("@code{INTEGER} or @code{REAL}");
1306 break;
1308 case '1': case '2': case '3': case '4': case '5':
1309 case '6': case '7': case '8': case '9':
1310 printf ("@code{INTEGER(KIND=%d)} or @code{REAL(KIND=%d)}",
1311 (kind - '0'), (kind - '0'));
1312 break;
1314 default:
1315 assert ("Sa" == NULL);
1316 break;
1318 break;
1320 default:
1321 assert ("type?" == NULL);
1322 break;