PIPS
c_parser.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "genC.h"
#include "linear.h"
#include "misc.h"
#include "ri.h"
#include "ri-util.h"
#include "cyacc.h"
#include "c_syntax.h"
#include "resources.h"
#include "database.h"
#include "pipsdbm.h"
#include "workspace-util.h"
#include "text-util.h"
+ Include dependency graph for c_parser.c:

Go to the source code of this file.

Functions

string get_c_parser_current_input_file_name ()
 
void set_c_parser_current_input_file_name (string file_name)
 
void reset_c_parser_current_input_file_name (void)
 
void error_reset_c_parser_current_input_file_name (void)
 
string get_c_parser_current_user_input_file_name ()
 
void set_c_parser_current_user_input_file_name (string file_name)
 
void reset_c_parser_current_user_input_file_name (void)
 
void error_reset_c_parser_current_user_input_file_name (void)
 
void init_entity_type_storage_table ()
 
void put_to_entity_type_stack_table (entity key, stack value)
 
stack get_from_entity_type_stack_table (entity key)
 
void remove_entity_type_stack (entity e)
 
void remove_entity_type_stacks (list el)
 
void reset_entity_type_stack_table ()
 
void parser_init_keyword_typedef_table ()
 
bool c_parser_error (const char *func, const char *msg)
 Output a parser message error. More...
 
static bool substitute_statement_label (statement s, hash_table l_to_nl)
 
static void FixCInternalLabels (statement s)
 To avoid label name conflicts, the parser uses a special character that cannot appear in a C label. More...
 
void make_predefined_C_entities (string compilation_unit_name)
 
static bool actual_c_parser (const char *module_name, string dbr_file, bool is_compilation_unit_parser)
 
bool c_parser (const char *module_name)
 
bool compilation_unit_parser (const char *module_name)
 

Variables

string compilation_unit_name
 cproto-generated files More...
 
list CalledModules = NIL
 
statement ModuleStatement = statement_undefined
 
static string c_parser_current_file_name = string_undefined
 
static string c_parser_current_user_input_file_name = string_undefined
 
stack ContextStack = stack_undefined
 
stack FunctionStack = stack_undefined
 
stack FormalStack = stack_undefined
 
stack OffsetStack = stack_undefined
 
stack StructNameStack = stack_undefined
 
int loop_counter = 1
 Global counter. More...
 
int derived_counter = 1
 
static hash_table entity_to_type_stack_table = hash_table_undefined
 
bool compilation_unit_parser_is_running_p = false
 To pass down the information to functions used by the syntactical analyzer. More...
 
list removable_extern_entities = list_undefined
 

Function Documentation

◆ actual_c_parser()

static bool actual_c_parser ( const char *  module_name,
string  dbr_file,
bool  is_compilation_unit_parser 
)
static

FI: not clean, but useful for debugging statement

ifdebug(1)

{

set_prettyprint_language_tag(is_language_c);

}

Special case, set the compilation unit as the current module

I do not know to put this where to avoid repeated creations

Rather than dealing with the issue in error handling

discard_C_comment();

Mainly reset the line number:

yacc parser is called

pips_debug(2,"Module statement: \n");

print_statement_of_module(ModuleStatement, module_name);

Even if you are not in a compilation unit, external functions may be declared many times within one scope.

Variables allocated within the compilation unit should be declared only once, no?

alue_code_p(v) &&

Beware : the rule in pipsmake-rc.tex for compilation_unit_parser does not include the production of parsed_code and callees. This is not very clean, and is done to work around the way pipsmake handles compilation units and modules. There was no simple solution... BC.

Used to be done in ResetCurrentCompilationUnitEntity()

free_keyword_typedef_table();

Definition at line 544 of file c_parser.c.

