PIPS
declaration.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "parser_private.h"
#include "properties.h"
#include "misc.h"
#include "syntax.h"
+ Include dependency graph for declaration.c:

Go to the source code of this file.

Macros

#define IS_UPPER(c)   (isascii(c) && isupper(c))
 

Functions

int SafeSizeOfArray (entity a)
 This function should not be used outside of the syntax library because it depends on ParserError(). More...
 
void InitAreas ()
 
void save_all_entities ()
 functions for the SAVE declaration More...
 
void SaveEntity (entity e)
 These two functions transform a dynamic variable into a static one. More...
 
void MakeVariableStatic (entity v, bool force_it)
 
void ProcessSave (entity v)
 
void save_initialized_variable (entity v)
 
void SaveCommon (entity c)
 this function transforms a dynamic common into a static one. More...
 
void PrintData (cons *ldvr, cons *ldvl)
 a debugging function, just in case ... More...
 
void AnalyzeData (list ldvr, list ldvl)
 this function scans at the same time a list of datavar and a list of dataval. More...
 
void MakeDataStatement (list ldr, list ldv)
 Receives as first input an implicit list of references, including implicit DO, and as second input an list of value using pseudo-intrinsic REPEAT_VALUE() to replicate values. More...
 
void DeclarePointer (entity ptr, entity pointed_array, list decl_dims)
 
static bool same_basic_and_scalar_p (type t1, type t2)
 type_equal_p -> same_basic_and_scalar_p in latter... More...
 
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 encountered. More...
 
void DeclareIntrinsic (entity e)
 Intrinsic e is used in the current module. More...
 
bool fortran_relevant_area_entity_p (entity c)
 These tests are needed to check area consistency when dumping or printing a symbol table. More...
 
void initialize_common_size_map ()
 
void reset_common_size_map ()
 
void reset_common_size_map_on_error ()
 
bool common_to_defined_size_p (entity a)
 
size_t common_to_size (entity a)
 
void set_common_to_size (entity a, size_t size)
 
void update_common_to_size (entity a, size_t new_size)
 
static entity make_common_entity (entity c)
 updates the common entity if necessary with the common prefix More...
 
entity MakeCommon (entity e)
 MakeCommon: This function creates a common block. More...
 
entity NameToCommon (string n)
 
void AddVariableToCommon (entity c, entity v)
 This function adds a variable v to a common block c. More...
 
int CurrentOffsetOfArea (entity a, entity v)
 
void update_common_sizes (void)
 
void InitImplicit ()
 this function initializes the data structure used to compute implicit types More...
 
void cr_implicit (tag t, int l, int lettre_d, int lettre_f)
 this function updates the data structure used to compute implicit types. More...
 
type ImplicitType (entity e)
 This function computes the Fortran implicit type of entity e. More...
 
bool implicit_type_p (entity e)
 This function checks that entity e has an undefined or an implicit type which can be superseded by another declaration. More...
 
void retype_formal_parameters ()
 If an IMPLICIT statement is encountered, it must be applied to the formal parameters, and, if the current module is a function, to the function result type and to the variable used internally when a value is assigned to the function (see MakeCurrentFunction) More...
 
type MakeFortranType (tag t, value v)
 this function creates a type that represents a fortran type. More...
 
int OffsetOfReference (reference r)
 This function computes the numerical offset of a variable element from the begining of the variable. More...
 
int ValueOfIthLowerBound (entity e, int i)
 this function returns the size of the ith lower bound of a variable e. More...
 
int SizeOfRange (range r)
 This function computes the size of a range, ie. More...
 
int IsIntegerScalar (entity e)
 FI: should be moved in ri-util; this function returns true if e is a zero dimension variable of basic type integer. More...
 
void update_user_common_layouts (entity m)
 Check... More...
 
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) the size of common c for the whole program or set of modules in the current workspace. More...
 
entity SafeFindOrCreateEntity (const char *package, const char *name)
 Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a function or subroutine call as functional parameter. More...
 
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. More...
 

Variables

static hash_table common_size_map = hash_table_undefined
 
static tag tag_implicit [26]
 local variables for implicit type implementation More...
 
static size_t int_implicit [26]
 

Macro Definition Documentation

◆ IS_UPPER

#define IS_UPPER (   c)    (isascii(c) && isupper(c))

Definition at line 76 of file declaration.c.

Function Documentation

◆ add_entity_to_declarations()

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.

The name of the new variable must be a global name, whereas the name of the area is a local name. And the area does not have to be the stack area...

Why is this variable called "stack area" when it can be any area?

Parameters
nameame
area_namerea_name
valal

Definition at line 1969 of file declaration.c.

1970  {
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 }
value make_value_unknown(void)
Definition: ri.c:2847
type make_type_variable(variable _field_)
Definition: ri.c:2715
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
storage make_storage_ram(ram _field_)
Definition: ri.c:2279
int CurrentOffsetOfArea(entity a, entity v)
Definition: declaration.c:1195
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
int tag
TAG.
Definition: newgen_types.h:92
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
entity FindOrCreateTopLevelEntity(const char *name)
Return a top-level entity.
Definition: entity.c:1603
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
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
#define entity_storage(x)
Definition: ri.h:2794
#define entity_type(x)
Definition: ri.h:2792
#define entity_initial(x)
Definition: ri.h:2796

References AddEntityToDeclarations(), CurrentOffsetOfArea(), discard_module_declaration_text(), entity_initial, entity_storage, entity_type, FindEntity(), FindOrCreateTopLevelEntity(), get_current_module_entity(), make_basic(), make_ram(), make_storage_ram(), make_type_variable(), make_value_unknown(), make_variable(), module_local_name(), module_name(), and NIL.

+ Here is the call graph for this function:

◆ AddVariableToCommon()

void AddVariableToCommon ( entity  c,
entity  v 
)

This function adds a variable v to a common block c.

v's storage must be undefined.

c's size used to be indirectly updated by CurrentOffsetOfArea() but this is meaningless because v's type and dimensions are unknown. The layouts of commons are updated later by update_common_sizes() called from EndOfProcedure().

