stage3/declaration_check.cc
changeset 865 7365c3e5c9ae
parent 812 6679b6b21214
child 892 54d5d185d6e2
equal deleted inserted replaced
864:300c27c08753 865:7365c3e5c9ae
   110       if (NULL == glo_decl) {
   110       if (NULL == glo_decl) {
   111         STAGE3_ERROR(0, ext_decl, ext_decl, "Declaration error. The external variable does not match with any global variable.");
   111         STAGE3_ERROR(0, ext_decl, ext_decl, "Declaration error. The external variable does not match with any global variable.");
   112         continue;
   112         continue;
   113       }
   113       }
   114       
   114       
   115       if (search_var_instance_glo_decl->get_option(var_name) != search_var_instance_ext_decl.get_option(var_name))
   115       /* Check whether variable's constness (CONSTANT) is compatible.
   116         STAGE3_ERROR(0, glo_decl, glo_decl, "Declaration error.  The external variable options do not match with thos of the global variable.");
   116        *        VAR_GLOBAL is contant     => VAR_EXTERNAL must also be CONSTANT
       
   117        *        VAR_GLOBAL is not contant => VAR_EXTERNAL may be CONSTANT, or not!
       
   118        */
       
   119       search_var_instance_decl_c::opt_t ext_opt = search_var_instance_ext_decl. get_option(var_name);
       
   120       search_var_instance_decl_c::opt_t glo_opt = search_var_instance_glo_decl->get_option(var_name);
       
   121       if ((glo_opt == search_var_instance_decl_c::constant_opt) && (ext_opt != search_var_instance_decl_c::constant_opt))
       
   122         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.");
   117 
   123 
   118       /* TODO: Check redefinition data type.
   124       /* TODO: Check redefinition data type.
   119        *       We need a new class (like search_base_type class) to get type id by variable declaration.
   125        *       We need a new class (like search_base_type class) to get type id by variable declaration.
   120        *  symbol_c *glo_type = ????;
   126        *  symbol_c *glo_type = ????;
   121        *  symbol_c *ext_type = fpi.param_type();
   127        *  symbol_c *ext_type = fpi.param_type();