547 {
548  string dir = db_get_current_workspace_directory();
549  string file_name =
550  strdup(concatenate(dir, "/",
551  db_get_file_resource(dbr_file,module_name,true), NULL));
552  free(dir);
553 
555  string input_file_name =
556  (string) db_get_memory_resource(DBR_INPUT_FILE_NAME, module_name, true);
560 
561  if (is_compilation_unit_parser) {
565  }
566  else {
569  (hash_table) db_get_memory_resource(DBR_DECLARATIONS,
570  compilation_unit_name,true);
572  }
573 
575  InitScope();
581 
582  loop_counter = 1;
583  derived_counter = 1;
584  CalledModules = NIL;
585 
586  debug_on("C_SYNTAX_DEBUG_LEVEL");
587  pips_debug(1,"Module name: %s\n", module_name);
588  pips_debug(1,"Compilation unit name: %s\n", compilation_unit_name);
589  ifdebug(1)
591 
592  /* FI: not clean, but useful for debugging statement */
593  /* ifdebug(1) */
594  /* { */
595  /* set_prettyprint_language_tag(is_language_c); */
596  /* } */
597 
599 
601  {
602  /* Special case, set the compilation unit as the current module */
604  /* I do not know to put this where to avoid repeated creations*/
606  /* Rather than dealing with the issue in error handling */
611  }
612 
613  /* discard_C_comment(); */
614  init_C_comment();
615  /* Mainly reset the line number: */
618 
619  /* yacc parser is called */
620  c_in = safe_fopen(file_name, "r");
621  //c_parser_current_file_name = file_name;
622 
624  c_parse();
625 
627 
629 
630  pips_assert("Module statement is consistent",
632 
634 
635  pips_assert("Module statement is consistent",
637 
639 
640  pips_assert("Module statement is consistent",
642 
643  ifdebug(2)
644  {
645  /* pips_debug(2,"Module statement: \n"); */
646  /* print_statement_of_module(ModuleStatement, module_name); */
647 
648  pips_debug(2,"and declarations: ");
651  pips_assert("e's type is defined", !type_undefined_p(entity_type(e)));
652  pips_assert("e's storage is defined", !storage_undefined_p(entity_storage(e)));
653  pips_assert("e's initial value is defined", !value_undefined_p(entity_initial(e)));
654  // Too strong because the normalize field of expressions in
655  //not initialized in the parser.
656  //pips_assert("e is fully defined", entity_defined_p(e));
657  }
659  /* Even if you are not in a compilation unit, external
660  functions may be declared many times within one scope. */
661  pips_assert("Variables are declared once",
663  }
664  else {
665  /* Variables allocated within the compilation unit should be declared only once, no? */
666  ; // no check yet
667  }
668  printf("\nList of callees:\n");
670  {
671  printf("\t%s\n",s);
672  }
673  }
674 
676  {
678  // unused: value v = entity_initial(ne);
679  type t = entity_type(ne);
680  if(/*value_code_p(v) &&*/ !type_variable_p(t))
681  RemoveFromExterns(ne);
682  }
685  ResetCurrentCompilationUnitEntity(is_compilation_unit_parser);
686  }
687 
688  if (is_compilation_unit_parser)
689  {
690  /* Beware : the rule in pipsmake-rc.tex for compilation_unit_parser
691  does not include the production of parsed_code and callees.
692  This is not very clean, and is done to work around the way pipsmake
693  handles compilation units and modules.
694  There was no simple solution... BC.
695  */
696  DB_PUT_MEMORY_RESOURCE(DBR_PARSED_CODE,
697  module_name,
698  (char *) ModuleStatement);
699  DB_PUT_MEMORY_RESOURCE(DBR_DECLARATIONS,
700  module_name,
701  (void *) keyword_typedef_table);
702  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES,
703  module_name,
704  (char *) make_callees(NIL));
705  }
706  else
707  {
708  DB_PUT_MEMORY_RESOURCE(DBR_PARSED_CODE,
709  module_name,
710  (char *) ModuleStatement);
711  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES,
712  module_name,
713  (char *) make_callees(CalledModules));
714  }
715 
716  free(file_name);
717  file_name = NULL;
720  reset_entity_type_stack_table(); /* Used to be done in ResetCurrentCompilationUnitEntity() */
726  /* free_keyword_typedef_table();*/
727  pips_assert("ContextStack is empty", stack_empty_p(ContextStack));
735  debug_off();
736  return true;
737 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
callees make_callees(list a)
Definition: ri.c:227
int derived_counter
Definition: c_parser.c:125
void set_c_parser_current_user_input_file_name(string file_name)
Definition: c_parser.c:96
void reset_entity_type_stack_table()
Definition: c_parser.c:186
void reset_c_parser_current_input_file_name(void)
Definition: c_parser.c:73
void set_c_parser_current_input_file_name(string file_name)
Definition: c_parser.c:65
stack StructNameStack
Definition: c_parser.c:121
void parser_init_keyword_typedef_table()
Definition: c_parser.c:193
list CalledModules
Definition: c_parser.c:51
string compilation_unit_name
cproto-generated files
Definition: c_parser.c:49
void reset_c_parser_current_user_input_file_name(void)
Definition: c_parser.c:104
bool compilation_unit_parser_is_running_p
To pass down the information to functions used by the syntactical analyzer.
Definition: c_parser.c:541
stack OffsetStack
Definition: c_parser.c:120
stack FunctionStack
Definition: c_parser.c:118
void init_entity_type_storage_table()
Definition: c_parser.c:131
void make_predefined_C_entities(string compilation_unit_name)
Definition: c_parser.c:425
list removable_extern_entities
Definition: c_parser.c:542
int loop_counter
Global counter.
Definition: c_parser.c:124
stack FormalStack
Definition: c_parser.c:119
stack ContextStack
Definition: c_parser.c:117
statement ModuleStatement
Definition: c_parser.c:53
static void FixCInternalLabels(statement s)
To avoid label name conflicts, the parser uses a special character that cannot appear in a C label.
Definition: c_parser.c:373
#define c_parser_context_domain
newgen_qualifier_domain_defined
void reset_expression_comment(void)
we don't want an expression comment with new lines, it is disgracefull
Definition: cyacc.tab.c:169
void init_c_parser_scope_stack(void)
Definition: cyacc.tab.c:514
void set_current_C_line_number(void)
Definition: clexer.c:1166
void reset_c_parser_scope_stack(void)
Definition: cyacc.tab.c:522
void reset_declaration_counter(void)
Definition: cyacc.tab.c:492
int c_parse()
FILE * c_in
Definition: c_syntax.h:291
void init_C_comment(void)
Definition: clexer.c:1513
void reset_current_C_line_number(void)
Definition: clexer.c:1210
void InitScope(void)
Definition: cyacc.tab.c:306
void reset_C_comment(bool)
reset and reset_error should be handled differently
Definition: clexer.c:1450
void MakeTopLevelEntity(void)
Definition: util.c:157
void FixCReturnStatements(statement)
When return statements have been encountered, each of them has been replaced by a goto to a unique re...
Definition: return.c:223
bool check_declaration_uniqueness_p(statement)
This is designed for standard C functions, not for compilation units.
Definition: util.c:3540
void reset_preprocessor_line_analysis(void)
Definition: util.c:3592
void ResetCurrentCompilationUnitEntity(bool)
Definition: util.c:349
void RemoveFromExterns(entity)
Definition: util.c:2884
void reset_current_dummy_parameter_number(void)
Definition: util.c:144
void MakeCurrentCompilationUnitEntity(const char *)
A compilation unit is also considered as a module.
Definition: util.c:328
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
Definition: module.c:350
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
Definition: entity_names.c:56
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
#define STRING(x)
Definition: genC.h:87
if(!(yy_init))
Definition: genread_lex.c:1029
void free(void *)
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define list_undefined_p(c)
Return if a list is undefined.
Definition: newgen_list.h:75
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
void set_prettyprint_language_tag(enum language_utype lang)
set the prettyprint language from a language_utype argument
Definition: language.c:143
#define debug_on(env)
Definition: misc-local.h:157
#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 debug_off()
Definition: misc-local.h:160
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
struct __hash_table * hash_table
Define hash_table structure which is hidden.
Definition: newgen_hash.h:43
#define stack_undefined
Definition: newgen_stack.h:55
bool stack_empty_p(const stack)
void stack_free(stack *)
type, bucket_size, policy
Definition: stack.c:292
stack stack_make(int, int, int)
allocation
Definition: stack.c:246
char * string
STRING.
Definition: newgen_types.h:39
#define db_get_file_resource
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
void print_entities(list l)
Definition: entity.c:167
void statement_normalize_subscripts(statement s)
To be used for module statements.
Definition: expression.c:4471
hash_table keyword_typedef_table
Because of typedefs, the C lexers need help to decide if a character string such as toto is a type na...
Definition: static.c:253
#define value_undefined_p(x)
Definition: ri.h:3017
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_storage(x)
Definition: ri.h:2794
#define type_undefined_p(x)
Definition: ri.h:2884
#define basic_domain
newgen_area_domain_defined
Definition: ri.h:42
#define statement_declarations(x)
Definition: ri.h:2460
#define entity_type(x)
Definition: ri.h:2792
#define type_variable_p(x)
Definition: ri.h:2947
#define code_domain
newgen_cast_domain_defined
Definition: ri.h:74
#define storage_undefined_p(x)
Definition: ri.h:2477
@ is_language_c
Definition: ri.h:1567
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define entity_initial(x)
Definition: ri.h:2796
char * strdup()
int printf()
#define ifdebug(n)
Definition: sg.c:47
static string file_name