Definition at line 1108 of file declaration.c.

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 }
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
bool value_defined_p(value p)
Definition: ri.c:2797
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
type ImplicitType(entity e)
This function computes the Fortran implicit type of entity e.
Definition: declaration.c:1311
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
#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 pips_user_warning
Definition: misc-local.h:146
#define user_warning(fn,...)
Definition: misc-local.h:262
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
bool entity_blockdata_p(entity e)
Definition: entity.c:712
#define value_undefined
Definition: ri.h:3016
#define storage_tag(x)
Definition: ri.h:2515
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
@ is_storage_ram
Definition: ri.h:2492
#define type_undefined_p(x)
Definition: ri.h:2884
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define area_layout(x)
Definition: ri.h:546
#define type_area(x)
Definition: ri.h:2946
#define type_undefined
Definition: ri.h:2883
#define storage_rom_p(x)
Definition: ri.h:2525
#define storage_undefined
Definition: ri.h:2476
#define FatalError(f, m)
Definition: syntax-local.h:56
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

References area_layout, CONS, DeclareVariable(), ENTITY, entity_blockdata_p(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, FatalError, FindOrCreateEntity(), gen_nconc(), get_current_module_entity(), get_current_module_name(), ImplicitType(), intrinsic_entity_p(), is_storage_ram, line_b_I, line_e_I, make_ram(), make_storage(), module_local_name(), NIL, ParserError(), pips_user_warning, storage_rom_p, storage_tag, storage_undefined, type_area, type_undefined, type_undefined_p, user_warning, value_defined_p(), and value_undefined.

+ Here is the call graph for this function:

◆ AnalyzeData()

void AnalyzeData ( list  ldvr,
list  ldvl 
)

this function scans at the same time a list of datavar and a list of dataval.

it tries to match datavar to dataval and to compute initial values for zero dimension variable of basic type integer.

ldvr is a list of datavar.

ldvl is a list of dataval.

FI: this assertion must be usually wrong! pips_assert("AnalyseData", gen_length(ldvr) == gen_length(ldvl));

Variable is in static area or in a user declared common

Variable must be in a user declared common

Variable must be in static area

entity e initial field is set here with the data information.

if (entity_defined_p(e))

Parameters
ldvrdvr
ldvldvl

Definition at line 352 of file declaration.c.

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 }
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
constant copy_constant(constant p)
CONSTANT.
Definition: ri.c:359
void free_value(value p)
Definition: ri.c:2787
entity StaticArea
Definition: area.c:58
void SaveEntity(entity e)
These two functions transform a dynamic variable into a static one.
Definition: declaration.c:178
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#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_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define DATAVAL(x)
DATAVAL.
#define datavar_nbelements(x)
#define dataval_constant(x)
#define DATAVAR(x)
DATAVAR.
#define dataval_nboccurrences(x)
#define datavar_variable(x)
#define UNKNOWN_RAM_OFFSET
bool dynamic_area_p(entity aire)
Definition: area.c:68
bool static_area_p(entity aire)
Definition: area.c:77
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
Definition: variable.c:1113
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_unknown_p(x)
Definition: ri.h:3077
@ is_value_constant
Definition: ri.h:3033
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
#define entity_undefined_p(x)
Definition: ri.h:2762
#define constant_int_p(x)
Definition: ri.h:848
#define constant_call_p(x)
Definition: ri.h:860
#define storage_ram(x)
Definition: ri.h:2521
#define storage_undefined_p(x)
Definition: ri.h:2477
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define Warning(f, m)
extern char * getenv();
Definition: syntax-local.h:53

References CAR, CDR, constant_call_p, constant_int_p, copy_constant(), DATAVAL, dataval_constant, dataval_nboccurrences, DATAVAR, datavar_nbelements, datavar_variable, dynamic_area_p(), entity_blockdata_p(), entity_initial, entity_local_name(), entity_name, entity_scalar_p(), entity_storage, entity_undefined_p, free_value(), gen_length(), get_bool_property(), get_current_module_entity(), is_storage_ram, is_value_constant, make_ram(), make_storage(), make_value(), module_local_name(), NIL, ParserError(), pips_assert, pips_debug, pips_user_warning, ram_section, SaveEntity(), static_area_p(), StaticArea, storage_ram, storage_ram_p, storage_tag, storage_undefined_p, UNKNOWN_RAM_OFFSET, user_warning, value_undefined_p, value_unknown_p, and Warning.

+ Here is the call graph for this function:

◆ common_to_defined_size_p()

bool common_to_defined_size_p ( entity  a)

Definition at line 980 of file declaration.c.

981 {
982  bool defined = false;
983 
984  defined = ( (hash_get(common_size_map,(char *) a))
986 
987  return defined;
988 }
static hash_table common_size_map
Definition: declaration.c:935
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
#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

References common_size_map, hash_get(), and HASH_UNDEFINED_VALUE.

Referenced by MakeCommon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ common_to_size()

size_t common_to_size ( entity  a)

Definition at line 990 of file declaration.c.

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 }
#define pips_internal_error
Definition: misc-local.h:149

References common_size_map, entity_name, hash_get(), HASH_UNDEFINED_VALUE, and pips_internal_error.

Referenced by ComputeAddresses(), CurrentOffsetOfArea(), fortran_relevant_area_entity_p(), update_common_layout(), and update_common_sizes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cr_implicit()

void cr_implicit ( tag  t,
int  l,
int  lettre_d,
int  lettre_f 
)

this function updates the data structure used to compute implicit types.

the implicit type for the range of letters defined by lettre_d and lettre_f has tag t and length l. tag is_basic_string is temporarely forbidden.

Parameters
lettre_dettre_d
lettre_fettre_f

Definition at line 1284 of file declaration.c.

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 }
#define IS_UPPER(c)
Definition: declaration.c:76
static tag tag_implicit[26]
local variables for implicit type implementation
Definition: declaration.c:1264
static size_t int_implicit[26]
Definition: declaration.c:1265

