Add check whether external var matches to global var.
authorManuele Conti <conti.ma@alice.it>
Fri, 28 Sep 2012 23:59:28 +0200
changeset 663 6ad7de83d22c
parent 662 b1b11dd09a54
child 664 199a9f84e64c
Add check whether external var matches to global var.
stage3/declaration_check.cc
--- a/stage3/declaration_check.cc	Thu Sep 27 18:14:52 2012 +0100
+++ b/stage3/declaration_check.cc	Fri Sep 28 23:59:28 2012 +0200
@@ -96,7 +96,11 @@
      	 /* found an external reference parameter. */
      	symbol_c *glo_decl = search_var_instance_glo_decl.get_decl(var_name);
         symbol_c *ext_decl = search_var_instance_ext_decl.get_decl(var_name);
-    	if (search_var_instance_glo_decl.get_option(var_name) != search_var_instance_ext_decl.get_option(var_name))
+    	if (glo_decl == NULL) {
+    	  STAGE3_ERROR(0, ext_decl, ext_decl, "Declaration error an external doesn't mach with any global var.");
+    	  continue;
+    	}
+        if (search_var_instance_glo_decl.get_option(var_name) != search_var_instance_ext_decl.get_option(var_name))
           STAGE3_ERROR(0, glo_decl, glo_decl, "Declaration error an external redefinition option.");
 
         /* TODO: Check redefinition data type.