References basic_domain, c_in, c_parse(), c_parser_context_domain, CalledModules, check_declaration_uniqueness_p(), code_domain, compilation_unit_name, compilation_unit_of_module(), compilation_unit_p(), compilation_unit_parser_is_running_p, concatenate(), ContextStack, db_get_current_workspace_directory(), db_get_file_resource, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, derived_counter, ENDP, ENTITY, entity_domain, entity_initial, entity_storage, entity_type, file_name, FixCInternalLabels(), FixCReturnStatements(), FOREACH, FormalStack, free(), FunctionStack, gen_free_list(), ifdebug, init_C_comment(), init_c_parser_scope_stack(), init_entity_type_storage_table(), InitScope(), is_language_c, keyword_typedef_table, list_undefined_p, loop_counter, make_callees(), make_predefined_C_entities(), MakeCurrentCompilationUnitEntity(), MakeTopLevelEntity(), module_name(), ModuleStatement, NIL, OffsetStack, parser_init_keyword_typedef_table(), pips_assert, pips_debug, print_entities(), printf(), removable_extern_entities, RemoveFromExterns(), reset_C_comment(), reset_c_parser_current_input_file_name(), reset_c_parser_current_user_input_file_name(), reset_c_parser_scope_stack(), reset_current_C_line_number(), reset_current_dummy_parameter_number(), reset_declaration_counter(), reset_entity_type_stack_table(), reset_expression_comment(), reset_preprocessor_line_analysis(), ResetCurrentCompilationUnitEntity(), safe_fclose(), safe_fopen(), set_c_parser_current_input_file_name(), set_c_parser_current_user_input_file_name(), set_current_C_line_number(), set_prettyprint_language_tag(), stack_empty_p(), stack_free(), stack_make(), stack_undefined, statement_consistent_p(), statement_declarations, statement_normalize_subscripts(), storage_undefined_p, strdup(), STRING, StructNameStack, type_undefined_p, type_variable_p, and value_undefined_p.

Referenced by c_parser(), and compilation_unit_parser().

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

◆ c_parser()

bool c_parser ( const char *  module_name)

When the compilation_unit is parsed, it is parsed a second time and multiple declarations are certain to happen.

Parameters
module_nameodule_name

Definition at line 739 of file c_parser.c.

740 {
741  /* When the compilation_unit is parsed, it is parsed a second time
742  and multiple declarations are certain to happen. */
743  return actual_c_parser(module_name,DBR_C_SOURCE_FILE,false);
744 }
static bool actual_c_parser(const char *module_name, string dbr_file, bool is_compilation_unit_parser)
Definition: c_parser.c:544

References actual_c_parser(), and module_name().

+ Here is the call graph for this function:

◆ c_parser_error()

bool c_parser_error ( const char *  func,
const char *  msg 
)

Output a parser message error.

At the end there is a pips_user_error that launch an exception so that this function may not really exit but may be caught at a higher level...

This function is called by macro CParserError()

Since many information are lost by the various resetting, first save them for later display:

Reset the parser global variables ?

The error may occur before the current module entity is defined

Stacks are not allocated yet when dealing with external declarations. I assume that all stacks are declared simultaneously, hence a single test before freeing.

Reset them to stack_undefined_p instead of STACK_NULL

get rid of all collected comments

ffective_line_number,

Parameters
funcunc
msgsg

Definition at line 266 of file c_parser.c.

267 {
269  const char * mod_name = entity_undefined_p(mod)? "entity_undefined":entity_user_name(mod);
270  /* Since many information are lost by the various resetting, first save
271  them for later display: */
273  //int effective_line_number = c_lineno;
274 
275  pips_debug(1, "Parser error detected in function \"%s\".\n", func);
276 
277  c_reset_lex();
278 
279  /* Reset the parser global variables ?*/
280 
281  pips_debug(4,"Reset current module entity %s\n", mod_name);
282 
283  /* The error may occur before the current module entity is defined */
287 
288  // Get rid of partly declared variables
289  if(mod!=entity_undefined) {
290  value v = entity_initial(mod);
291  code c = value_code(v);
292 
293  code_declarations(c) = NIL;
295  CleanLocalEntities(mod);
296  }
297 
298  // Free CalledModules?
299 
300  // Could not rebuild filename (A. Mensi)
301  // c_in = safe_fopen(file_name, "r");
302  // safe_fclose(c_in, file_name);
303 
304  /* Stacks are not allocated yet when dealing with external
305  declarations. I assume that all stacks are declared
306  simultaneously, hence a single test before freeing. */
307  if(!entity_undefined_p(mod)) {
315  /* Reset them to stack_undefined_p instead of STACK_NULL */
320 
331  }
332  }
333 
335  /* get rid of all collected comments */
336  reset_C_comment(true);
339 
340  //debug_off();
341 
342  pips_user_warning("\nRecovery from C parser failure not (fully) implemented yet.\n"
343  "C parser is likely to fail later if re-used.\n");
347  pips_user_error("\n%s at user line %d in file \"%s\"\n",
348  msg, user_line_number, /*effective_line_number,*/ fn);
349  // Never reached, but for compatibility with Fortran ParserError
350  return true;
351 }
void error_reset_c_parser_current_user_input_file_name(void)
Definition: c_parser.c:112
void error_reset_c_parser_current_input_file_name(void)
Definition: c_parser.c:81
string get_c_parser_current_user_input_file_name()
Definition: c_parser.c:89
int get_current_C_line_number(void)
Definition: clexer.c:1146
void c_reset_lex(void)
void error_reset_current_C_line_number(void)
Definition: clexer.c:1224
void force_reset_c_parser_scope_stack(void)
To be used by an error handler.
Definition: cyacc.tab.c:539
stack SwitchControllerStack
Definition: statement.c:63
stack LoopStack
Definition: statement.c:64
void Reset_C_ReturnStatement(void)
The return statement must be reset when it is used by the parser to add the return statement to the f...
Definition: return.c:115
stack SwitchGotoStack
list of labeled statements of the current module
Definition: statement.c:62
stack BlockStack
statement.c
Definition: statement.c:58
void CleanLocalEntities(entity function)
Fortran version.
Definition: clean.c:140
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define pips_user_warning
Definition: misc-local.h:146
#define pips_user_error
Definition: misc-local.h:147
#define stack_undefined_p(s)
Definition: newgen_stack.h:56
#define string_undefined
Definition: newgen_types.h:40
int user_line_number
To be exported to the parser for error messages related to the user file.
Definition: lexer.c:1087
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
void error_reset_current_module_entity(void)
To be called by an error management routine only.
Definition: static.c:109
#define code_declarations(x)
Definition: ri.h:784
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define value_code(x)
Definition: ri.h:3067
#define code_decls_text(x)
Definition: ri.h:786