References FatalError, int_implicit, IS_UPPER, and tag_implicit.

Referenced by InitImplicit().

+ Here is the caller graph for this function:

◆ CurrentOffsetOfArea()

int CurrentOffsetOfArea ( entity  a,
entity  v 
)

the local areas are StaticArea, DynamicArea, HeapArea, StackArea

Definition at line 1195 of file declaration.c.

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 }
int SafeSizeOfArray(entity a)
This function should not be used outside of the syntax library because it depends on ParserError().
Definition: declaration.c:83
void update_common_to_size(entity a, size_t new_size)
Definition: declaration.c:1010
size_t common_to_size(entity a)
Definition: declaration.c:990
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
#define area_size(x)
Definition: ri.h:544

References area_layout, area_size, common_to_size(), CONS, ENTITY, entity_type, gen_nconc(), NIL, SafeSizeOfArray(), top_level_entity_p(), type_area, and update_common_to_size().

Referenced by add_entity_to_declarations(), and gfc2pips_code2instruction__TOP().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeclareIntrinsic()

void DeclareIntrinsic ( entity  e)

Intrinsic e is used in the current module.

Definition at line 918 of file declaration.c.

919 {
920  pips_assert("entity is defined", e!=entity_undefined && intrinsic_entity_p(e));
921 
923 }

References AddEntityToDeclarations(), entity_undefined, get_current_module_entity(), intrinsic_entity_p(), and pips_assert.

+ Here is the call graph for this function:

◆ DeclarePointer()

void DeclarePointer ( entity  ptr,
entity  pointed_array,
list  decl_dims 
)

It is assumed that decl_tableau can be ignored for EDF examples

A varying dimension is impossible in the dynamic area for address computation. A heap area must be added.

dims = decl_dims;

No specific type for SUN pointers

EDF code contains several declaration for a unique pointer

Parameters
ptrtr
pointed_arrayointed_array
decl_dimsecl_dims

Definition at line 546 of file declaration.c.

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 }
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
entity HeapArea
Definition: area.c:59
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
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#define UNBOUNDED_DIMENSION_NAME
Definition: ri-util-local.h:74
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
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
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
@ is_basic_int
Definition: ri.h:571
#define basic_int_p(x)
Definition: ri.h:614
#define type_variable(x)
Definition: ri.h:2949
#define type_variable_p(x)
Definition: ri.h:2947
#define variable_basic(x)
Definition: ri.h:3120

References basic_int_p, CONS, CreateIntrinsic(), DeclareVariable(), DIMENSION, ENDP, entity_local_name(), entity_type, get_bool_property(), get_current_module_entity(), HeapArea, implicit_type_p(), int_to_expression(), is_basic_int, is_storage_ram, line_b_I, line_e_I, list_undefined, make_dimension(), make_ram(), make_storage(), MakeBasic(), MakeNullaryCall(), MakeTypeVariable(), NIL, ParserError(), pips_user_warning, storage_undefined, type_undefined, type_undefined_p, type_variable, type_variable_p, UNBOUNDED_DIMENSION_NAME, UNKNOWN_RAM_OFFSET, value_undefined, and variable_basic.

+ Here is the call graph for this function:

◆ DeclareVariable()

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 encountered.

Examples of sequences:

INTEGER*4 T DIMENSION T(10) SAVE T

or COMMON /TOTO/X,Y CHARACTER*30 X DIMENSION X(10)

or EXTERNAL F INTEGER F

The input code is assumed correct. As the standard states, IMPLICIT statements must occur before any declaration.

Parameters: e is an entity which should be either a variable or a funtion; it may already have a type et, of kind variable or functional; the type variable may have a dimension; variable or functional implicit types, as well as undefined type, can be superseded by the new type t; a NIL type dimension can be superseded by d; how should area entities be handled ??? t is a type of kind "variable" (functional types are not accepted; functional declaration are handled by ??? ) or undefined; it should have no dimensions; d is a (possibly) empty list of dimensions; the empty list is handled as the undefined list; each dimension is an expression s is the storage, possibly undefined; v is the initial value, possibly undefined

Most problems occur because of the great number of combinations between the entity type et (undefined, variable, functional) and the entity type dimension etd (NIL ot not) giving 7 cases on one hand, the type t and the dimensions d giving 4 cases on the other hand. That is 28 different behaviors.

No sharing is introduced between t and et. However d and s are directly used in e fields.

no new information: do nothing

update functional type

the old type should be gen_freed...

set dimension etd if NIL

set dimension etd if NIL

update type

I: to check update_common_layout

FI: it should be redefined and the offset be updated, maybe in check_common_area(); 1 Feb. 1994

Exception: since it is a synthetic variable, it is unlikely to be typed explicitly. But it can appear in later PIPS regenerated declarations. Unless there is a clash with a user variable.

No problem, but do not free t because this is performed in gram.y

free_type(t);

If the return variable is retyped, the function must be retyped

the pointed area has just been freed!

Meaningless warning when the result variable is declared the first time with the function itself user_warning("DeclareVariable", "Attempt to retype function %s with result of type " "%s with very same type %s\n", module_local_name(f), basic_to_string(old), basic_to_string(new));

Definition at line 670 of file declaration.c.

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 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
void free_type(type p)
Definition: ri.c:2658
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
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
string basic_to_string(basic)
Definition: type.c:87
void fprint_functional(FILE *fd, functional f)
This function is called from c_parse() via ResetCurrentModule() and fprint_environment()
Definition: declarations.c:227
bool formal_label_replacement_p(entity)
Definition: variable.c:1797
int basic_type_size(basic)
See also SizeOfElements()
Definition: type.c:1074
bool type_equal_p(type, type)
Definition: type.c:547
#define type_functional_p(x)
Definition: ri.h:2950
#define functional_result(x)
Definition: ri.h:1444
#define type_tag(x)
Definition: ri.h:2940
#define type_functional(x)
Definition: ri.h:2952
#define basic_undefined
Definition: ri.h:556
#define variable_dimensions(x)
Definition: ri.h:3122
@ is_type_functional
Definition: ri.h:2901
@ is_type_variable
Definition: ri.h:2900
@ is_type_area
Definition: ri.h:2899
#define storage_return_p(x)
Definition: ri.h:2516
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47

