PIPS
declaration.c
Go to the documentation of this file.
1 /*
2 
3  $Id: declaration.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /*
28  * Functions to handle all declarations, but some related to functional
29  * entities
30  *
31  * Remi Triolet
32  *
33  * Modifications:
34  * - DeclareVariable() : an implicit type is assumed to be mutable like
35  * an undefined type; Francois Irigoin, 5 April 1991
36  * - FindOrCreateEntity() : see below; numerous trials of various
37  * partial links at compile time; see also procedure.c,
38  * update_called_modules()
39  * - DeclareVariable() is rewritten from scratch; (Francois Irigoin,
40  * 20 September 1991)
41  * - AnalyzeData() : "too few analyzers" for an exact count; the last
42  * iteration of pcr = CDR(pcr) is not executed because pcl==NIL;
43  * fix: update of datavar_nbelements(dvr) and modification of the
44  * condition guarding the message emission; FI, 18 February 1992
45  * (this might be no more than a new bug! )
46  * - MakeDataVar() : used to consider that array X was full initialized
47  * each time an array element was initialized; a check for subscripts
48  * was added; FI, 18 February 1992
49  * - check_common_layouts() : added to fix bug 1; FI, 1 December 1993
50  * renamed update_user_common_layouts(), FI, 25 September 1998
51  *
52  * Bugs:
53  * - layout for commons are wrong if type and/or dimension declarations
54  * follow the COMMON declaration; PIPS Fortran syntax should be modified
55  * to prevent this;
56  */
57 
58 #include <stdlib.h>
59 #include <stdio.h>
60 #include <string.h>
61 #include <ctype.h>
62 
63 #include "genC.h"
64 #include "linear.h"
65 #include "ri.h"
66 #include "ri-util.h"
67 #include "workspace-util.h"
68 #include "parser_private.h"
69 
70 #include "properties.h"
71 
72 #include "misc.h"
73 
74 #include "syntax.h"
75 
76 #define IS_UPPER(c) (isascii(c) && isupper(c))
77 
78 /* This function should not be used outside of the syntax library
79  * because it depends on ParserError().
80  *
81  * See ri-util/size.c: array_size()
82  */
84 {
85  int s;
86 
87  if (!SizeOfArray(a, &s)) {
88  pips_user_warning("Varying size of array \"%s\": An integer PARAMETER may "
89  "have been initialized with a real value?\n",
90  entity_name(a));
91  ParserError(__FUNCTION__,
92  "Fortran standard prohibit varying size array\n"
93  "Set property PARSER_ACCEPT_ANSI_EXTENSIONS to true.\n");
94  }
95 
96  return s;
97 }
98 
99 void
101 {
109 
117 
125 
133 }
134 ␌
135 /* functions for the SAVE declaration */
136 
137 void
139 {
142 
143  pips_assert("save_all_entities", StaticArea != entity_undefined);
144  pips_assert("save_all_entities", DynamicArea != entity_undefined);
145 
146  /* FI: all variables previously allocated should be reallocated */
147 
148  MAP(ENTITY, e, {
149  storage s;
150  if((s=entity_storage(e))!= storage_undefined) {
153  entity_storage(e) =
155  (make_ram(mod,
156  StaticArea,
158  NIL)));
159  }
160  }
161  }, vars);
162 
163  /* FI: This is pretty crude... Let's hope it works */
165 }
166 
167 /* These two functions transform a dynamic variable into a static one.
168  * They are called to handle SAVE and DATA statements.
169  *
170  * Because equivalence chains have not yet been processed, it is not
171  * possible to assign an offset or to chain the variable to the static
172  * area layout. These two updates are performed by ComputeAddresses()
173  * only called by EndOfProcedure() to make sure that all non-declared
174  * variables have been taken into account.
175  */
176 
177 void
179 {
181 
182  if(!entity_undefined_p(g)
183  /* Let's hope functions and subroutines called are listed in the
184  * declaration list.
185  */
187  user_warning("SaveEntity",
188  "Ambiguity between external %s and local %s forbidden by Fortran standard\n",
189  entity_name(g), entity_name(e));
190  ParserError("SaveEntity", "Name conflict\n");
191  }
192 
193  if (entity_type(e) == type_undefined) {
196  }
197 
198  if (entity_storage(e) != storage_undefined) {
199  if (storage_ram_p(entity_storage(e))) {
200  ram r;
201 
202  r = storage_ram(entity_storage(e));
203 
204  if (ram_section(r) == DynamicArea) {
205  /* This cannot be done before the equivalences have been processed */
206  /*
207  area a = type_area(entity_type(StaticArea));
208  area_layout(a) = gen_nconc(area_layout(a),
209  CONS(ENTITY, e, NIL));
210  */
211  ram_section(r) = StaticArea;
213  }
214  else {
215  /* Not much can be said. Maybe it is redundant, but... */
216  /* Maybe the standard claims that you are not allowed
217  * to save a common variable?
218  */
219  /*
220  user_warning("SaveEntity", "Variable %s has already been declared static "
221  "by SAVE, by DATA or by appearing in a common declaration\n",
222  entity_local_name(e));
223  */
224  }
225  }
226  else {
227  user_warning("SaveEntity",
228  "Cannot save variable %s with non RAM storage (storage tag = %d)\n",
231  ParserError("SaveEntity", "Cannot save this variable");
232  }
233  }
234  else {
235  entity_storage(e) =
238  StaticArea,
239  /* The type and dimensions are still unknown */
241  NIL)));
242  }
243 }
244 
245 void MakeVariableStatic(entity v, bool force_it)
246 {
248  SaveEntity(v);
249  }
250  else if(storage_ram_p(entity_storage(v))) {
252  if(a==DynamicArea) {
253  SaveEntity(v);
254  }
255  else if(a==StaticArea) {
256  /* v may have become static because of a DATA statement (OK)
257  * or because of another SAVE (NOK)
258  */
259  }
260  else {
261  /* Could be the stack or the heap area or any common */
262  if(force_it) {
263  user_warning("ProcessSave", "Variable %s has already been declared static "
264  "by appearing in Common %s\n",
266  ParserError("parser", "SAVE statement incompatible with previous"
267  " COMMON declaration\n");
268  }
269  else {
270  }
271  }
272  }
273  else {
274  user_warning("parser", "Variable %s cannot be declared static "
275  "be cause of its storage class (tag=%d)\n",
277  ParserError("parser", "SAVE statement incompatible with previous"
278  " declaration (e.g. EXTERNAL).\n");
279  }
280 }
281 
283 {
284  MakeVariableStatic(v, true);
285 }
286 
288 {
289  MakeVariableStatic(v, false);
290 }
291 
292 /* this function transforms a dynamic common into a static one. */
293 
294 void
296 entity c;
297 {
298  pips_assert("SaveCommon",type_area_p(entity_type(c)));
299 
300  Warning("SaveCommon", "common blocks are automatically saved\n");
301 
302  return;
303 }
304 ␌
305 
306 
307 /* a debugging function, just in case ... */
308 
309 void
310 PrintData(ldvr, ldvl)
311 cons *ldvr, *ldvl;
312 {
313  cons *pc;
314 
315  debug(7, "PrintData", "Begin\n");
316 
317  for (pc = ldvr; pc != NIL; pc = CDR(pc)) {
318  datavar dvr = DATAVAR(CAR(pc));
319 
320  debug(7, "PrintData", "(%s,%d), ", entity_name(datavar_variable(dvr)),
321  datavar_nbelements(dvr));
322 
323  }
324  debug(7, "PrintData", "\n");
325 
326  for (pc = ldvl; pc != NIL; pc = CDR(pc)) {
327  dataval dvl = DATAVAL(CAR(pc));
328 
329  if (constant_int_p(dataval_constant(dvl))) {
330  debug(7, "PrintData", "(%d,%d), ", constant_int(dataval_constant(dvl)),
331  dataval_nboccurrences(dvl));
332  }
333  else {
334  debug(7, "PrintData", "(x,%d), ", dataval_nboccurrences(dvl));
335  }
336 
337  }
338  debug(7, "PrintData", "End\n\n");
339 }
340 
341 
342 
343 /* this function scans at the same time a list of datavar and a list of
344 dataval. it tries to match datavar to dataval and to compute initial
345 values for zero dimension variable of basic type integer.
346 
347 ldvr is a list of datavar.
348 
349 ldvl is a list of dataval. */
350 
351 void
352 AnalyzeData(list ldvr, list ldvl)
353 {
354  list pcr, pcl;
355  dataval dvl;
356 
357  /* FI: this assertion must be usually wrong!
358  * pips_assert("AnalyseData", gen_length(ldvr) == gen_length(ldvl));
359  */
360 
361  pips_debug(8, "number of reference groups: %td\n", gen_length(ldvr));
362 
363  pcl = ldvl;
364  dvl = DATAVAL(CAR(pcl));
365  for (pcr = ldvr; pcr != NIL && pcl != NIL; pcr = CDR(pcr))
366  {
367  datavar dvr = DATAVAR(CAR(pcr));
368  entity e = datavar_variable(dvr);
369  int i = datavar_nbelements(dvr);
370 
371  if (!entity_undefined_p(e))
372  {
373 
374  pips_debug(8, "Storage for entity %s must be static or made static\n",
375  entity_name(e));
376 
378  entity_storage(e) =
381  StaticArea,
383  NIL)));
384  }
385  else if(storage_ram_p(entity_storage(e))) {
388 
389  if(dynamic_area_p(s)) {
390  if(entity_blockdata_p(m)) {
392  ("Variable %s is declared dynamic in a BLOCKDATA\n",
393  entity_local_name(e));
394  ParserError("AnalyzeData",
395  "No dynamic variables in BLOCKDATA\n");
396  }
397  else {
398  SaveEntity(e);
399  }
400  }
401  else {
402  /* Variable is in static area or in a user declared common */
403  if(entity_blockdata_p(m)) {
404  /* Variable must be in a user declared common */
405  if(static_area_p(s)) {
407  ("DATA for variable %s declared is impossible:"
408  " it should be declared in a COMMON instead\n",
409  entity_local_name(e));
410  ParserError("AnalyzeData",
411  "Improper DATA declaration in BLOCKDATA");
412  }
413  }
414  else {
415  /* Variable must be in static area */
416  if(!static_area_p(s)) {
418  ("DATA for variable %s declared in COMMON %s:"
419  " not standard compliant,"
420  " use a BLOCKDATA\n",
422  if(!get_bool_property("PARSER_ACCEPT_ANSI_EXTENSIONS")) {
423  ParserError("AnalyzeData",
424  "Improper DATA declaration, use a BLOCKDATA"
425  " or set property PARSER_ACCEPT_ANSI_EXTENSIONS");
426  }
427  }
428  }
429  }
430  }
431  else {
432  user_warning("AnalyzeData",
433  "DATA initialization for non RAM variable %s "
434  "(storage tag = %d)\n",
436  ParserError("AnalyzeData",
437  "DATA statement initializes non RAM variable\n");
438  }
439 
440  pips_debug(8, "needs %d elements for entity %s\n",
441  i, entity_name(e));
442 
443  pips_assert("AnalyzeData", dataval_nboccurrences(dvl) > 0);
444 
445  /* entity e initial field is set here with the data information.
446  */
447  if (entity_scalar_p(e))
448  {
449  constant cst = dataval_constant(dvl);
450 
451  pips_assert("AnalyzeData", i == 1);
452 
453  if (constant_int_p(cst) || constant_call_p(cst))
454  {
457  {
458  value old = entity_initial(e);
460  copy_constant(cst));
461  free_value(old);
462  }
463  else
464  {
465  pips_user_warning("Conflicting initial values for variable %s\n",
466  entity_local_name(e));
467  ParserError("AnalyzeData", "Too many initial values");
468  }
469  }
470  else
471  {
472  Warning("AnalyzeData",
473  "Integer scalar variable initialized "
474  "with non-integer constant");
475  }
476  }
477 
478  } /* if (entity_defined_p(e)) */
479 
480  while (i > 0 && pcl != NIL)
481  {
482  if (i <= dataval_nboccurrences(dvl)) {
483  pips_debug(8, "uses %d values out of %td\n",
484  i, dataval_nboccurrences(dvl));
485  dataval_nboccurrences(dvl) -= i;
486  i = 0;
487  }
488  else {
489  pips_debug(8, "satisfies %td references out of %d\n",
490  dataval_nboccurrences(dvl), i);
491  i -= dataval_nboccurrences(dvl);
492  dataval_nboccurrences(dvl) = 0;
493  }
494 
495  if (dataval_nboccurrences(dvl) == 0) {
496  if ((pcl = CDR(pcl)) != NIL) {
497  dvl = DATAVAL(CAR(pcl));
498 
499  pips_debug(8, "use next dataval\n");
500  }
501  }
502  datavar_nbelements(dvr) = i;
503  }
504  }
505 
506  if (pcl != NIL) {
507  Warning("AnalyzeData", "too many initializers\n");
508  }
509 
510  if (pcr != NIL &&
511  (datavar_nbelements(DATAVAR(CAR(pcr))) != 0 || CDR(pcr) != NIL)) {
512  ParserError("AnalyzeData", "too few initializers\n");
513  }
514 }
515 ␌
516 /* Receives as first input an implicit list of references, including
517  implicit DO, and as second input an list of value using
518  pseudo-intrinsic REPEAT_VALUE() to replicate values. Generates a call
519  statement to STATIC-INITIALIZATION(), with a call to DATA_LIST to
520  prefix ldr (unlike IO list). Processes the information as AnalyzeData()
521  used to do it. Add the new data call statement to the initializations
522  field of the current module. */
523 
525 {
530 
531  pips_assert("The static initialization pseudo-intrinsic is defined",
532  !entity_undefined_p(dl));
533 
534  pldr = make_call_expression(dl, ldr);
536  gen_nconc(CONS(EXPRESSION, pldr, NIL), ldv),
538  strdup(PrevComm));
539  PrevComm[0] = '\0';
540  iPrevComm = 0;
541 
544 }
545 ␌
546 void DeclarePointer(entity ptr, entity pointed_array, list decl_dims)
547 {
548  /* It is assumed that decl_tableau can be ignored for EDF examples */
549  list dims = list_undefined;
550 
551  if(!get_bool_property("PARSER_ACCEPT_ANSI_EXTENSIONS")) {
552  pips_user_warning("Non-standard pointer declaration. "
553  "Set property PARSER_ACCEPT_ANSI_EXTENSIONS to true.\n");
554  }
555 
556  if(!ENDP(decl_dims)) {
557  /* A varying dimension is impossible in the dynamic area for address
558  * computation. A heap area must be added.
559  */
560 
561  dims =
562  CONS(DIMENSION,
565  NIL),
566  NIL);
567 
568  /* dims = decl_dims; */
569  }
570  else {
571  dims = decl_dims;
572  }
573 
574  pips_user_warning("SUN pointer declaration detected. Integer type used.\n");
575  /* No specific type for SUN pointers */
576  if(type_undefined_p(entity_type(ptr))) {
579  }
580  else if(implicit_type_p(ptr)) {
583  }
584  else {
585  type tp = entity_type(ptr);
586 
587  if(type_variable_p(tp)
589  /* EDF code contains several declaration for a unique pointer */
590  pips_user_warning("%s %s between lines %d and % d\n",
591  "Redefinition of pointer",
593 
594  }
595  else {
596  pips_user_warning("DeclarePointer",
597  "%s %s between lines %d and % d\n",
598  "Redefinition of type for entity",
600  ParserError("Syntax", "Conflicting type declarations\n");
601  }
602  }
603  DeclareVariable(pointed_array, type_undefined, dims,
606  HeapArea,
608  NIL)),
610 }
611 
612 /* type_equal_p -> same_basic_and_scalar_p in latter... FC.
613  */
614 static bool
616 {
617  variable v1, v2;
618  if (!type_variable_p(t1) || !type_variable_p(t2)) return false;
619  v1 = type_variable(t1);
620  v2 = type_variable(t2);
621  if (variable_undefined_p(v1) || variable_undefined_p(v2)) return false;
622  if (!basic_equal_p(variable_basic(v1), variable_basic(v2))) return false;
623  return variable_dimensions(v1)==NIL && variable_dimensions(v2)==NIL;
624 }
625 
626 /* void DeclareVariable(e, t, d, s, v): update entity e description
627  * as declaration statements are encountered. Examples of sequences:
628  *
629  * INTEGER*4 T
630  * DIMENSION T(10)
631  * SAVE T
632  *
633  * or
634  * COMMON /TOTO/X,Y
635  * CHARACTER*30 X
636  * DIMENSION X(10)
637  *
638  * or
639  * EXTERNAL F
640  * INTEGER F
641  *
642  * The input code is assumed correct. As the standard states, IMPLICIT
643  * statements must occur before *any* declaration.
644  *
645  * Parameters:
646  * e is an entity which should be either a variable or a funtion; it
647  * may already have a type et, of kind variable or functional;
648  * the type variable may have a dimension; variable or functional
649  * implicit types, as well as undefined type, can be superseded by
650  * the new type t; a NIL type dimension can be superseded by d;
651  * how should area entities be handled ???
652  * t is a type of kind "variable" (functional types are not accepted;
653  * functional declaration are handled by ??? ) or undefined;
654  * it should have no dimensions;
655  * d is a (possibly) empty list of dimensions; the empty list is
656  * handled as the undefined list; each dimension is an expression
657  * s is the storage, possibly undefined;
658  * v is the initial value, possibly undefined
659  *
660  * Most problems occur because of the great number of combinations between
661  * the entity type et (undefined, variable, functional) and the entity type
662  * dimension etd (NIL ot not) giving 7 cases on one hand, the type t and
663  * the dimensions d giving 4 cases on the other hand. That is 28 different
664  * behaviors.
665  *
666  * No sharing is introduced between t and et. However d and s are directly
667  * used in e fields.
668  */
669 void
671  entity e,
672  type t,
673  list d,
674  storage s,
675  value v)
676 {
677  type et = entity_type(e);
678  list etd = list_undefined;
679  bool variable_had_implicit_type_p = false;
680 
681  debug(8, "DeclareVariable", "%s\n", entity_name(e));
682  pips_assert("DeclareVariable", t == type_undefined || type_variable_p(t));
683 
684  if(et == type_undefined) {
685  if(t == type_undefined) {
686  entity_type(e) = ImplicitType(e);
688  }
689  else {
690  type nt;
691  nt = MakeTypeVariable
693  d);
694  entity_type(e) = nt;
695  }
696  }
697  else
698  switch(type_tag(et)) {
699  case is_type_functional:
700  if(d!=NIL) {
701  user_warning("DeclareVariable",
702  "%s %s between lines %d and % d\n",
703  "Attempt to dimension functional entity",
705  ParserError("DeclareVariable", "Likely name conflict\n");
706  }
707  if(t == type_undefined)
708  /* no new information: do nothing */
709  ;
710  else
711  if (implicit_type_p(e)) {
712  /* update functional type */
715  NIL);
717  /* the old type should be gen_freed... */
718  }
720  user_warning("DeclareVariable",
721  "%s %s between lines %d and % d\n",
722  "Redefinition of functional type for entity",
724  }
725  else {
726  user_warning("DeclareVariable",
727  "%s %s between lines %d and % d\n",
728  "Modification of functional result type for entity",
730  ParserError("DeclareVariable",
731  "Possible name conflict?\n");
732  }
733  break;
734  case is_type_variable:
736  if(t == type_undefined) {
737  /* set dimension etd if NIL */
738  if(etd==NIL)
740  else if (d==NIL)
741  ;
742  else {
743  user_warning("DeclareVariable",
744  "%s %s between lines %d and % d\n",
745  "Redefinition of dimension for entity",
747  ParserError("DeclareVariable", "Name conflict?\n");
748  }
749  }
750  else {
751  pips_assert("DeclareVariable",
753  if(implicit_type_p(e)){
754  type nt;
755 
756  variable_had_implicit_type_p = true;
757 
758  /* set dimension etd if NIL */
759  if(etd==NIL)
761  else if (d==NIL)
762  ;
763  else {
764  user_warning("DeclareVariable",
765  "%s %s between lines %d and % d\n",
766  "Redefinition of dimension for entity",
768  ParserError("DeclareVariable", "Name conflict?\n");
769  }
770  /* update type */
771  nt = MakeTypeVariable
774 
776  {
777 
778  if(/*FI: to check update_common_layout*/ false &&
783  {
784  user_warning("DeclareVariable",
785  "Storage information for %s is likely to be wrong because its type is "
786  "redefined as a larger type\nType is *not* redefined internally to avoid "
787  "aliasing\n", entity_local_name(e));
788  /* FI: it should be redefined and the offset be updated,
789  * maybe in check_common_area(); 1 Feb. 1994
790  */
791  }
792  else {
793  entity_type(e) = nt;
794  }
795  }
796  else {
797  free_type(nt);
798  }
799  }
800  else {
802  /* Exception: since it is a synthetic variable, it is
803  unlikely to be typed explicitly. But it can appear
804  in later PIPS regenerated declarations. Unless
805  there is a clash with a user variable. */
806  if(type_equal_p(entity_type(e), t)) {
807  /* No problem, but do not free t because this is performed in gram.y */
808  /* free_type(t); */
809  }
810  else {
812  "%s %s between lines %d and % d\n",
813  "Redefinition of type for formal label substitution entity",
815  ParserError("DeclareVariable",
816  "Name conflict for formal label substitution variable? "
817  "Use property PARSER_FORMAL_LABEL_SUBSTITUTE_PREFIX?\n");
818  }
819  }
820  else {
822  "%s %s between lines %d and % d\n",
823  "Redefinition of type for entity",
825  ParserError("DeclareVariable",
826  "Name conflict or declaration ordering "
827  "not supported by PIPS\n"
828  "Late typing of formal parameter and/or "
829  "interference with IMPLICIT\n");
830  }
831  }
832  }
833  break;
834  case is_type_area:
835  user_warning("DeclareVariable",
836  "%s %s between lines %d and % d\n%s\n",
837  "COMMON/VARIABLE homonymy for entity name",
839  "Rename your common.");
840  ParserError("DeclareVariable", "Name conflict\n");
841  break;
842  default:
843  pips_internal_error("unexpected entity type tag: %d",
844  type_tag(et));
845  }
846 
847  if (s != storage_undefined) {
848  if (entity_storage(e) != storage_undefined) {
849  ParserError("DeclareVariable", "storage non implemented\n");
850  }
851  else {
852  entity_storage(e) = s;
853  }
854  }
855 
856  if (v == value_undefined) {
857  if (entity_initial(e) == value_undefined) {
859  }
860  }
861  else {
862  ParserError("DeclareVariable", "value non implemented\n");
863  }
864 
866 
867  /* If the return variable is retyped, the function must be retyped */
868 
872  type tf = entity_type(f);
873  functional func = type_functional(tf);
874  type tr = functional_result(func);
877 
878  pips_assert("Return variable and function must have the same name",
879  strcmp(entity_local_name(e), module_local_name(f)) == 0 );
880  pips_assert("Function must have functional type", type_functional_p(tf));
881  pips_assert("New type must be of kind variable", type_variable_p(t));
882 
883  if(!type_equal_p(tr, t)) {
884  if(variable_had_implicit_type_p) {
885  debug(8, "DeclareVariable", " Type for result of function %s "
886  "changed from %s to %s: ", module_local_name(f),
887  basic_to_string(old), basic_to_string(new));
889  old = basic_undefined; /* the pointed area has just been freed! */
890  functional_result(func) = copy_type(t);
891  ifdebug(8) {
892  fprint_functional(stderr, type_functional(tf));
893  fprintf(stderr, "\n");
894  }
895  }
896  else {
897  user_warning("DeclareVariable",
898  "Attempt to retype function %s with result of type "
899  "%s with new type %s\n", module_local_name(f),
900  basic_to_string(old), basic_to_string(new));
901  ParserError("DeclareVariable", "Illegal retyping");
902  }
903  }
904  else {
905  /* Meaningless warning when the result variable is declared the first time
906  * with the function itself
907  * user_warning("DeclareVariable",
908  * "Attempt to retype function %s with result of type "
909  * "%s with very same type %s\n", module_local_name(f),
910  * basic_to_string(old), basic_to_string(new));
911  */
912  }
913  }
914 }
915 
916 /* Intrinsic e is used in the current module */
917 void
919 {
920  pips_assert("entity is defined", e!=entity_undefined && intrinsic_entity_p(e));
921 
923 }
924 ␌
925 /*
926  * COMMONs are handled as global objects. They may pre-exist when the
927  * current module is parsed. They may also be declared in more than
928  * one statement. So we need to keep track of the current size of each
929  * common encountered in the current module with a mapping from entity
930  * to integer, common_size_map.
931  *
932  * At the end of the declaration phase, common sizes can be either set
933  * if yet unknown, or compared for equality with a pre-defined size.
934  */
936 
937 /* These tests are needed to check area consistency when dumping or
938  * printing a symbol table.
939  */
941 {
943  && !heap_area_p(c)
944  && !stack_area_p(c));
945 }
946 
948 {
949  pips_assert("common_size_map is undefined",
952 }
953 
955 {
959  }
960  else {
961  /* Problems:
962  * - this routine may be called from ParserError()... which should not
963  * be called recursively
964  * - but it maight also be called from somewhere else and ParserError()
965  * then should be called
966  * A second reset routine must be defined.
967  */
968  ParserError("reset_common_size_map", "Resetting a resetted variable!\n");
969  }
970 }
971 
973 {
977  }
978 }
979 
981 {
982  bool defined = false;
983 
984  defined = ( (hash_get(common_size_map,(char *) a))
986 
987  return defined;
988 }
989 
991 {
992  size_t size;
993 
994  if((size = (size_t) hash_get(common_size_map,(char *) a))
995  == (size_t) HASH_UNDEFINED_VALUE) {
996  pips_internal_error("common_size_map uninitialized for common %s",
997  entity_name(a));
998  }
999 
1000  return size;
1001 }
1002 
1003 void
1005 {
1006  (void) hash_put(common_size_map, (char *) a, (char *) (size));
1007 }
1008 
1009 void
1010 update_common_to_size(entity a, size_t new_size)
1011 {
1012  (void) hash_update(common_size_map, (char *) a, (char *) (new_size));
1013 }
1014 
1015 /* updates the common entity if necessary with the common prefix
1016  */
1017 static entity
1019 {
1020  if (!entity_common_p(c))
1021  {
1022  if (type_undefined_p(entity_type(c)))
1023  {
1025  entity_storage(c) =
1028  StaticArea, 0, NIL)));
1031  }
1032  }
1033 
1034  return c;
1035 }
1036 
1037 /* MakeCommon:
1038  * This function creates a common block. pips creates static common
1039  * blocks. This is not true in the ANSI standard stricto sensu, but
1040  * true in most implementations.
1041  *
1042  * A common declaration can be made out of several common statements.
1043  * MakeCommon() is called for each common statement, although it only
1044  * is useful the first time.
1045  */
1046 entity
1048 {
1049  e = make_common_entity(e);
1050 
1051  /* common e may already exist because it was encountered
1052  * in another module
1053  * but not have been registered as known by the current module.
1054  * It may also already exist because it was encountered in
1055  * the *same* module, but AddEntityToDeclarations() does not
1056  * duplicate declarations.
1057  */
1059 
1060  /* FI: for a while, common sizes were *always* reset to 0, even when
1061  * several common statements were encountered in the same module for
1062  * the same common. This did not matter because offsets in commons are
1063  * recomputed once variable types and dimensions are all known.
1064  */
1065  if(!common_to_defined_size_p(e))
1066  set_common_to_size(e, 0);
1067 
1068  return e;
1069 }
1070 entity
1071 NameToCommon(string n)
1072 {
1073  string c_name = strdup(concatenate(COMMON_PREFIX, n, NULL));
1075  string prefixes[] = {"", MAIN_PREFIX, BLOCKDATA_PREFIX, NULL};
1076  string nature[] = {"function or subroutine", "main", "block data"};
1077  int i = 0;
1078 
1079  c = MakeCommon(c);
1080  free(c_name);
1081 
1082  /* Check for potential conflicts */
1083  for(i=0; prefixes[i]!=NULL; i++) {
1084  string name = strdup(concatenate(prefixes[i], n, NULL));
1086 
1087  if(!entity_undefined_p(ce)) {
1088  user_warning("NameToCommon", "Identifier %s used for a common and for a %s\n",
1089  n, nature[i]);
1090  }
1091 
1092  free(name);
1093  }
1094 
1095  return c;
1096 }
1097 
1098 /*
1099  * This function adds a variable v to a common block c. v's storage
1100  * must be undefined.
1101  *
1102  * c's size used to be indirectly updated by CurrentOffsetOfArea() but
1103  * this is meaningless because v's type and dimensions are
1104  * unknown. The layouts of commons are updated later by
1105  * update_common_sizes() called from EndOfProcedure().
1106  */
1107 void
1109 {
1110  entity new_v = entity_undefined;
1111  type ct = entity_type(c);
1112  area ca = type_area(ct);
1113 
1114  if (entity_storage(v) != storage_undefined) {
1115  if(intrinsic_entity_p(v)) {
1117  entity_local_name(v));
1118  user_warning("AddVariableToCommon",
1119  "Intrinsic %s overloaded by variable %s between line %d and %d\n",
1121  if(type_undefined_p(entity_type(new_v))) {
1122  entity_type(new_v) = ImplicitType(new_v);
1123  }
1124  }
1125  else if(storage_rom_p(entity_storage(v))) {
1126  user_warning("AddVariableToCommon",
1127  "Module or parameter %s declared in common %s between line %d and %d\n",
1129  ParserError("AddVariableToCommon",
1130  "Ill. decl. of function or subroutine in a common\n");
1131  }
1132  else {
1134 
1136  pips_user_warning("Variable %s has conflicting requirements"
1137  " for storage (e.g. it appears in a DATA"
1138  " and in a COMMON statement in a non "
1139  "BLOCKDATA module\n", entity_local_name(v));
1140  ParserError("AddVariableToCommon", "Storage conflict\n");
1141  }
1142  else {
1143  if(entity_blockdata_p(m)) {
1144  pips_user_warning("ANSI extension: specification statements"
1145  " after DATA statement for variable %s\n",
1146  entity_local_name(v));
1147  ParserError("AddVariableToCommon", "Storage conflict\n");
1148  }
1149  else {
1150  user_warning("AddVariableToCommon",
1151  "Storage tag=%d for entity %s\n",
1153  FatalError("AddVariableToCommon", "storage already defined\n");
1154  }
1155  }
1156  }
1157  }
1158  else {
1159  new_v = v;
1160  }
1161 
1162  DeclareVariable(new_v,
1163  type_undefined,
1164  NIL,
1167  0, // UNKNOWN_RAM_OFFSET?
1168  NIL)))),
1169  value_undefined);
1170 
1171  area_layout(ca) = gen_nconc(area_layout(ca), CONS(ENTITY, v, NIL));
1172 }
1173 
1174 /*
1175  * This function computes the current offset of the area a passed as
1176  * argument. The length of the variable v is also computed and then added
1177  * to a's offset. The initial offset is returned to the calling function.
1178  * The layout of the common is updated.
1179  *
1180  * Note FI: this function is called too early by the Fortran parser
1181  * because a DIMENSION or a Type statement can modify both the basic
1182  * type and the dimensions of variable v.
1183  *
1184  * I do not understand why the Static and Dynamic area sizes are not recorded
1185  * by a call to update_common_to_size(). Maybe because it is not necessary
1186  * because they are local to the current procedure and hence area_size can be
1187  * directly be used. But this is not consistent with other uses of the
1188  * common_size_map...
1189  *
1190  * Note: the useful part of this function has been named
1191  * current_offset_of_area(0 and moved into ri-util. This function
1192  * seems about obsolete and never used with Fortran common. Most of
1193  * its call sites in syntax have been commented out.
1194  */
1196 {
1197  int OldOffset;
1198  type ta = entity_type(a);
1199  area aa = type_area(ta);
1200 
1201  if(top_level_entity_p(a)) {
1202  OldOffset = common_to_size(a);
1203  (void) update_common_to_size(a, OldOffset+SafeSizeOfArray(v));
1204  }
1205  else {
1206  /* the local areas are StaticArea, DynamicArea, HeapArea, StackArea */
1207  OldOffset = area_size(aa);
1208  area_size(aa) = OldOffset+SafeSizeOfArray(v);
1209  }
1210 
1211  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1212  return OldOffset;
1213 }
1214 
1216 {
1217  list commons = NIL;
1218 
1219  HASH_MAP(k, v,{
1220  entity c = (entity) k;
1221  commons = arguments_add_entity(commons, c);
1222  },
1223  common_size_map);
1224 
1225  sort_list_of_entities(commons);
1226 
1227  FOREACH(ENTITY, c, commons)
1228  {
1229  intptr_t s = common_to_size(c);
1230  type tc = entity_type(c);
1231  area ac = type_area(tc);
1232 
1233  pips_assert("update_common_sizes", s != (intptr_t) HASH_UNDEFINED_VALUE);
1234 
1235  if(area_size(ac) == 0) {
1236  area_size(ac) = s;
1237  pips_debug(1, "set size %zd for common %s\n", s, entity_name(c));
1238  }
1239  else if (area_size(ac) != s) {
1240  /* I'm afraid this warning might be printed because area_size is given
1241  * a wrong value by CurrentOffsetOfArea().
1242  */
1243  user_warning("update_common_sizes",
1244  "inconsistent size (%d and %d) for common /%s/ in %s\n"
1245  "Best results are obtained if all instances of a "
1246  "COMMON are declared the same way.\n",
1247  area_size(ac), s, module_local_name(c),
1248  CurrentPackage);
1249  if(area_size(ac) < s)
1250  area_size(ac) = s;
1251  }
1252  else {
1253  debug(1, "update_common_sizes",
1254  "reset size %d for common %s\n", s, entity_name(c));
1255  }
1256  }
1257  // Postpone the resetting because DynamicArea is updated till EndOfProcedure()
1258  /* reset_common_size_map(); */
1259 
1260  gen_free_list(commons);
1261 }
1262 ␌
1263 /* local variables for implicit type implementation */
1264 static tag tag_implicit[26];
1265 static size_t int_implicit[26];
1266 
1267 /* this function initializes the data structure used to compute implicit
1268 types */
1269 
1270 void
1272 {
1276 }
1277 
1278 /* this function updates the data structure used to compute implicit
1279 types. the implicit type for the range of letters defined by lettre_d
1280 and lettre_f has tag t and length l. tag is_basic_string is temporarely
1281 forbidden. */
1282 
1283 void
1284 cr_implicit(t, l, lettre_d, lettre_f)
1285 tag t;
1286 int l;
1287 int lettre_d, lettre_f;
1288 {
1289  int i;
1290 
1291  /*
1292  if (t == is_basic_string)
1293  ParserError("cr_implicit",
1294  "Unsupported implicit character declaration\n");
1295  */
1296 
1297  if ((! IS_UPPER(lettre_d)) || (! IS_UPPER(lettre_f)))
1298  FatalError("cr_implicit", "bad char\n");
1299 
1300  for (i = lettre_d-'A'; i <= lettre_f-'A'; i += 1) {
1301  tag_implicit[i] = t;
1302  int_implicit[i] = l;
1303  }
1304 }
1305 
1306 /* This function computes the Fortran implicit type of entity e. The first
1307  * letter of e's name is used.
1308  *
1309  * It should be now called FortranImplicitType()
1310  */
1312 {
1313  int i;
1314  const char* s = entity_local_name(e);
1315  type t = type_undefined;
1316  value v = value_undefined;
1317 
1318  if (s[0] == '_')
1319  s++;
1320 
1321  if (!(IS_UPPER((int)s[0]))) {
1322  pips_internal_error("[ImplicitType] bad name: %s", s);
1323  FatalError("ImplicitType", "\n");
1324  }
1325 
1326  i = (int) (s[0] - 'A');
1327 
1328  switch(tag_implicit[i]) {
1329  case is_basic_int:
1330  case is_basic_float:
1331  case is_basic_logical:
1332  case is_basic_complex:
1333  t = MakeTypeVariable(make_basic(tag_implicit[i], (void *) int_implicit[i]), NIL);
1334  break;
1335  case is_basic_string:
1339  break;
1340  case is_basic_overloaded:
1341  FatalError("ImplicitType", "Unsupported overloaded tag for basic\n");
1342  default:
1343  FatalError("ImplicitType", "Illegal tag for basic\n");
1344  }
1345  /*
1346  return(MakeTypeVariable(make_basic(tag_implicit[i], int_implicit[i]), NIL));
1347  */
1348  return t;
1349 }
1350 
1351 /* This function checks that entity e has an undefined or an implicit type
1352  * which can be superseded by another declaration. The first
1353  * letter of e's name is used to determine the implicit type.
1354  * The implicit type of a functional entity is its result type.
1355  */
1356 
1357 bool
1359 {
1360  int i;
1361  const char* s = entity_local_name(e);
1362  type t = entity_type(e);
1363  basic b;
1364 
1365  if(t == type_undefined)
1366  return true;
1367 
1368  if(type_functional_p(t))
1370 
1371  if (s[0] == '_')
1372  s++;
1373  if (!(IS_UPPER((int)s[0]))) {
1374  pips_internal_error("bad name: %s", s);
1375  FatalError("implicit_type_p", "\n");
1376  }
1377  i = (int) (s[0] - 'A');
1378 
1379  /* ASSERT */
1380  if (!type_variable_p(t))
1381  pips_internal_error("expecting a variable for %s, got tag %d",
1382  entity_name(e), type_tag(t));
1383 
1384  b = variable_basic(type_variable(t));
1385 
1386  if((tag)basic_tag(b) != tag_implicit[i])
1387  return false;
1388 
1389  switch(basic_tag(b)) {
1390  case is_basic_int: return (size_t)basic_int(b)==int_implicit[i];
1391  case is_basic_float: return (size_t)basic_float(b)==int_implicit[i];
1392  case is_basic_logical: return (size_t)basic_logical(b)==int_implicit[i];
1393  case is_basic_complex: return (size_t)basic_complex(b)==int_implicit[i];
1394  case is_basic_overloaded:
1395  pips_internal_error("unexpected overloaded basic tag");
1396  case is_basic_string:
1397  return (size_t)constant_int(value_constant(basic_string(b)))==
1398  int_implicit[i];
1399  default:
1400  pips_internal_error("illegal basic tag");
1401  }
1402  return false; /* to please gcc */
1403 }
1404 
1405 /* If an IMPLICIT statement is encountered, it must be applied to
1406  * the formal parameters, and, if the current module is a function,
1407  * to the function result type and to the variable used internally
1408  * when a value is assigned to the function (see MakeCurrentFunction)
1409  */
1410 void
1412 {
1415  type tm = entity_type(m);
1416  type tr = type_undefined;
1417 
1418  pips_debug(8, "Begin for module %s\n",
1419  module_local_name(m));
1420 
1421  MAP(ENTITY, v, {
1423  if(!implicit_type_p(v)) {
1424  free_type(entity_type(v));
1425  entity_type(v) = ImplicitType(v);
1426 
1427  pips_debug(8, "Retype formal parameter %s\n",
1428  entity_local_name(v));
1429  }
1430  }
1434  {
1435  pips_debug(8, "Cannot retype entity %s: warning!!!\n",
1436  entity_local_name(v));
1437  pips_user_warning("Cannot retype variable or function %s."
1438  " Move up the implicit statement at the beginning of declarations.\n",
1439  entity_local_name(v));
1440  }
1441  else {
1442  pips_debug(8, "Ignore entity %s\n",
1443  entity_local_name(v));
1444  }
1445  }, vars);
1446 
1447  /* If the current module is a function, its type should be updated. */
1448 
1449  pips_assert("Should be a functional type", type_functional_p(tm));
1450 
1451  /* The function signature is computed later by UpdateFunctionalType()
1452  * called from EndOfProcedure: there should be no parameters in the type.
1453  */
1454  pips_assert("Parameter type list should be empty",
1456 
1458  if(type_variable_p(tr)) {
1459  if(!implicit_type_p(m)) {
1461  free_type(tr);
1463  pips_debug(8, "Retype result of function %s\n",
1464  module_local_name(m));
1465 
1466  /* Update type of internal variable used to store the function result */
1468  != entity_undefined) {
1469  free_type(entity_type(r));
1470  entity_type(r) = ImplicitType(r);
1471  pips_assert("Result and function result types should be equal",
1473  entity_type(r)));
1474  }
1475  else {
1476  pips_internal_error("Result entity should exist!");
1477  }
1478  }
1479  }
1480  else if (type_void_p(tr)) {
1481  /* nothing to be done: subroutine or main */
1482  }
1483  else
1484  pips_internal_error("Unexpected type with tag = %d",
1485  type_tag(tr));
1486 
1487  pips_assert("Parameter type list should still be empty",
1489 
1490  pips_debug(8, "End for module %s\n",
1491  module_local_name(m));
1492 }
1493 ␌
1494 /* this function creates a type that represents a fortran type. its basic
1495 is an int (the length of the fortran type) except in case of strings
1496 where the type might be unknown, as in:
1497 
1498  CHARACTER*(*) PF
1499 
1500 t is a tag, eg: INTEGER, REAL, ...
1501 
1502 v is a value that represents the length in bytes of the type. */
1503 
1504 type
1506 tag t;
1507 value v;
1508 {
1509  basic b;
1510  size_t l;
1511 
1512  if (t == is_basic_string) {
1513  if (v == value_undefined) {
1514  l = DefaultLengthOfBasic(t);
1516  make_constant(is_constant_int, (void *) l));
1517  }
1518  b = make_basic(t, v);
1519  }
1520  else {
1521  bool ok = false;
1522  l = (v == value_undefined) ? DefaultLengthOfBasic(t) :
1524 
1525  /* Check compatibility between type and byte length */
1526  switch (t)
1527  {
1528  case is_basic_int:
1529  if(get_bool_property("PARSER_ACCEPT_ANSI_EXTENSIONS"))
1530  /* Accept INTEGER*1 for SIMD parallelizer and INTEGER*2 for
1531  legacy code and INTEGER*8 for 64 bit machines */
1532  ok = l==1 || l==2 || l==4 || l==8;
1533  else
1534  ok = l==4;
1535  break;
1536  case is_basic_float:
1537  ok = l==4 || l==8;
1538  break;
1539  case is_basic_logical:
1540  ok = l==1 || l==2 || l==4 || l==8;
1541  break;
1542  case is_basic_complex:
1543  ok = l==8 || l==16;
1544  break;
1545  case is_basic_string:
1546  break;
1547  case is_basic_overloaded:
1548  default: break;
1549  }
1550  if(!ok) {
1551  ParserError("Declaration", "incompatible type length");
1552  }
1553  b = make_basic(t, (void *) l);
1554  }
1555 
1556  return(MakeTypeVariable(b, NIL));
1557 }
1558 ␌
1559 /* This function computes the numerical offset of a variable element from
1560 the begining of the variable. The variable must have numerical bounds for
1561 this function to work. It core dumps for adjustable arrays such as formal
1562 parameters. */
1563 
1564 int
1566 reference r;
1567 {
1568  cons *pi;
1569  int idim, iindex, pid, o, ilowerbound;
1570 
1571  pi = reference_indices(r);
1572 
1573  for (idim = 0, pid = 1, o = 0; pi != NULL; idim++, pi = CDR(pi)) {
1574  iindex = ExpressionToInt(EXPRESSION(CAR(pi)));
1575  ilowerbound = ValueOfIthLowerBound((reference_variable(r)), idim+1);
1576  /* Use a trick to retrieve the size in bytes of one array element
1577  * and use the size of the previous dimension
1578  */
1579  pid *= SizeOfIthDimension((reference_variable(r)), idim);
1580  o += ((iindex-ilowerbound)*pid);
1581  }
1582 
1583  return(o);
1584 }
1585 
1586 
1587 
1588 /* this function returns the size of the ith lower bound of a variable e. */
1589 
1590 int
1592 entity e;
1593 int i;
1594 {
1595  cons * pc;
1596 
1597  pips_assert("ValueOfIthLowerBound", type_variable_p(entity_type(e)));
1598 
1599  pips_assert("ValueOfIthLowerBound", i >= 1 && i <= 7);
1600 
1602 
1603  while (pc != NULL && --i > 0)
1604  pc = CDR(pc);
1605 
1606  if (pc == NULL)
1607  ParserError("SizeOfIthLowerBound", "not enough dimensions\n");
1608 
1609  return(ExpressionToInt((dimension_lower(DIMENSION(CAR(pc))))));
1610 }
1611 ␌
1612 /* This function computes the size of a range, ie. the number of
1613  * iterations that would be done by a loop with this range.
1614  *
1615  * See also range_count().
1616  */
1617 
1618 int
1620 range r;
1621 {
1622  int ir, il, iu, ii;
1623 
1624  il = ExpressionToInt(range_lower(r));
1625  iu = ExpressionToInt(range_upper(r));
1627 
1628  if (ii == 0)
1629  FatalError("SizeOfRange", "null increment\n");
1630 
1631  ir = ((iu-il)/ii)+1;
1632 
1633  if (ir < 0)
1634  FatalError("SizeOfRange", "negative value\n");
1635 
1636  return(ir);
1637 }
1638 
1639 
1640 
1641 /* FI: should be moved in ri-util;
1642  * this function returns true if e is a zero dimension variable of basic
1643  * type integer
1644  */
1645 
1646 int
1648 entity e;
1649 {
1650  if (type_variable_p(entity_type(e))) {
1652 
1654  return(true);
1655  }
1656 
1657  return(false);
1658 }
1659 
1660 ␌
1661 /*
1662  * Check... and fix, if needed!
1663  *
1664  * Only user COMMONs are checked. The two implicit areas, DynamicArea and
1665  * StaticArea, have not been initialized yet (see ComputeAddress() and the
1666  * calls in EndOfProcedure()).
1667  */
1668 
1669 void
1671 entity m;
1672 {
1673  list decls = NIL;
1674  list sorted_decls = NIL;
1675 
1676  pips_assert("update_user_common_layouts", entity_module_p(m));
1677 
1679  sorted_decls = gen_append(decls, NIL);
1680  sort_list_of_entities(sorted_decls);
1681 
1682  ifdebug(1) {
1683  pips_debug(1, "\nDeclarations for module %s\n", module_local_name(m));
1684 
1685  /* List of implicitly and explicitly declared variables,
1686  functions and areas */
1687 
1688  pips_debug(1, "%s\n", ENDP(decls)?
1689  "* empty declaration list *\n\n": "Variable list:\n\n");
1690 
1691  MAP(ENTITY, e,
1692  fprintf(stderr, "Declared entity %s\n", entity_name(e)),
1693  sorted_decls);
1694 
1695  /* Structure of each area/common */
1696  if(!ENDP(decls)) {
1697  (void) fprintf(stderr, "\nLayouts for areas (commons):\n\n");
1698  }
1699  }
1700 
1701  MAP(ENTITY, e, {
1702  if(type_area_p(entity_type(e))) {
1703  ifdebug(1) {
1704  print_common_layout(stderr, e, true);
1705  }
1706  if(!entity_special_area_p(e)) {
1707  /* User declarations of commons imply the offset and
1708  cannot conflict with equivalences, whereas static and
1709  dynamic variables must first comply with
1710  equivalences. Hence the layouts of user commons must be
1711  updated before equivalences are satisfied whereas
1712  layouts of the static and dynamic areas must be
1713  satisfied after the equiavelences have been
1714  processed. */
1715  if(update_common_layout(m, e)) {
1716  ifdebug(1) {
1717  print_common_layout(stderr, e, true);
1718  }
1719  }
1720  }
1721  }
1722  }, sorted_decls);
1723 
1724  gen_free_list(sorted_decls);
1725 
1726  pips_debug(1, "End of declarations for module %s\n\n",
1727  module_local_name(m));
1728 }
1729 
1730 
1731 /* (Re)compute offests of all variables allocated in common c from module m
1732  * and update (if necessary) the size of common c for the *whole* program or
1733  * set of modules in the current workspace. As a consequence, warning messages
1734  * unfortunately depend on the parsing order.
1735  *
1736  * Offsets used to be computed a first time when the common declaration is
1737  * encountered, but the variables may be typed or dimensionned *later*.
1738  *
1739  * This function is correct only if no equivalenced variables have been
1740  * added to the layout. It should not be used for the static and dynamic
1741  * areas (see below).
1742  *
1743  */
1744 
1745 bool
1747 entity m;
1748 entity c;
1749 {
1750  /* It is assumed that:
1751  * - each variable appears only once
1752  * - variables appears in their declaration order
1753  * - all variables that belong to the same module appear contiguously
1754  * (i.e. declarations are concatenated on a module basis)
1755  * - variables wich are located in the common thru an EQUIVALENCE statement
1756  * are *not* (yet) in its layout
1757  * It also was wrongly assumed that each common would have at least two members.
1758  */
1759 
1760  list members = area_layout(type_area(entity_type(c)));
1761  entity previous = entity_undefined;
1762  bool updated = false;
1763  list cm = list_undefined;
1764 
1765  ifdebug(8) {
1766  debug(8, "update_common_layout",
1767  "Begin for common /%s/ with members\n", module_local_name(c));
1768  print_arguments(members);
1769  }
1770 
1771  /* the layout field does not seem to be filled in for STATIC and DYNAMIC */
1772  if(!ENDP(members)) {
1773  /* skip variables which do not belong to the module of interest */
1774  /*
1775  for(previous = ENTITY(CAR(members)); !ENDP(members) && !variable_in_module_p(previous, m);
1776  POP(members))
1777  previous = ENTITY(CAR(members));
1778  */
1779  do {
1780  previous = ENTITY(CAR(members));
1781  POP(members);
1782  } while(!ENDP(members) && !variable_in_module_p(previous, m));
1783 
1784  for(cm = members; !ENDP(cm); POP(cm)) {
1785  entity current = ENTITY(CAR(cm));
1786 
1787  pips_assert("update_common_layout",
1789 
1790  if(!variable_in_module_p(current, m)) {
1791  break;
1792  }
1793 
1794  if(ram_offset(storage_ram(entity_storage(previous)))+SafeSizeOfArray(previous) >
1796  /* This should now always be the case. The offset within the common is
1797  * no longer computed on the fly.
1798  */
1800  ram_offset(storage_ram(entity_storage(previous)))+SafeSizeOfArray(previous);
1801 
1802  /* If c really is a common, check its size because it may have increased.
1803  * Note that decreases are not taken into account although they might
1804  * occur as well.
1805  */
1806  /* Too late, if the common only contains one element because the MAPL
1807  * has not been entered at all if we are dealing wih te last parsed
1808  * module... which is always the case up to now!
1809  */
1811  int s = common_to_size(c);
1814  if(s < new_s) {
1815  (void) update_common_to_size(c, new_s);
1816  }
1817  }
1818  updated = true;
1819  }
1820  else {
1821  /* Variables declared in the static and dynamic areas were
1822  assigned offsets dynamically. The result may be
1823  ok. */
1824  pips_assert("Offsets should always be updated",entity_special_area_p(c));
1825  }
1826 
1827  previous = current;
1828  }
1829 
1830 
1831  /* Special case: only one element in the common for the current procedure
1832  * (and the current procedure is last one declared - which is not so
1833  * special)
1834  */
1835  if(ENDP(members)) {
1836  pips_assert("Previous must in declared in the current module",
1837  variable_in_module_p(previous, m));
1838  /* If c really is a common, check its size because it may have increased.
1839  * Note that decreases are not taken into account although they might
1840  * occur as well.
1841  */
1842  if(top_level_entity_p(c)) {
1843  int s = common_to_size(c);
1844  int new_s = ram_offset(storage_ram(entity_storage(previous)))
1845  +SafeSizeOfArray(previous);
1846  if(s < new_s) {
1847  (void) update_common_to_size(c, new_s);
1848  updated = true;
1849  }
1850  }
1851  }
1852  }
1853  debug(8, "update_common_layout",
1854  "End for common /%s/: updated=%s\n",
1855  module_local_name(c), bool_to_string(updated));
1856 
1857  return updated;
1858 }
1859 
1860 
1861 /* Problem: A functional global entity may be referenced without
1862  parenthesis or CALL keyword in a function or subroutine call as
1863  functional parameter. FindOrCreateEntity() will return a local variable
1864  which already is or will be in the ghost variable list. When ghost
1865  variables are eliminated the data structure using this local variable
1866  contain a pointer to nowhere.
1867 
1868  However, SafeFindOrCreateEntity() does not solve this problem
1869  entirely. The call with a functional parameter may occur before a call
1870  to this functional parameter lets us find out it is indeed functional.
1871 
1872  Morevover, SafeFindOrCreateEntity() does create new problem because
1873  intrinsic overloading is ignored. Fortran does not use reserved words
1874  and a local variable may have the same name as an intrinsics. The
1875  intrinsic entity returned by this function must later be converted into
1876  a local variable when it is found out that the user really wanted a
1877  local variable, for instance because it appears in a lhs. So intrinsics
1878  are not searched anymore.
1879 
1880  This is yet another reason to split the building of the internal
1881  representation into three phases. The first phase should not assume any
1882  default type or storage. Then, type and storage are consolidated
1883  together and default type and storage are only used when no information
1884  is available. The last phase should be kind of a link edit. The
1885  references to really global variables and intrinsics have to be fixed
1886  by scanning the intermediate representation.
1887 
1888  See also FindOrCreateEntity(). */
1889 
1890 entity
1892  const char* package, /* le nom du package */
1893  const char* name /* le nom de l'entite */)
1894 {
1896 
1897  if(strcmp(package, TOP_LEVEL_MODULE_NAME) == 0) {
1898  /* This is a request for a global variable */
1899  e = FindEntity(package , name );
1900  }
1901  else { /* May be a local or a global entity */
1902  /* This is a request for a local or a global variable. If a local
1903  variable with name "name" exists, return it. */
1904  string full_name = concatenate(package, MODULE_SEP_STRING, name, NULL);
1906 
1907  if(entity_undefined_p(le)) { /* No such local variable yet. */
1908  /* Does a global variable with the same name exist and is it
1909  in the package's scope? */
1910 
1911  /* let s hope concatenate s buffer lasts long enough... */
1912  string full_top_name = concatenate(TOP_LEVEL_MODULE_NAME,
1913  MODULE_SEP_STRING, name, NULL);
1914 
1915  entity fe = gen_find_tabulated(full_top_name, entity_domain);
1916 
1917  if(entity_undefined_p(fe)) {
1918  /* There is no such global variable. Let's make a new local variable */
1922  }
1923  else { /* A global entity with the same local name exists. */
1925  && entity_is_argument_p(fe,
1927  /* There is such a global variable and it is in the proper scope */
1928  e = fe;
1929  }
1930  else if(false && intrinsic_entity_p(fe)) {
1931  /* Here comes the mistake if the current_module_entity is not
1932  yet defined as is the case when formal parameters are
1933  parsed. Intrinsics may wrongly picked out. See capture01.f, variable DIM. */
1934  e = fe;
1935  }
1936  else { /* The global variable is not be in the scope. */
1937  /* A local variable must be created. It is later replaced by a
1938  global variable if necessary and becomes a ghost variable. */
1942  }
1943  }
1944  }
1945  else { /* A local variable has been found */
1946  if(ghost_variable_entity_p(le)) {
1947  string full_top_name = concatenate(TOP_LEVEL_MODULE_NAME,
1948  MODULE_SEP_STRING, name, NULL);
1949 
1950  entity fe = gen_find_tabulated(full_top_name, entity_domain);
1951 
1952  pips_assert("Entity fe must be defined", !entity_undefined_p(fe));
1953  e = fe;
1954  }
1955  else { /* le is not a ghost variable */
1956  e = le;
1957  }
1958  }
1959  }
1960 
1961  return e;
1962 }
1963 
1964 /* FI: I do not understand the naming here, or the parameter. The name
1965  * of the new variable must be a global name, whereas the name of the
1966  * area is a local name. And the area does not have to be the stack
1967  * area...
1968  */
1969 void add_entity_to_declarations (string name, string area_name, enum basic_utype tag,
1970  void* val) {
1971  entity new_e = FindOrCreateTopLevelEntity (name);
1972  basic b = make_basic (tag, val);
1973  variable v = make_variable (b, NIL, NIL);
1974  entity_type (new_e) = make_type_variable (v);
1976  /* Why is this variable called "stack area" when it can be any area? */
1977  entity stack_area = FindEntity(module_name, area_name);
1979  stack_area,
1980  CurrentOffsetOfArea(stack_area, new_e),
1981  NIL));
1982  entity_storage (new_e) = s;
1983  value initial = make_value_unknown ();
1984  entity_initial (new_e) = initial;
1987 }
constant make_constant(enum constant_utype tag, void *val)
Definition: ri.c:406
value make_value_unknown(void)
Definition: ri.c:2847
value make_value_code(code _field_)
Definition: ri.c:2835
language make_language_fortran(void)
Definition: ri.c:1250
type make_type_variable(variable _field_)
Definition: ri.c:2715
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
storage make_storage_rom(void)
Definition: ri.c:2285
type copy_type(type p)
TYPE.
Definition: ri.c:2655
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
bool value_defined_p(value p)
Definition: ri.c:2797
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
area make_area(intptr_t a1, list a2)
Definition: ri.c:98
code make_code(list a1, string a2, sequence a3, list a4, language a5)
Definition: ri.c:353
void free_storage(storage p)
Definition: ri.c:2231
void free_type(type p)
Definition: ri.c:2658
storage make_storage_ram(ram _field_)
Definition: ri.c:2279
sequence make_sequence(list a)
Definition: ri.c:2125
constant copy_constant(constant p)
CONSTANT.
Definition: ri.c:359
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
void free_value(value p)
Definition: ri.c:2787
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
cons * arguments_add_entity(cons *a, entity e)
Definition: arguments.c:85
void const char const char const int
entity DynamicArea
These global variables are declared in ri-util/util.c.
Definition: area.c:57
entity HeapArea
Definition: area.c:59
entity StaticArea
Definition: area.c:58
entity StackArea
Definition: area.c:60
int DefaultLengthOfBasic(tag t)
Deals with constant expressions and constant entities.
Definition: constant.c:44
#define IS_UPPER(c)
Definition: declaration.c:76
static bool same_basic_and_scalar_p(type t1, type t2)
type_equal_p -> same_basic_and_scalar_p in latter...
Definition: declaration.c:615
int CurrentOffsetOfArea(entity a, entity v)
Definition: declaration.c:1195
void InitImplicit()
this function initializes the data structure used to compute implicit types
Definition: declaration.c:1271
void save_initialized_variable(entity v)
Definition: declaration.c:287
void AnalyzeData(list ldvr, list ldvl)
this function scans at the same time a list of datavar and a list of dataval.
Definition: declaration.c:352
void MakeVariableStatic(entity v, bool force_it)
Definition: declaration.c:245
void update_user_common_layouts(entity m)
Check...
Definition: declaration.c:1670
int SafeSizeOfArray(entity a)
This function should not be used outside of the syntax library because it depends on ParserError().
Definition: declaration.c:83
entity SafeFindOrCreateEntity(const char *package, const char *name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: declaration.c:1891
static hash_table common_size_map
Definition: declaration.c:935
bool update_common_layout(entity m, entity c)
(Re)compute offests of all variables allocated in common c from module m and update (if necessary) th...
Definition: declaration.c:1746
void update_common_to_size(entity a, size_t new_size)
Definition: declaration.c:1010
int OffsetOfReference(reference r)
This function computes the numerical offset of a variable element from the begining of the variable.
Definition: declaration.c:1565
int IsIntegerScalar(entity e)
FI: should be moved in ri-util; this function returns true if e is a zero dimension variable of basic...
Definition: declaration.c:1647
void InitAreas()
Definition: declaration.c:100
void update_common_sizes(void)
Definition: declaration.c:1215
int ValueOfIthLowerBound(entity e, int i)
this function returns the size of the ith lower bound of a variable e.
Definition: declaration.c:1591
void set_common_to_size(entity a, size_t size)
Definition: declaration.c:1004
void reset_common_size_map()
Definition: declaration.c:954
void add_entity_to_declarations(string name, string area_name, enum basic_utype tag, void *val)
FI: I do not understand the naming here, or the parameter.
Definition: declaration.c:1969
void cr_implicit(tag t, int l, int lettre_d, int lettre_f)
this function updates the data structure used to compute implicit types.
Definition: declaration.c:1284
void SaveCommon(entity c)
this function transforms a dynamic common into a static one.
Definition: declaration.c:295
void DeclareVariable(entity e, type t, list d, storage s, value v)
void DeclareVariable(e, t, d, s, v): update entity e description as declaration statements are encoun...
Definition: declaration.c:670
static tag tag_implicit[26]
local variables for implicit type implementation
Definition: declaration.c:1264
void SaveEntity(entity e)
These two functions transform a dynamic variable into a static one.
Definition: declaration.c:178
void MakeDataStatement(list ldr, list ldv)
Receives as first input an implicit list of references, including implicit DO, and as second input an...
Definition: declaration.c:524
void reset_common_size_map_on_error()
Definition: declaration.c:972
bool implicit_type_p(entity e)
This function checks that entity e has an undefined or an implicit type which can be superseded by an...
Definition: declaration.c:1358
void ProcessSave(entity v)
Definition: declaration.c:282
static size_t int_implicit[26]
Definition: declaration.c:1265
static entity make_common_entity(entity c)
updates the common entity if necessary with the common prefix
Definition: declaration.c:1018
entity MakeCommon(entity e)
MakeCommon: This function creates a common block.
Definition: declaration.c:1047
void save_all_entities()
functions for the SAVE declaration
Definition: declaration.c:138
void DeclareIntrinsic(entity e)
Intrinsic e is used in the current module.
Definition: declaration.c:918
int SizeOfRange(range r)
This function computes the size of a range, ie.
Definition: declaration.c:1619
entity NameToCommon(string n)
Definition: declaration.c:1071
type ImplicitType(entity e)
This function computes the Fortran implicit type of entity e.
Definition: declaration.c:1311
void retype_formal_parameters()
If an IMPLICIT statement is encountered, it must be applied to the formal parameters,...
Definition: declaration.c:1411
void initialize_common_size_map()
Definition: declaration.c:947
size_t common_to_size(entity a)
Definition: declaration.c:990
void PrintData(cons *ldvr, cons *ldvl)
a debugging function, just in case ...
Definition: declaration.c:310
void DeclarePointer(entity ptr, entity pointed_array, list decl_dims)
Definition: declaration.c:546
type MakeFortranType(tag t, value v)
this function creates a type that represents a fortran type.
Definition: declaration.c:1505
void AddVariableToCommon(entity c, entity v)
This function adds a variable v to a common block c.
Definition: declaration.c:1108
bool common_to_defined_size_p(entity a)
Definition: declaration.c:980
bool fortran_relevant_area_entity_p(entity c)
These tests are needed to check area consistency when dumping or printing a symbol table.
Definition: declaration.c:940
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static char * package
The package name in which functions will be defined.
Definition: genLisp.c:59
void free(void *)
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list gen_append(list l1, const list l2)
Definition: list.c:471
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
statement make_call_statement(string, list, entity, string)
This function is limited to intrinsics calls...
Definition: statement.c:1274
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
void hash_update(hash_table htp, const void *key, const void *val)
update key->val in htp, that MUST be pre-existent.
Definition: hash.c:491
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define full_name(dir, name)
Definition: compile.c:414
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define user_warning(fn,...)
Definition: misc-local.h:262
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define COMMON_PREFIX
Definition: naming-local.h:34
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define MAIN_PREFIX
Definition: naming-local.h:32
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define BLOCKDATA_PREFIX
Definition: naming-local.h:35
#define STACK_AREA_LOCAL_NAME
Definition: naming-local.h:72
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define MODULE_SEP_STRING
Definition: naming-local.h:30
#define HEAP_AREA_LOCAL_NAME
Definition: naming-local.h:71
void print_arguments(list args)
Definition: naming.c:228
string bool_to_string(bool)
Definition: string.c:243
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
@ hash_pointer
Definition: newgen_hash.h:32
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
int tag
TAG.
Definition: newgen_types.h:92
#define string_undefined
Definition: newgen_types.h:40
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define DATAVAL(x)
DATAVAL.
#define datavar_nbelements(x)
#define dataval_constant(x)
#define DATAVAR(x)
DATAVAR.
#define dataval_nboccurrences(x)
#define datavar_variable(x)
string basic_to_string(basic)
Definition: type.c:87
bool ghost_variable_entity_p(entity e)
Definition: procedure.c:292
char * PrevComm
Definition: reader.c:152
int iPrevComm
Definition: reader.c:153
static int tc
Internal variables
Definition: reindexing.c:107
#define UNBOUNDED_DIMENSION_NAME
Definition: ri-util-local.h:74
#define STATIC_INITIALIZATION_NAME
Definition: ri-util-local.h:79
#define make_entity(n, t, s, i)
#define DATA_LIST_FUNCTION_NAME
Definition: ri-util-local.h:81
#define UNKNOWN_RAM_OFFSET
@ ENTITY_STATIC_AREA
@ ABSTRACT_LOCATION
@ ENTITY_DYNAMIC_AREA
@ ENTITY_STACK_AREA
@ ENTITY_HEAP_AREA
bool dynamic_area_p(entity aire)
Definition: area.c:68
void print_common_layout(FILE *fd, entity c, bool debug_p)
Definition: area.c:207
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86
int current_offset_of_area(entity a, entity v)
Definition: area.c:174
bool static_area_p(entity aire)
Definition: area.c:77
bool entity_special_area_p(entity e)
Definition: area.c:154
void fprint_functional(FILE *fd, functional f)
This function is called from c_parse() via ResetCurrentModule() and fprint_environment()
Definition: declarations.c:227
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
bool intrinsic_entity_p(entity e)
Definition: entity.c:1272
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
code entity_code(entity e)
Definition: entity.c:1098
entity FindOrCreateTopLevelEntity(const char *name)
Return a top-level entity.
Definition: entity.c:1603
bool entity_function_p(entity e)
Definition: entity.c:724
static string prefixes[]
Definition: entity.c:1433
void sort_list_of_entities(list l)
sorted in place.
Definition: entity.c:1358
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool entity_blockdata_p(entity e)
Definition: entity.c:712
bool entity_module_p(entity e)
Definition: entity.c:683
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
Definition: entity.c:1311
bool entity_common_p(entity e)
Definition: entity.c:718
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
expression MakeNullaryCall(entity f)
Creates a call expression to a function with zero arguments.
Definition: expression.c:331
bool formal_label_replacement_p(entity)
Definition: variable.c:1797
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
Definition: size.c:87
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
int ExpressionToInt(expression)
this function computes the value of an integer constant expression and returns it to the calling func...
Definition: size.c:562
int basic_type_size(basic)
See also SizeOfElements()
Definition: type.c:1074
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
Definition: variable.c:1113
bool variable_entity_p(entity)
variable.c
Definition: variable.c:70
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
int SizeOfIthDimension(entity, int)
this function returns the size of the ith dimension of a variable e.
Definition: size.c:453
bool type_equal_p(type, type)
Definition: type.c:547
bool variable_in_module_p(entity, entity)
This test can only be applied to variables, not to functions, subroutines or commons visible from a m...
Definition: variable.c:1610
void discard_module_declaration_text(entity)
Discard the decls_text string of the module code to make the prettyprinter ignoring the textual decla...
Definition: variable.c:1696
bool basic_equal_p(basic, basic)
Definition: type.c:927
bool formal_parameter_p(entity)
Definition: variable.c:1489
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
#define type_functional_p(x)
Definition: ri.h:2950
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_undefined
Definition: ri.h:3016
basic_utype
Definition: ri.h:570
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_int
Definition: ri.h:571
@ is_basic_logical
Definition: ri.h:573
@ is_basic_complex
Definition: ri.h:575
#define functional_result(x)
Definition: ri.h:1444
#define area_size(x)
Definition: ri.h:544
#define value_constant(x)
Definition: ri.h:3073
#define basic_int_p(x)
Definition: ri.h:614
#define reference_variable(x)
Definition: ri.h:2326
#define basic_int(x)
Definition: ri.h:616
#define range_upper(x)
Definition: ri.h:2290
#define storage_tag(x)
Definition: ri.h:2515
#define type_tag(x)
Definition: ri.h:2940
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define constant_int(x)
Definition: ri.h:850
#define type_functional(x)
Definition: ri.h:2952
#define value_unknown_p(x)
Definition: ri.h:3077
#define dimension_lower(x)
Definition: ri.h:980
#define basic_tag(x)
Definition: ri.h:613
@ is_constant_int
Definition: ri.h:817
#define type_variable(x)
Definition: ri.h:2949
#define entity_storage(x)
Definition: ri.h:2794
@ is_value_constant
Definition: ri.h:3033
#define code_declarations(x)
Definition: ri.h:784
#define range_increment(x)
Definition: ri.h:2292
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_storage_ram
Definition: ri.h:2492
#define type_undefined_p(x)
Definition: ri.h:2884
#define basic_undefined
Definition: ri.h:556
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define constant_int_p(x)
Definition: ri.h:848
#define expression_undefined
Definition: ri.h:1223
#define basic_logical(x)
Definition: ri.h:622
#define type_void_p(x)
Definition: ri.h:2959
#define entity_name(x)
Definition: ri.h:2790
#define area_layout(x)
Definition: ri.h:546
#define functional_parameters(x)
Definition: ri.h:1442
#define code_initializations(x)
Definition: ri.h:788
#define sequence_statements(x)
Definition: ri.h:2360
#define reference_indices(x)
Definition: ri.h:2328
#define value_code(x)
Definition: ri.h:3067
#define constant_call_p(x)
Definition: ri.h:860
#define variable_undefined_p(x)
Definition: ri.h:3096
#define type_area(x)
Definition: ri.h:2946
#define basic_float(x)
Definition: ri.h:619
#define range_lower(x)
Definition: ri.h:2288
#define variable_dimensions(x)
Definition: ri.h:3122
#define storage_ram(x)
Definition: ri.h:2521
#define type_undefined
Definition: ri.h:2883
#define basic_complex(x)
Definition: ri.h:628
#define type_area_p(x)
Definition: ri.h:2944
#define storage_rom_p(x)
Definition: ri.h:2525
#define entity_kind(x)
Definition: ri.h:2798
@ is_type_functional
Definition: ri.h:2901
@ is_type_variable
Definition: ri.h:2900
@ is_type_area
Definition: ri.h:2899
#define entity_type(x)
Definition: ri.h:2792
#define storage_return_p(x)
Definition: ri.h:2516
#define type_variable_p(x)
Definition: ri.h:2947
#define storage_undefined_p(x)
Definition: ri.h:2477
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define variable_basic(x)
Definition: ri.h:3120
#define statement_undefined
Definition: ri.h:2419
#define basic_string(x)
Definition: ri.h:631
#define ram_offset(x)
Definition: ri.h:2251
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
#define ifdebug(n)
Definition: sg.c:47
static bool ok
#define intptr_t
Definition: stdint.in.h:294
static size_t current
Definition: string.c:115
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define FatalError(f, m)
Definition: syntax-local.h:56
#define Warning(f, m)
extern char * getenv();
Definition: syntax-local.h:53
int line_e_I
Definition: parser.c:68
int line_b_I
Indicates where the current instruction (in fact statement) starts and ends in the input file and giv...
Definition: parser.c:68
bool ParserError(const char *f, const char *m)
Definition: parser.c:116
const char * CurrentPackage
the name of the current package, i.e.
Definition: parser.c:58