References BlockStack, c_reset_lex(), CleanLocalEntities(), code_declarations, code_decls_text, ContextStack, entity_initial, entity_undefined, entity_undefined_p, entity_user_name(), error_reset_c_parser_current_input_file_name(), error_reset_c_parser_current_user_input_file_name(), error_reset_current_C_line_number(), error_reset_current_module_entity(), force_reset_c_parser_scope_stack(), FormalStack, FunctionStack, get_c_parser_current_user_input_file_name(), get_current_C_line_number(), get_current_module_entity(), LoopStack, NIL, OffsetStack, pips_debug, pips_user_error, pips_user_warning, reset_C_comment(), Reset_C_ReturnStatement(), reset_current_dummy_parameter_number(), reset_declaration_counter(), reset_entity_type_stack_table(), reset_expression_comment(), stack_free(), stack_undefined, stack_undefined_p, string_undefined, StructNameStack, SwitchControllerStack, SwitchGotoStack, user_line_number, and value_code.

Referenced by make_C_constant_entity().

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

◆ compilation_unit_parser()

bool compilation_unit_parser ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 746 of file c_parser.c.

747 {
748  return actual_c_parser(module_name,DBR_C_SOURCE_FILE,true);
749 }

References actual_c_parser(), and module_name().

Referenced by AddEntityToCompilationUnit(), and outliner_independent().

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

◆ error_reset_c_parser_current_input_file_name()

void error_reset_c_parser_current_input_file_name ( void  )

Definition at line 81 of file c_parser.c.

82 {
84 }
static string c_parser_current_file_name
Definition: c_parser.c:56

References c_parser_current_file_name, and string_undefined.

Referenced by c_parser_error().

+ Here is the caller graph for this function:

◆ error_reset_c_parser_current_user_input_file_name()

void error_reset_c_parser_current_user_input_file_name ( void  )

Definition at line 112 of file c_parser.c.

113 {
115 }
static string c_parser_current_user_input_file_name
Definition: c_parser.c:87

References c_parser_current_user_input_file_name, and string_undefined.

Referenced by c_parser_error().

+ Here is the caller graph for this function:

◆ FixCInternalLabels()

static void FixCInternalLabels ( statement  s)
static

To avoid label name conflicts, the parser uses a special character that cannot appear in a C label.

Any label that uses this character must be replaced. A new label entity must be introduced.

Build the substitution table while avoiding label name conflicts

Here we end up with a conflict free label name

Substitute the labels by the new labels in all substatement of s

Get rid of useless label entities, unless it has already been performed by substitute_statement_label().

Definition at line 373 of file c_parser.c.