References AddEntityToDeclarations(), basic_to_string(), basic_type_size(), basic_undefined, copy_basic(), copy_type(), debug(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, f(), formal_label_replacement_p(), fprint_functional(), fprintf(), free_type(), functional_result, get_current_module_entity(), ifdebug, implicit_type_p(), ImplicitType(), is_type_area, is_type_functional, is_type_variable, line_b_I, line_e_I, list_undefined, make_value_unknown(), MakeTypeVariable(), module_local_name(), NIL, ParserError(), pips_assert, pips_internal_error, pips_user_warning, same_basic_and_scalar_p(), storage_ram_p, storage_return_p, storage_undefined, storage_undefined_p, type_equal_p(), type_functional, type_functional_p, type_tag, type_undefined, type_undefined_p, type_variable, type_variable_p, user_warning, value_undefined, variable_basic, and variable_dimensions.

Referenced by AddVariableToCommon(), DeclarePointer(), MakeAssignedGotoInst(), MakeAtom(), MakeCurrentFunction(), and SaveEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fortran_relevant_area_entity_p()

bool fortran_relevant_area_entity_p ( entity  c)

These tests are needed to check area consistency when dumping or printing a symbol table.

Definition at line 940 of file declaration.c.

941 {
943  && !heap_area_p(c)
944  && !stack_area_p(c));
945 }
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86

References common_size_map, common_to_size(), hash_table_undefined, heap_area_p(), and stack_area_p().

+ Here is the call graph for this function:

◆ implicit_type_p()

bool implicit_type_p ( entity  e)

This function checks that entity e has an undefined or an implicit type which can be superseded by another declaration.

The first letter of e's name is used to determine the implicit type. The implicit type of a functional entity is its result type.

ASSERT

to please gcc

Definition at line 1358 of file declaration.c.

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 }
void const char const char const int
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_logical
Definition: ri.h:573
@ is_basic_complex
Definition: ri.h:575
#define value_constant(x)
Definition: ri.h:3073
#define basic_int(x)
Definition: ri.h:616
#define constant_int(x)
Definition: ri.h:850
#define basic_tag(x)
Definition: ri.h:613
#define basic_logical(x)
Definition: ri.h:622
#define basic_float(x)
Definition: ri.h:619
#define basic_complex(x)
Definition: ri.h:628
#define basic_string(x)
Definition: ri.h:631

References basic_complex, basic_float, basic_int, basic_logical, basic_string, basic_tag, constant_int, entity_local_name(), entity_name, entity_type, FatalError, functional_result, int, int_implicit, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, IS_UPPER, pips_internal_error, tag_implicit, type_functional, type_functional_p, type_tag, type_undefined, type_variable, type_variable_p, value_constant, and variable_basic.

Referenced by DeclarePointer(), DeclareVariable(), retype_formal_parameters(), and TypeFunctionalEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImplicitType()

type ImplicitType ( entity  e)

This function computes the Fortran implicit type of entity e.

The first letter of e's name is used.

It should be now called FortranImplicitType()

Definition at line 1311 of file declaration.c.

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 }
constant make_constant(enum constant_utype tag, void *val)
Definition: ri.c:406
@ is_constant_int
Definition: ri.h:817

References entity_local_name(), FatalError, int, int_implicit, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, is_constant_int, IS_UPPER, is_value_constant, make_basic(), make_constant(), make_value(), MakeTypeVariable(), NIL, pips_internal_error, tag_implicit, type_undefined, and value_undefined.

Referenced by AddVariableToCommon(), DeclareVariable(), MakeAtom(), MakeCurrentFunction(), MakeFormalParameter(), MakeParameter(), MakeResultType(), mpi_type_mpi_comm(), mpi_type_mpi_request(), mpi_type_mpi_status(), retype_formal_parameters(), TypeFunctionalEntity(), and UpdateFunctionalType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitAreas()

void InitAreas ( void  )

Definition at line 100 of file declaration.c.

101 {
109 
117 
125 
133 }
storage make_storage_rom(void)
Definition: ri.c:2285
area make_area(intptr_t a1, list a2)
Definition: ri.c:98
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
entity DynamicArea
These global variables are declared in ri-util/util.c.
Definition: area.c:57
entity StackArea
Definition: area.c:60
void set_common_to_size(entity a, size_t size)
Definition: declaration.c:1004
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define STACK_AREA_LOCAL_NAME
Definition: naming-local.h:72
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define HEAP_AREA_LOCAL_NAME
Definition: naming-local.h:71
@ ENTITY_STATIC_AREA
@ ABSTRACT_LOCATION
@ ENTITY_DYNAMIC_AREA
@ ENTITY_STACK_AREA
@ ENTITY_HEAP_AREA
#define entity_kind(x)
Definition: ri.h:2798
const char * CurrentPackage
the name of the current package, i.e.
Definition: parser.c:58

References ABSTRACT_LOCATION, AddEntityToDeclarations(), CurrentPackage, DYNAMIC_AREA_LOCAL_NAME, DynamicArea, ENTITY_DYNAMIC_AREA, ENTITY_HEAP_AREA, entity_initial, entity_kind, ENTITY_STACK_AREA, ENTITY_STATIC_AREA, entity_storage, entity_type, FindOrCreateEntity(), get_current_module_entity(), HEAP_AREA_LOCAL_NAME, HeapArea, is_type_area, make_area(), make_storage_rom(), make_type(), make_value_unknown(), NIL, set_common_to_size(), STACK_AREA_LOCAL_NAME, StackArea, STATIC_AREA_LOCAL_NAME, and StaticArea.

Referenced by gfc2pips_namespace(), and MakeCurrentFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_common_size_map()

void initialize_common_size_map ( void  )

