stage3/declaration_check.cc
changeset 963 e3d4dca7520b
parent 892 54d5d185d6e2
child 971 8aee27d46208
equal deleted inserted replaced
962:98e7a0d3af21 963:e3d4dca7520b
    73 
    73 
    74 
    74 
    75 
    75 
    76 
    76 
    77 
    77 
       
    78 #include "constant_folding.hh"
    78 
    79 
    79 
    80 
    80 #include <set>
    81 #include <set>
    81 class check_extern_c: public iterator_visitor_c {
    82 class check_extern_c: public iterator_visitor_c {
    82   public:
    83   public:
   138           search_var_instance_decl_c::opt_t ext_opt = search_var_instance_ext_decl. get_option(var_name);
   139           search_var_instance_decl_c::opt_t ext_opt = search_var_instance_ext_decl. get_option(var_name);
   139           search_var_instance_decl_c::opt_t glo_opt = search_var_instance_glo_decl->get_option(var_name);
   140           search_var_instance_decl_c::opt_t glo_opt = search_var_instance_glo_decl->get_option(var_name);
   140           if ((glo_opt == search_var_instance_decl_c::constant_opt) && (ext_opt != search_var_instance_decl_c::constant_opt))
   141           if ((glo_opt == search_var_instance_decl_c::constant_opt) && (ext_opt != search_var_instance_decl_c::constant_opt))
   141             STAGE3_ERROR(0, glo_decl, glo_decl, "Declaration error. The external variable must be declared as constant, as it maps to a constant global variable.");
   142             STAGE3_ERROR(0, glo_decl, glo_decl, "Declaration error. The external variable must be declared as constant, as it maps to a constant global variable.");
   142     
   143     
       
   144           /* Copy the const_value from the global to the external variable.
       
   145            *   This is actually part of the constant folding algorithm. It is placed here because it needs the extern<->global pairing
       
   146            *   information to run correctly, which is all available right here!
       
   147            */
       
   148           constant_folding_c constant_folding;
       
   149           constant_folding.handle_var_extern_global_pair(var_name /* extern_var */, ext_decl /* extern_decl */, NULL /* global_var */, glo_decl /* global_decl */);
       
   150 
   143           /* TODO: Check redefinition data type.
   151           /* TODO: Check redefinition data type.
   144            *       We need a new class (like search_base_type class) to get type id by variable declaration.
   152            *       We need a new class (like search_base_type class) to get type id by variable declaration.
   145            *  symbol_c *glo_type = ????;
   153            *  symbol_c *glo_type = ????;
   146            *  symbol_c *ext_type = fpi.param_type();
   154            *  symbol_c *ext_type = fpi.param_type();
   147            */
   155            */