374 {
375  list pll = statement_to_labels(s);
376  hash_table label_to_new_label = hash_table_make(hash_pointer, 0);
377  int count = 0;
378 
379  /* Build the substitution table while avoiding label name conflicts */
380  FOREACH(ENTITY, l, pll) {
381  const char* ln = label_local_name(l);
382  string p = get_label_prefix(); // The prefix is assumed to be one
383  // character long
384  if(*p==*ln) {
385  string nln = strdup(ln);
386  *nln = '_';
387 
388  // In case of presence of '-' in the label
389  for(char * c = nln; *c != '\0'; c++)
390  if (*c == '-')
391  *c = '_';
392 
393  while(label_name_conflict_with_labels(nln, pll)) {
394  string nnln = strdup(concatenate("_", nln, NULL));
395  free(nln);
396  nln = nnln;
397  }
398  /* Here we end up with a conflict free label name */
399  const char* mn = entity_module_name(l);
400  // The current module is no longer definned at this point in the parser
401  //entity nl = MakeCLabel(nln);
402  string cln = strdup(concatenate(LABEL_PREFIX, nln, NULL));
403  entity nl = FindOrCreateEntity(mn, cln);
404  hash_put(label_to_new_label, (char *) l, (char *) nl);
405  free(nln), free(cln);
406  count++;
407  }
408  }
409 
410  /* Substitute the labels by the new labels in all substatement of s */
411  if(count>0) {
412  gen_context_recurse(s, (void *) label_to_new_label, statement_domain,
414 
415  /* Get rid of useless label entities, unless it has already been
416  performed by substitute_statement_label(). */
417  ;
418  }
419 
420  hash_table_free(label_to_new_label);
421 
422  return;
423 }
static int count
Definition: SDG.c:519
static bool substitute_statement_label(statement s, hash_table l_to_nl)
Definition: c_parser.c:354
#define get_label_prefix()
The labels in C have function scope...
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
list statement_to_labels(statement)
Look for non-empty labels appearing directly or indirectly and allocate a label list.
Definition: statement.c:3169
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define LABEL_PREFIX
Definition: naming-local.h:31
@ hash_pointer
Definition: newgen_hash.h:32
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 label_name_conflict_with_labels(const char *n, list ll)
Definition: entity.c:610
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
const char * label_local_name(entity e)
END_EOLE.
Definition: entity.c:604
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References concatenate(), count, ENTITY, entity_module_name(), FindOrCreateEntity(), FOREACH, free(), gen_context_recurse, gen_null2(), get_label_prefix, hash_pointer, hash_put(), hash_table_free(), hash_table_make(), label_local_name(), label_name_conflict_with_labels(), LABEL_PREFIX, statement_domain, statement_to_labels(), strdup(), and substitute_statement_label().

Referenced by actual_c_parser().

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

◆ get_c_parser_current_input_file_name()

string get_c_parser_current_input_file_name ( void  )

Definition at line 58 of file c_parser.c.

59 {
61  pips_internal_error("c_parser_current_file_name not initialized.\n");
63 }
#define pips_internal_error
Definition: misc-local.h:149
#define string_undefined_p(s)
Definition: newgen_types.h:41

References c_parser_current_file_name, pips_internal_error, and string_undefined_p.

Referenced by c_parser_user_warning_alist(), and UpdateEntity().

+ Here is the caller graph for this function:

◆ get_c_parser_current_user_input_file_name()

string get_c_parser_current_user_input_file_name ( void  )

Definition at line 89 of file c_parser.c.

90 {
92  pips_internal_error("c_parser_current_user_input_file_name not initialized.\n");
94 }

References c_parser_current_user_input_file_name, pips_internal_error, and string_undefined_p.

Referenced by c_parser_error(), and c_parser_user_warning_alist().

+ Here is the caller graph for this function:

◆ get_from_entity_type_stack_table()

stack get_from_entity_type_stack_table ( entity  key)
Parameters
keyey

Definition at line 146 of file c_parser.c.

147 {
149 
150  if(p==HASH_UNDEFINED_VALUE)
151  return stack_undefined;
152  else
153  return ((stack) p);
154 }
static hash_table entity_to_type_stack_table
Definition: c_parser.c:128
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
#define entity_name(x)
Definition: ri.h:2790
the stack head
Definition: stack.c:62

References entity_name, entity_to_type_stack_table, hash_get(), HASH_UNDEFINED_VALUE, and stack_undefined.

Referenced by FindOrCreateCurrentEntity(), RenameFunctionEntity(), SubstituteDummyParameters(), UpdateAbstractEntity(), UpdateDerivedEntity(), UpdateEntity(), and UseFormalArguments().

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

◆ init_entity_type_storage_table()

void init_entity_type_storage_table ( void  )

Definition at line 131 of file c_parser.c.

132 {
136  //put_stack_storage_table("test","T");
137 }
@ hash_string
Definition: newgen_hash.h:32
#define hash_table_undefined_p(h)
Definition: newgen_hash.h:50

References entity_to_type_stack_table, hash_string, hash_table_make(), hash_table_undefined_p, and reset_entity_type_stack_table().

Referenced by actual_c_parser().

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

◆ make_predefined_C_entities()

void make_predefined_C_entities ( string  compilation_unit_name)

Predefined type(s): __builtin_va_list

Let's lie about the real type

Predefined functions(s): __builtin_va_end (va_arg() is parsed directly)

Let's lie about the real type...

Let's lie about the real type

Let's lie about the real type

Parameters
compilation_unit_nameompilation_unit_name

Definition at line 425 of file c_parser.c.

426 {
427  entity built_in_va_list = entity_undefined;
428  entity built_in_bool = entity_undefined;
429  entity built_in_complex = entity_undefined;
430  entity built_in_va_start = entity_undefined;
431  entity built_in_va_end = entity_undefined;
432  entity built_in_va_copy = entity_undefined;
433 
434  /* Predefined type(s): __builtin_va_list */
435  built_in_va_list =
437  if(storage_undefined_p(entity_storage(built_in_va_list))) {
438  entity_storage(built_in_va_list) = make_storage_rom();
439  /* Let's lie about the real type */
440  entity_type(built_in_va_list) =
443  NIL,
444  NIL));
445  entity_initial(built_in_va_list) = make_value_unknown();
446  }
447  built_in_bool =
449  if(storage_undefined_p(entity_storage(built_in_bool))) {
450  entity_storage(built_in_bool) = make_storage_rom();
451  entity_type(built_in_bool) =
454  NIL, NIL));
455  entity_initial(built_in_bool) = make_value_unknown();
456  }
457  built_in_complex =
459  if(storage_undefined_p(entity_storage(built_in_complex))) {
460  entity_storage(built_in_complex) = make_storage_rom();
461  entity_type(built_in_complex) =
464  NIL, NIL));
465  entity_initial(built_in_complex) = make_value_unknown();
466  }
467 
468  /* Predefined functions(s): __builtin_va_end (va_arg() is parsed directly) */
469  built_in_va_start =
471  if(storage_undefined_p(entity_storage(built_in_va_start))) {
472  basic va_list_b = make_basic(is_basic_typedef, built_in_va_list);
473  type va_list_t =
476  type void_start_t =
478  entity_storage(built_in_va_start) = make_storage_rom();
479  /* Let's lie about the real type... */
480  entity_type(built_in_va_start) =
483  make_parameter(va_list_t,
485  UU),
487  CONS(PARAMETER,
488  make_parameter(void_start_t,
491  NIL)),
493  entity_initial(built_in_va_start) = make_value_intrinsic();
494  }
495 
496  built_in_va_end =
498  if(storage_undefined_p(entity_storage(built_in_va_end))) {
499  basic va_list_b = make_basic(is_basic_typedef, built_in_va_list);
500  type va_list_t =
502  entity_storage(built_in_va_end) = make_storage_rom();
503  /* Let's lie about the real type */
504  entity_type(built_in_va_end) =
507  make_parameter(va_list_t,
510  NIL),
512  entity_initial(built_in_va_end) = make_value_intrinsic();
513  }
514 
515  built_in_va_copy =
517  if(storage_undefined_p(entity_storage(built_in_va_copy))) {
518  basic va_list_b = make_basic(is_basic_typedef, built_in_va_list);
519  type va_list_t =
521  parameter va_list_p = make_parameter(va_list_t,
522  make_mode_value(),
524  entity_storage(built_in_va_copy) = make_storage_rom();
525  /* Let's lie about the real type */
526  entity_type(built_in_va_copy) =
529  va_list_p,
530  CONS(PARAMETER,
531  copy_parameter(va_list_p),
532  NIL)),
534  entity_initial(built_in_va_copy) = make_value_intrinsic();
535  }
536 }
functional make_functional(list a1, type a2)
Definition: ri.c:1109
parameter copy_parameter(parameter p)
PARAMETER.
Definition: ri.c:1459
basic make_basic_complex(intptr_t _field_)
Definition: ri.c:170
value make_value_unknown(void)
Definition: ri.c:2847
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
mode make_mode(enum mode_utype tag, void *val)
Definition: ri.c:1350
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
storage make_storage_rom(void)
Definition: ri.c:2285
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
type make_type_void(list _field_)
Definition: ri.c:2727
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
basic make_basic_logical(intptr_t _field_)
Definition: ri.c:164
value make_value_intrinsic(void)
Definition: ri.c:2844
dummy make_dummy_unknown(void)
Definition: ri.c:617
mode make_mode_value(void)
Definition: ri.c:1353
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define TYPEDEF_PREFIX
Definition: naming-local.h:62
#define UU
Definition: newgen_types.h:98
#define BUILTIN_VA_END
vararg stuff.
#define DEFAULT_LOGICAL_TYPE_SIZE
#define BUILTIN_VA_COPY
#define DEFAULT_INTEGER_TYPE_SIZE
#define DEFAULT_COMPLEX_TYPE_SIZE
#define BUILTIN_VA_START
@ is_basic_pointer
Definition: ri.h:578
@ is_basic_typedef
Definition: ri.h:580
@ is_mode_value
Definition: ri.h:1675
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
@ is_type_void
Definition: ri.h:2904
@ is_type_functional
Definition: ri.h:2901
@ is_type_variable
Definition: ri.h:2900