Definition at line 947 of file declaration.c.

948 {
949  pips_assert("common_size_map is undefined",
952 }
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_pointer
Definition: newgen_hash.h:32

References common_size_map, hash_pointer, hash_table_make(), hash_table_undefined, and pips_assert.

Referenced by gfc2pips_namespace(), and MakeCurrentFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitImplicit()

void InitImplicit ( void  )

this function initializes the data structure used to compute implicit types

Definition at line 1271 of file declaration.c.

1272 {
1276 }
int DefaultLengthOfBasic(tag t)
Deals with constant expressions and constant entities.
Definition: constant.c:44
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

References cr_implicit(), DefaultLengthOfBasic(), is_basic_float, and is_basic_int.

Referenced by BeginingOfProcedure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsIntegerScalar()

int IsIntegerScalar ( entity  e)

FI: should be moved in ri-util; this function returns true if e is a zero dimension variable of basic type integer.

Definition at line 1647 of file declaration.c.

1649 {
1650  if (type_variable_p(entity_type(e))) {
1652 
1654  return(true);
1655  }
1656 
1657  return(false);
1658 }

References basic_int_p, entity_type, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.

◆ make_common_entity()

static entity make_common_entity ( entity  c)
static

updates the common entity if necessary with the common prefix

Definition at line 1018 of file declaration.c.

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 }
value make_value_code(code _field_)
Definition: ri.c:2835
language make_language_fortran(void)
Definition: ri.c:1250
code make_code(list a1, string a2, sequence a3, list a4, language a5)
Definition: ri.c:353
sequence make_sequence(list a)
Definition: ri.c:2125
#define string_undefined
Definition: newgen_types.h:40
bool entity_common_p(entity e)
Definition: entity.c:718

References AddEntityToDeclarations(), entity_common_p(), entity_initial, entity_storage, entity_type, get_current_module_entity(), is_storage_ram, is_type_area, make_area(), make_code(), make_language_fortran(), make_ram(), make_sequence(), make_storage(), make_type(), make_value_code(), NIL, StaticArea, string_undefined, and type_undefined_p.

Referenced by MakeCommon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeCommon()

entity MakeCommon ( entity  e)

MakeCommon: This function creates a common block.

pips creates static common blocks. This is not true in the ANSI standard stricto sensu, but true in most implementations.

A common declaration can be made out of several common statements. MakeCommon() is called for each common statement, although it only is useful the first time.

common e may already exist because it was encountered in another module but not have been registered as known by the current module. It may also already exist because it was encountered in the same module, but AddEntityToDeclarations() does not duplicate declarations.

FI: for a while, common sizes were always reset to 0, even when several common statements were encountered in the same module for the same common. This did not matter because offsets in commons are recomputed once variable types and dimensions are all known.

Definition at line 1047 of file declaration.c.

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 }
static entity make_common_entity(entity c)
updates the common entity if necessary with the common prefix
Definition: declaration.c:1018
bool common_to_defined_size_p(entity a)
Definition: declaration.c:980

References AddEntityToDeclarations(), common_to_defined_size_p(), get_current_module_entity(), make_common_entity(), and set_common_to_size().

Referenced by MakeEntryCommon(), and NameToCommon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeDataStatement()

void MakeDataStatement ( list  ldr,
list  ldv 
)

Receives as first input an implicit list of references, including implicit DO, and as second input an list of value using pseudo-intrinsic REPEAT_VALUE() to replicate values.

Generates a call statement to STATIC-INITIALIZATION(), with a call to DATA_LIST to prefix ldr (unlike IO list). Processes the information as AnalyzeData() used to do it. Add the new data call statement to the initializations field of the current module.

Parameters
ldrdr
ldvdv

Definition at line 524 of file declaration.c.

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 }
statement make_call_statement(string, list, entity, string)
This function is limited to intrinsics calls...
Definition: statement.c:1274
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
char * PrevComm
Definition: reader.c:152
int iPrevComm
Definition: reader.c:153
#define STATIC_INITIALIZATION_NAME
Definition: ri-util-local.h:79
#define DATA_LIST_FUNCTION_NAME
Definition: ri-util-local.h:81
code entity_code(entity e)
Definition: entity.c:1098
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
#define code_initializations(x)
Definition: ri.h:788
#define sequence_statements(x)
Definition: ri.h:2360
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
char * strdup()

References code_initializations, CONS, DATA_LIST_FUNCTION_NAME, entity_code(), entity_undefined, entity_undefined_p, EXPRESSION, expression_undefined, FindEntity(), gen_nconc(), get_current_module_entity(), iPrevComm, make_call_expression(), make_call_statement(), NIL, pips_assert, PrevComm, sequence_statements, STATEMENT, statement_undefined, STATIC_INITIALIZATION_NAME, strdup(), and TOP_LEVEL_MODULE_NAME.

+ Here is the call graph for this function:

◆ MakeFortranType()

type MakeFortranType ( tag  t,
value  v 
)

this function creates a type that represents a fortran type.

its basic is an int (the length of the fortran type) except in case of strings where the type might be unknown, as in:

  CHARACTER*(*) PF

t is a tag, eg: INTEGER, REAL, ...

v is a value that represents the length in bytes of the type.

Check compatibility between type and byte length

Accept INTEGER*1 for SIMD parallelizer and INTEGER*2 for legacy code and INTEGER*8 for 64 bit machines

Definition at line 1505 of file declaration.c.

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 }
static bool ok

References constant_int, DefaultLengthOfBasic(), get_bool_property(), is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, is_constant_int, is_value_constant, make_basic(), make_constant(), make_value(), MakeTypeVariable(), NIL, ok, ParserError(), value_constant, and value_undefined.

+ Here is the call graph for this function:

◆ MakeVariableStatic()

void MakeVariableStatic ( entity  v,
bool  force_it 
)

v may have become static because of a DATA statement (OK) or because of another SAVE (NOK)

Could be the stack or the heap area or any common

Parameters
force_itorce_it

Definition at line 245 of file declaration.c.

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 }

References DynamicArea, entity_local_name(), entity_storage, module_local_name(), ParserError(), ram_section, SaveEntity(), StaticArea, storage_ram, storage_ram_p, storage_tag, storage_undefined, and user_warning.

Referenced by ProcessSave(), and save_initialized_variable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NameToCommon()

entity NameToCommon ( string  n)

Check for potential conflicts

Definition at line 1071 of file declaration.c.

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 }
entity MakeCommon(entity e)
MakeCommon: This function creates a common block.
Definition: declaration.c:1047
void free(void *)
#define COMMON_PREFIX
Definition: naming-local.h:34
#define MAIN_PREFIX
Definition: naming-local.h:32
#define BLOCKDATA_PREFIX
Definition: naming-local.h:35
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
static string prefixes[]
Definition: entity.c:1433

References BLOCKDATA_PREFIX, COMMON_PREFIX, concatenate(), entity_undefined_p, FindEntity(), FindOrCreateEntity(), free(), MAIN_PREFIX, MakeCommon(), prefixes, strdup(), TOP_LEVEL_MODULE_NAME, and user_warning.

+ Here is the call graph for this function:

◆ OffsetOfReference()

int OffsetOfReference ( reference  r)

This function computes the numerical offset of a variable element from the begining of the variable.

The variable must have numerical bounds for this function to work. It core dumps for adjustable arrays such as formal parameters.

Use a trick to retrieve the size in bytes of one array element and use the size of the previous dimension

Definition at line 1565 of file declaration.c.

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 }
int ValueOfIthLowerBound(entity e, int i)
this function returns the size of the ith lower bound of a variable e.
Definition: declaration.c:1591
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 SizeOfIthDimension(entity, int)
this function returns the size of the ith dimension of a variable e.
Definition: size.c:453
#define reference_variable(x)
Definition: ri.h:2326
#define reference_indices(x)
Definition: ri.h:2328

References CAR, CDR, EXPRESSION, ExpressionToInt(), reference_indices, reference_variable, SizeOfIthDimension(), and ValueOfIthLowerBound().

Referenced by MakeEquivAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrintData()

void PrintData ( cons ldvr,
cons ldvl 
)

a debugging function, just in case ...

Parameters
ldvrdvr
ldvldvl

Definition at line 310 of file declaration.c.

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 }

References CAR, CDR, constant_int, constant_int_p, DATAVAL, dataval_constant, dataval_nboccurrences, DATAVAR, datavar_nbelements, datavar_variable, debug(), entity_name, and NIL.

+ Here is the call graph for this function:

◆ ProcessSave()

void ProcessSave ( entity  v)

Definition at line 282 of file declaration.c.

283 {
284  MakeVariableStatic(v, true);
285 }
void MakeVariableStatic(entity v, bool force_it)
Definition: declaration.c:245

References MakeVariableStatic().

+ Here is the call graph for this function:

◆ reset_common_size_map()

void reset_common_size_map ( void  )

Problems:

  • this routine may be called from ParserError()... which should not be called recursively
  • but it maight also be called from somewhere else and ParserError() then should be called A second reset routine must be defined.

Definition at line 954 of file declaration.c.

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 }
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327

References common_size_map, hash_table_free(), hash_table_undefined, and ParserError().

Referenced by EndOfProcedure(), and gfc2pips_namespace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_common_size_map_on_error()

void reset_common_size_map_on_error ( void  )

Definition at line 972 of file declaration.c.

References common_size_map, hash_table_free(), and hash_table_undefined.

Referenced by ParserError().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retype_formal_parameters()

void retype_formal_parameters ( void  )

If an IMPLICIT statement is encountered, it must be applied to the formal parameters, and, if the current module is a function, to the function result type and to the variable used internally when a value is assigned to the function (see MakeCurrentFunction)

If the current module is a function, its type should be updated.

The function signature is computed later by UpdateFunctionalType() called from EndOfProcedure: there should be no parameters in the type.

Update type of internal variable used to store the function result

nothing to be done: subroutine or main

Definition at line 1411 of file declaration.c.

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 }
#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
bool entity_function_p(entity e)
Definition: entity.c:724
bool variable_entity_p(entity)
variable.c
Definition: variable.c:70
bool formal_parameter_p(entity)
Definition: variable.c:1489
#define code_declarations(x)
Definition: ri.h:784
#define type_void_p(x)
Definition: ri.h:2959
#define functional_parameters(x)
Definition: ri.h:1442
#define value_code(x)
Definition: ri.h:3067

References code_declarations, ENDP, ENTITY, entity_function_p(), entity_initial, entity_local_name(), entity_storage, entity_type, entity_undefined, FindEntity(), formal_parameter_p(), free_type(), functional_parameters, functional_result, get_current_module_entity(), implicit_type_p(), ImplicitType(), MAP, module_local_name(), pips_assert, pips_debug, pips_internal_error, pips_user_warning, storage_ram_p, storage_rom_p, storage_undefined_p, type_equal_p(), type_functional, type_functional_p, type_tag, type_undefined, type_variable_p, type_void_p, value_code, and variable_entity_p().

+ Here is the call graph for this function:

◆ SafeFindOrCreateEntity()

entity SafeFindOrCreateEntity ( const char *  package,
const char *  name 
)

Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a function or subroutine call as functional parameter.

FindOrCreateEntity() will return a local variable which already is or will be in the ghost variable list. When ghost variables are eliminated the data structure using this local variable contain a pointer to nowhere.

However, SafeFindOrCreateEntity() does not solve this problem entirely. The call with a functional parameter may occur before a call to this functional parameter lets us find out it is indeed functional.

Morevover, SafeFindOrCreateEntity() does create new problem because intrinsic overloading is ignored. Fortran does not use reserved words and a local variable may have the same name as an intrinsics. The intrinsic entity returned by this function must later be converted into a local variable when it is found out that the user really wanted a local variable, for instance because it appears in a lhs. So intrinsics are not searched anymore.