References BUILTIN_VA_COPY, BUILTIN_VA_END, BUILTIN_VA_START, compilation_unit_name, CONS, copy_parameter(), DEFAULT_COMPLEX_TYPE_SIZE, DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_LOGICAL_TYPE_SIZE, entity_initial, entity_storage, entity_type, entity_undefined, FindOrCreateEntity(), is_basic_pointer, is_basic_typedef, is_mode_value, is_type_functional, is_type_variable, is_type_void, make_basic(), make_basic_complex(), make_basic_int(), make_basic_logical(), make_dummy_unknown(), make_functional(), make_mode(), make_mode_value(), make_parameter(), make_storage_rom(), make_type(), make_type_void(), make_value_intrinsic(), make_value_unknown(), make_variable(), NIL, PARAMETER, storage_undefined_p, TYPEDEF_PREFIX, and UU.

Referenced by actual_c_parser().

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

◆ parser_init_keyword_typedef_table()

void parser_init_keyword_typedef_table ( void  )

FI: keyword_typedef_table is also a global variable. I am trying to move towards some kind of functional wrapping around the global variable, which I would like to declare static in ri-util/static.c.

GNU predefined type(s), expecting no conflict with user named type

AM: en attendant mieux...

typedef names are added later when encoutered.

Definition at line 193 of file c_parser.c.