This is yet another reason to split the building of the internal representation into three phases. The first phase should not assume any default type or storage. Then, type and storage are consolidated together and default type and storage are only used when no information is available. The last phase should be kind of a link edit. The references to really global variables and intrinsics have to be fixed by scanning the intermediate representation.

See also FindOrCreateEntity().

This is a request for a global variable

May be a local or a global entity

This is a request for a local or a global variable. If a local variable with name "name" exists, return it.

No such local variable yet.

Does a global variable with the same name exist and is it in the package's scope?

let s hope concatenate s buffer lasts long enough...

There is no such global variable. Let's make a new local variable

A global entity with the same local name exists.

There is such a global variable and it is in the proper scope

Here comes the mistake if the current_module_entity is not yet defined as is the case when formal parameters are parsed. Intrinsics may wrongly picked out. See capture01.f, variable DIM.

The global variable is not be in the scope.

A local variable must be created. It is later replaced by a global variable if necessary and becomes a ghost variable.

A local variable has been found

le is not a ghost variable

Parameters
packageackage
namele nom du package le nom de l'entite

Definition at line 1891 of file declaration.c.

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 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
static char * package
The package name in which functions will be defined.
Definition: genLisp.c:59
#define full_name(dir, name)
Definition: compile.c:414
#define MODULE_SEP_STRING
Definition: naming-local.h:30
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
bool ghost_variable_entity_p(entity e)
Definition: procedure.c:292
#define make_entity(n, t, s, i)
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References code_declarations, concatenate(), entity_code(), entity_domain, entity_is_argument_p(), entity_undefined, entity_undefined_p, FindEntity(), full_name, gen_find_tabulated(), get_current_module_entity(), ghost_variable_entity_p(), intrinsic_entity_p(), make_entity, MODULE_SEP_STRING, package, pips_assert, storage_undefined, strdup(), TOP_LEVEL_MODULE_NAME, type_undefined, and value_undefined.

+ Here is the call graph for this function:

◆ SafeSizeOfArray()

int SafeSizeOfArray ( entity  a)

This function should not be used outside of the syntax library because it depends on ParserError().

cproto-generated files

See ri-util/size.c: array_size()

Definition at line 83 of file declaration.c.

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 }
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
Definition: size.c:87

References entity_name, ParserError(), pips_user_warning, and SizeOfArray().

Referenced by ComputeAddresses(), CurrentOffsetOfArea(), and update_common_layout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ same_basic_and_scalar_p()

static bool same_basic_and_scalar_p ( type  t1,
type  t2 
)
static

type_equal_p -> same_basic_and_scalar_p in latter...

FC.

Definition at line 615 of file declaration.c.

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 }
bool basic_equal_p(basic, basic)
Definition: type.c:927
#define variable_undefined_p(x)
Definition: ri.h:3096

References basic_equal_p(), NIL, type_variable, type_variable_p, variable_basic, variable_dimensions, and variable_undefined_p.

Referenced by DeclareVariable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save_all_entities()

void save_all_entities ( void  )

functions for the SAVE declaration

FI: all variables previously allocated should be reallocated

FI: This is pretty crude... Let's hope it works

Definition at line 138 of file declaration.c.

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 }
void free_storage(storage p)
Definition: ri.c:2231
int current_offset_of_area(entity a, entity v)
Definition: area.c:174

References code_declarations, current_offset_of_area(), DynamicArea, ENTITY, entity_initial, entity_storage, entity_undefined, free_storage(), get_current_module_entity(), is_storage_ram, make_ram(), make_storage(), MAP, NIL, pips_assert, ram_section, StaticArea, storage_ram, storage_ram_p, storage_undefined, and value_code.

+ Here is the call graph for this function:

◆ save_initialized_variable()

void save_initialized_variable ( entity  v)

Definition at line 287 of file declaration.c.

288 {
289  MakeVariableStatic(v, false);
290 }

References MakeVariableStatic().

+ Here is the call graph for this function:

◆ SaveCommon()

void SaveCommon ( entity  c)

this function transforms a dynamic common into a static one.


Definition at line 295 of file declaration.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 }
#define type_area_p(x)
Definition: ri.h:2944

References entity_type, pips_assert, type_area_p, and Warning.

◆ SaveEntity()

void SaveEntity ( entity  e)

These two functions transform a dynamic variable into a static one.

They are called to handle SAVE and DATA statements.

Because equivalence chains have not yet been processed, it is not possible to assign an offset or to chain the variable to the static area layout. These two updates are performed by ComputeAddresses() only called by EndOfProcedure() to make sure that all non-declared variables have been taken into account.

Let's hope functions and subroutines called are listed in the declaration list.

This cannot be done before the equivalences have been processed

Not much can be said. Maybe it is redundant, but...

Maybe the standard claims that you are not allowed to save a common variable?

The type and dimensions are still unknown

Definition at line 178 of file declaration.c.

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 }
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
#define ram_offset(x)
Definition: ri.h:2251

References code_declarations, DeclareVariable(), DynamicArea, entity_initial, entity_is_argument_p(), entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined_p, get_current_module_entity(), is_storage_ram, local_name_to_top_level_entity(), make_ram(), make_storage(), NIL, ParserError(), ram_offset, ram_section, StaticArea, storage_ram, storage_ram_p, storage_tag, storage_undefined, type_undefined, UNKNOWN_RAM_OFFSET, user_warning, value_code, and value_undefined.

Referenced by AnalyzeData(), fix_storage(), and MakeVariableStatic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_common_to_size()

void set_common_to_size ( entity  a,
size_t  size 
)
Parameters
sizeize

Definition at line 1004 of file declaration.c.

1005 {
1006  (void) hash_put(common_size_map, (char *) a, (char *) (size));
1007 }
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

References common_size_map, and hash_put().

Referenced by gfc2pips_computeAdressesOfArea(), gfc2pips_namespace(), InitAreas(), and MakeCommon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SizeOfRange()

int SizeOfRange ( range  r)

This function computes the size of a range, ie.