194 {
195  /* FI: keyword_typedef_table is also a global variable. I am trying
196  * to move towards some kind of functional wrapping around the
197  * global variable, which I would like to declare static in
198  * ri-util/static.c.
199  */
201  hash_put(keyword_typedef_table,"auto", (char *) TK_AUTO);
202  hash_put(keyword_typedef_table,"break", (char *) TK_BREAK);
203  hash_put(keyword_typedef_table,"case", (char *) TK_CASE);
204  hash_put(keyword_typedef_table,"char", (char *) TK_CHAR);
205  hash_put(keyword_typedef_table,"const", (char *) TK_CONST);
206  hash_put(keyword_typedef_table,"__const", (char *) TK_CONST);
207  hash_put(keyword_typedef_table,"continue", (char *) TK_CONTINUE);
208  hash_put(keyword_typedef_table,"default", (char *) TK_DEFAULT);
209  hash_put(keyword_typedef_table,"do", (char *) TK_DO);
210  hash_put(keyword_typedef_table,"double", (char *) TK_DOUBLE);
211  hash_put(keyword_typedef_table,"else", (char *) TK_ELSE);
212  hash_put(keyword_typedef_table,"enum", (char *) TK_ENUM);
213  hash_put(keyword_typedef_table,"extern", (char *) TK_EXTERN);
214  hash_put(keyword_typedef_table,"float", (char *) TK_FLOAT);
215  hash_put(keyword_typedef_table,"for", (char *) TK_FOR);
216  hash_put(keyword_typedef_table,"goto", (char *) TK_GOTO);
217  hash_put(keyword_typedef_table,"if", (char *) TK_IF);
218  hash_put(keyword_typedef_table,"inline", (char *) TK_INLINE);
219  hash_put(keyword_typedef_table,"int", (char *) TK_INT);
220  hash_put(keyword_typedef_table,"__int128_t", (char *) TK_INT128);
221  hash_put(keyword_typedef_table,"__uint128_t", (char *) TK_UINT128);
222  hash_put(keyword_typedef_table,"_Complex", (char *) TK_COMPLEX);
223  hash_put(keyword_typedef_table,"long", (char *) TK_LONG);
224  hash_put(keyword_typedef_table,"register", (char *) TK_REGISTER);
225  hash_put(keyword_typedef_table,"restrict", (char *) TK_RESTRICT);
226  hash_put(keyword_typedef_table,"__restrict", (char *) TK_RESTRICT);
227  hash_put(keyword_typedef_table,"__restrict__", (char *) TK_RESTRICT);
228  hash_put(keyword_typedef_table,"return", (char *) TK_RETURN);
229  hash_put(keyword_typedef_table,"short", (char *) TK_SHORT);
230  hash_put(keyword_typedef_table,"signed", (char *) TK_SIGNED);
231  hash_put(keyword_typedef_table,"sizeof", (char *) TK_SIZEOF);
232  hash_put(keyword_typedef_table,"static", (char *) TK_STATIC);
233  hash_put(keyword_typedef_table,"struct", (char *) TK_STRUCT);
234  hash_put(keyword_typedef_table,"switch", (char *) TK_SWITCH);
235  hash_put(keyword_typedef_table,"__thread", (char *) TK_THREAD);
236  hash_put(keyword_typedef_table,"typedef", (char *) TK_TYPEDEF);
237  hash_put(keyword_typedef_table,"union", (char *) TK_UNION);
238  hash_put(keyword_typedef_table,"unsigned", (char *) TK_UNSIGNED);
239  hash_put(keyword_typedef_table,"void", (char *) TK_VOID);
240  hash_put(keyword_typedef_table,"volatile", (char *) TK_VOLATILE);
241  hash_put(keyword_typedef_table,"while", (char *) TK_WHILE);
242  hash_put(keyword_typedef_table,"__builtin_va_arg", (char *) TK_BUILTIN_VA_ARG);
243  hash_put(keyword_typedef_table,"asm", (char *) TK_ASM);
244  hash_put(keyword_typedef_table,"__asm__", (char *) TK_ASM);
245  hash_put(keyword_typedef_table,"__volatile__", (char *) TK_VOLATILE);
246 
247  /* GNU predefined type(s), expecting no conflict with user named type */
248 
249  hash_put(keyword_typedef_table,"__builtin_va_list", (char *) TK_NAMED_TYPE);
250  hash_put(keyword_typedef_table,"_Bool", (char *) TK_NAMED_TYPE);
251 
252  /* AM: en attendant mieux... */
253  hash_put(keyword_typedef_table,"STEP_ARG", (char *) TK_NAMED_TYPE);
254 
255  /* typedef names are added later when encoutered. */
256 }
hash_table make_keyword_typedef_table(int)
Definition: static.c:256
#define TK_STATIC
Definition: splitc.c:782
#define TK_BREAK
Definition: splitc.c:837
#define TK_SHORT
Definition: splitc.c:779
#define TK_WHILE
Definition: splitc.c:844
#define TK_RESTRICT
Definition: splitc.c:784
#define TK_INT128
Definition: splitc.c:766
#define TK_RETURN
Definition: splitc.c:840
#define TK_INLINE
Definition: splitc.c:850
#define TK_THREAD
Definition: splitc.c:787
#define TK_CASE
Definition: splitc.c:842
#define TK_REGISTER
Definition: splitc.c:786
#define TK_COMPLEX
Definition: splitc.c:771
#define TK_GOTO
Definition: splitc.c:839
#define TK_STRUCT
Definition: splitc.c:773
#define TK_SIZEOF
Definition: splitc.c:789
#define TK_CONST
Definition: splitc.c:783
#define TK_VOID
Definition: splitc.c:770
#define TK_UINT128
Definition: splitc.c:767
#define TK_INT
Definition: splitc.c:765
#define TK_LONG
Definition: splitc.c:778
#define TK_NAMED_TYPE
Definition: splitc.c:760
#define TK_FOR
Definition: splitc.c:846
#define TK_FLOAT
Definition: splitc.c:769
#define TK_SIGNED
Definition: splitc.c:776
#define TK_BUILTIN_VA_ARG
Definition: splitc.c:856
#define TK_SWITCH
Definition: splitc.c:841
#define TK_VOLATILE
Definition: splitc.c:780
#define TK_CONTINUE
Definition: splitc.c:838
#define TK_ELSE
Definition: splitc.c:848
#define TK_EXTERN
Definition: splitc.c:781
#define TK_ENUM
Definition: splitc.c:772
#define TK_IF
Definition: splitc.c:847
#define TK_CHAR
Definition: splitc.c:764
#define TK_AUTO
Definition: splitc.c:785
#define TK_TYPEDEF
Definition: splitc.c:774
#define TK_DO
Definition: splitc.c:845
#define TK_DEFAULT
Definition: splitc.c:843
#define TK_DOUBLE
Definition: splitc.c:768
#define TK_UNSIGNED
Definition: splitc.c:777
#define TK_UNION
Definition: splitc.c:775
#define TK_ASM
Definition: splitc.c:851

References hash_put(), keyword_typedef_table, make_keyword_typedef_table(), TK_ASM, TK_AUTO, TK_BREAK, TK_BUILTIN_VA_ARG, TK_CASE, TK_CHAR, TK_COMPLEX, TK_CONST, TK_CONTINUE, TK_DEFAULT, TK_DO, TK_DOUBLE, TK_ELSE, TK_ENUM, TK_EXTERN, TK_FLOAT, TK_FOR, TK_GOTO, TK_IF, TK_INLINE, TK_INT, TK_INT128, TK_LONG, TK_NAMED_TYPE, TK_REGISTER, TK_RESTRICT, TK_RETURN, TK_SHORT, TK_SIGNED, TK_SIZEOF, TK_STATIC, TK_STRUCT, TK_SWITCH, TK_THREAD, TK_TYPEDEF, TK_UINT128, TK_UNION, TK_UNSIGNED, TK_VOID, TK_VOLATILE, and TK_WHILE.

Referenced by actual_c_parser().

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

◆ put_to_entity_type_stack_table()

void put_to_entity_type_stack_table ( entity  key,
stack  value 
)
Parameters
keyey

Definition at line 139 of file c_parser.c.

140 {
142  pips_internal_error("The stack must be defined");
144 }

References entity_name, entity_to_type_stack_table, hash_put(), pips_internal_error, and stack_undefined_p.

Referenced by RenameFunctionEntity(), and SubstituteDummyParameters().

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

◆ remove_entity_type_stack()

void remove_entity_type_stack ( entity  e)

Definition at line 156 of file c_parser.c.

157 {
158  //entity te = entity_undefined;
159  void * p = hash_get(entity_to_type_stack_table, (void *) entity_name(e));
160  //void * p = hash_delget(entity_to_type_stack_table, (void *) e, (void **) &te);
161 
162  pips_debug(8, "Remove type stack for \"%s\":", entity_name(e));
163  //fprintf(stderr, "Remove type stack for \"%s\"\n", entity_name(e));
164  //pips_debug(8, "get=%p, delget=%p\n", p1, p);
165  if(p==HASH_UNDEFINED_VALUE) {
166  ifdebug(8) {fprintf(stderr, "no associated stack\n");
167  }
168  }
169  else {
170  stack es = (stack) p;
171 
172  (void) hash_del(entity_to_type_stack_table, (void *) entity_name(e));
173  if(!stack_undefined_p(es))
174  stack_free(&es);
175  ifdebug(8) fprintf(stderr, "done\n");
176  }
177 }
void * hash_del(hash_table htp, const void *key)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:439
struct __stack_head * stack
STACK MANAGEMENT – headers.
Definition: newgen_stack.h:47
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References entity_name, entity_to_type_stack_table, fprintf(), hash_del(), hash_get(), HASH_UNDEFINED_VALUE, ifdebug, pips_debug, stack_free(), and stack_undefined_p.

Referenced by remove_entity_type_stacks(), and SubstituteDummyParameters().

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

◆ remove_entity_type_stacks()

void remove_entity_type_stacks ( list  el)
Parameters
ell

Definition at line 179 of file c_parser.c.

180 {
181  FOREACH(ENTITY, e, el) {
183  }
184 }
void remove_entity_type_stack(entity e)
Definition: c_parser.c:156

References ENTITY, FOREACH, and remove_entity_type_stack().

Referenced by RemoveDummyArguments(), and UseFormalArguments().

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

◆ reset_c_parser_current_input_file_name()

void reset_c_parser_current_input_file_name ( void  )

Definition at line 73 of file c_parser.c.

74 {
75  // Could check that it is defined on entry
77  pips_internal_error("c_parser_current_file_name no initialized.\n");
79 }

References c_parser_current_file_name, pips_internal_error, string_undefined, and string_undefined_p.

Referenced by actual_c_parser().

+ Here is the caller graph for this function:

◆ reset_c_parser_current_user_input_file_name()

void reset_c_parser_current_user_input_file_name ( void  )

Definition at line 104 of file c_parser.c.

105 {
106  // Could check that it is defined on entry
108  pips_internal_error("c_parser_current_user_input_file_name no initialized.\n");
110 }

References c_parser_current_user_input_file_name, pips_internal_error, string_undefined, and string_undefined_p.

Referenced by actual_c_parser().

+ Here is the caller graph for this function:

◆ reset_entity_type_stack_table()

void reset_entity_type_stack_table ( void  )

Definition at line 186 of file c_parser.c.

187 {
191 }
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49

References entity_to_type_stack_table, HASH_MAP, hash_table_free(), hash_table_undefined, and stack_free().

Referenced by actual_c_parser(), c_parser_error(), and init_entity_type_storage_table().

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

◆ set_c_parser_current_input_file_name()

void set_c_parser_current_input_file_name ( string  file_name)
Parameters
file_nameile_name

Definition at line 65 of file c_parser.c.

66 {
67  // Could check that it is undefined on entry
69  pips_internal_error("c_parser_current_file_name no initialized.\n");
71 }

References c_parser_current_file_name, file_name, pips_internal_error, and string_undefined_p.

Referenced by actual_c_parser().

+ Here is the caller graph for this function:

◆ set_c_parser_current_user_input_file_name()

void set_c_parser_current_user_input_file_name ( string  file_name)
Parameters
file_nameile_name

Definition at line 96 of file c_parser.c.

97 {
98  // Could check that it is undefined on entry
100  pips_internal_error("c_parser_current_user_input_file_name no initialized.\n");
102 }

References c_parser_current_user_input_file_name, file_name, pips_internal_error, and string_undefined_p.

Referenced by actual_c_parser().

+ Here is the caller graph for this function:

◆ substitute_statement_label()

static bool substitute_statement_label ( statement  s,
hash_table  l_to_nl 
)
static

FI: entity l could be destroyed right away...

Definition at line 354 of file c_parser.c.

355 {
356  entity l = statement_label(s);
357 
358  if(!entity_empty_label_p(l)) {
359  entity nl = (entity) hash_get(l_to_nl, (char *) l);
360  if(nl!=(entity) HASH_UNDEFINED_VALUE) {
361  statement_label(s) = nl;
362  /* FI: entity l could be destroyed right away... */
363  }
364  }
365 
366  return true;
367 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
bool entity_empty_label_p(entity e)
Definition: entity.c:666
#define statement_label(x)
Definition: ri.h:2450

References entity_empty_label_p(), hash_get(), HASH_UNDEFINED_VALUE, and statement_label.

Referenced by FixCInternalLabels().

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

Variable Documentation

◆ c_parser_current_file_name

◆ c_parser_current_user_input_file_name

◆ CalledModules

list CalledModules = NIL

Definition at line 51 of file c_parser.c.

Referenced by actual_c_parser(), and AddToCalledModules().

◆ compilation_unit_name

◆ compilation_unit_parser_is_running_p

bool compilation_unit_parser_is_running_p = false

To pass down the information to functions used by the syntactical analyzer.

Definition at line 541 of file c_parser.c.

Referenced by actual_c_parser(), and analyze_preprocessor_line().

◆ ContextStack

◆ derived_counter

int derived_counter = 1

Definition at line 125 of file c_parser.c.

Referenced by actual_c_parser().

◆ entity_to_type_stack_table

◆ FormalStack

◆ FunctionStack

◆ loop_counter

int loop_counter = 1

Global counter.

Definition at line 124 of file c_parser.c.

Referenced by actual_c_parser().

◆ ModuleStatement

◆ OffsetStack

◆ removable_extern_entities

list removable_extern_entities = list_undefined

Definition at line 542 of file c_parser.c.

Referenced by actual_c_parser(), and CleanUpEntities().

◆ StructNameStack

stack StructNameStack = stack_undefined

Definition at line 121 of file c_parser.c.

Referenced by actual_c_parser(), and c_parser_error().