the number of iterations that would be done by a loop with this range.

See also range_count().

Definition at line 1619 of file declaration.c.

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 }
#define range_upper(x)
Definition: ri.h:2290
#define range_increment(x)
Definition: ri.h:2292
#define range_lower(x)
Definition: ri.h:2288

References ExpressionToInt(), FatalError, range_increment, range_lower, and range_upper.

+ Here is the call graph for this function:

◆ update_common_layout()

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) the size of common c for the whole program or set of modules in the current workspace.

As a consequence, warning messages unfortunately depend on the parsing order.

Offsets used to be computed a first time when the common declaration is encountered, but the variables may be typed or dimensionned later.

This function is correct only if no equivalenced variables have been added to the layout. It should not be used for the static and dynamic areas (see below).

It is assumed that:

  • each variable appears only once
  • variables appears in their declaration order
  • all variables that belong to the same module appear contiguously (i.e. declarations are concatenated on a module basis)
  • variables wich are located in the common thru an EQUIVALENCE statement are not (yet) in its layout It also was wrongly assumed that each common would have at least two members.

the layout field does not seem to be filled in for STATIC and DYNAMIC

skip variables which do not belong to the module of interest

This should now always be the case. The offset within the common is no longer computed on the fly.

If c really is a common, check its size because it may have increased. Note that decreases are not taken into account although they might occur as well.

Too late, if the common only contains one element because the MAPL has not been entered at all if we are dealing wih te last parsed module... which is always the case up to now!

Variables declared in the static and dynamic areas were assigned offsets dynamically. The result may be ok.

Special case: only one element in the common for the current procedure (and the current procedure is last one declared - which is not so special)

If c really is a common, check its size because it may have increased. Note that decreases are not taken into account although they might occur as well.

Definition at line 1746 of file declaration.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 }
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
void print_arguments(list args)
Definition: naming.c:228
string bool_to_string(bool)
Definition: string.c:243
bool entity_special_area_p(entity e)
Definition: area.c:154
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
static size_t current
Definition: string.c:115

References area_layout, bool_to_string(), CAR, common_to_size(), current, debug(), ENDP, ENTITY, entity_special_area_p(), entity_storage, entity_type, entity_undefined, ifdebug, list_undefined, module_local_name(), pips_assert, POP, print_arguments(), ram_offset, SafeSizeOfArray(), storage_ram, storage_ram_p, top_level_entity_p(), type_area, update_common_to_size(), and variable_in_module_p().

Referenced by update_user_common_layouts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_common_sizes()

void update_common_sizes ( void  )

I'm afraid this warning might be printed because area_size is given a wrong value by CurrentOffsetOfArea().

reset_common_size_map();

Definition at line 1215 of file declaration.c.

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 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
cons * arguments_add_entity(cons *a, entity e)
Definition: arguments.c:85
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 HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
static int tc
Internal variables
Definition: reindexing.c:107
void sort_list_of_entities(list l)
sorted in place.
Definition: entity.c:1358
#define intptr_t
Definition: stdint.in.h:294

References area_size, arguments_add_entity(), common_size_map, common_to_size(), CurrentPackage, debug(), ENTITY, entity_name, entity_type, FOREACH, gen_free_list(), HASH_MAP, HASH_UNDEFINED_VALUE, intptr_t, module_local_name(), NIL, pips_assert, pips_debug, sort_list_of_entities(), tc, type_area, and user_warning.

Referenced by EndOfProcedure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_common_to_size()

void update_common_to_size ( entity  a,
size_t  new_size 
)
Parameters
new_sizeew_size

Definition at line 1010 of file declaration.c.

1011 {
1012  (void) hash_update(common_size_map, (char *) a, (char *) (new_size));
1013 }
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

References common_size_map, and hash_update().

Referenced by ComputeAddresses(), CurrentOffsetOfArea(), and update_common_layout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_user_common_layouts()

void update_user_common_layouts ( entity  m)

Check...

and fix, if needed!

Only user COMMONs are checked. The two implicit areas, DynamicArea and StaticArea, have not been initialized yet (see ComputeAddress() and the calls in EndOfProcedure()).

List of implicitly and explicitly declared variables, functions and areas

Structure of each area/common

User declarations of commons imply the offset and cannot conflict with equivalences, whereas static and dynamic variables must first comply with equivalences. Hence the layouts of user commons must be updated before equivalences are satisfied whereas layouts of the static and dynamic areas must be satisfied after the equiavelences have been processed.

Definition at line 1670 of file declaration.c.

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 }
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
list gen_append(list l1, const list l2)
Definition: list.c:471
void print_common_layout(FILE *fd, entity c, bool debug_p)
Definition: area.c:207
bool entity_module_p(entity e)
Definition: entity.c:683

References code_declarations, ENDP, ENTITY, entity_initial, entity_module_p(), entity_name, entity_special_area_p(), entity_type, fprintf(), gen_append(), gen_free_list(), ifdebug, MAP, module_local_name(), NIL, pips_assert, pips_debug, print_common_layout(), sort_list_of_entities(), type_area_p, update_common_layout(), and value_code.

Referenced by EndOfProcedure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ValueOfIthLowerBound()

int ValueOfIthLowerBound ( entity  e,
int  i 
)

this function returns the size of the ith lower bound of a variable e.

Definition at line 1591 of file declaration.c.

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 }
#define dimension_lower(x)
Definition: ri.h:980

References CAR, CDR, DIMENSION, dimension_lower, entity_type, ExpressionToInt(), ParserError(), pips_assert, type_variable, type_variable_p, and variable_dimensions.

Referenced by OffsetOfReference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ common_size_map

◆ int_implicit

size_t int_implicit[26]
static

Definition at line 1265 of file declaration.c.

Referenced by cr_implicit(), implicit_type_p(), and ImplicitType().

◆ tag_implicit

tag tag_implicit[26]
static

local variables for implicit type implementation

Definition at line 1264 of file declaration.c.

Referenced by cr_implicit(), implicit_type_p(), and ImplicitType().