@@ -4689,6 +4689,56 @@ move_error (cb_tree src, cb_tree dst, const size_t value_flag, const int flag,
46894689	return  0 ;
46904690}
46914691
4692+ static  void 
4693+ error_destination  (cb_tree  x )
4694+ {
4695+ 	struct  cb_reference      * r ;
4696+ 	struct  cb_field          * f ;
4697+ 	cb_tree                  loc ;
4698+ 
4699+ 	r  =  CB_REFERENCE  (x );
4700+ 	f  =  CB_FIELD  (r -> value );
4701+ 	loc  =  CB_TREE  (f );
4702+ 
4703+ 	if  (r -> offset ) {
4704+ 		return ;
4705+ 	}
4706+ 
4707+ 	if  (!strcmp  (f -> name , "RETURN-CODE" ) || 
4708+ 			!strcmp  (f -> name , "SORT-RETURN" ) || 
4709+ 			!strcmp  (f -> name , "NUMBER-OF-CALL-PARAMETERS" )) {
4710+ 		cb_error  (_ ("Internal register '%s' defined as BINARY-LONG" ), f -> name );
4711+ 	} else  if  (f -> pic ) {
4712+ 		cb_error_x  (loc , _ ("'%s' defined here as PIC %s" ), check_filler_name  ((char  * )f -> name ), f -> pic -> orig );
4713+ 	} else  {
4714+ 		cb_error_x  (loc , _ ("'%s' defined here as a group of length %d" ), check_filler_name  ((char  * )f -> name ), f -> size );
4715+ 	}
4716+ }
4717+ 
4718+ static  int 
4719+ move_error2  (cb_tree  src , cb_tree  dst , const  size_t  value_flag , const  int  flag ,
4720+ 		const  int  src_flag , const  char  * msg )
4721+ {
4722+ 	cb_tree  loc ;
4723+ 
4724+ 	loc  =  src -> source_line  ? src  : dst ;
4725+ 	if  (value_flag ) {
4726+ 		/* VALUE clause */ 
4727+ 		cb_error_x  (loc , msg );
4728+ 	} else  {
4729+ 		/* MOVE statement */ 
4730+ 		if  (flag ) {
4731+ 			cb_error_x  (loc , msg );
4732+ 			if  (src_flag ) {
4733+ 				error_destination  (src );
4734+ 			}
4735+ 			error_destination  (dst );
4736+ 		}
4737+ 	}
4738+ 
4739+ 	return  0 ;
4740+ }
4741+ 
46924742/* count the number of free places in an alphanumeric edited field */ 
46934743static  int 
46944744count_pic_alphanumeric_edited  (struct  cb_field  * field )
@@ -5335,6 +5385,11 @@ validate_move (cb_tree src, cb_tree dst, size_t is_value)
53355385	return  0 ;
53365386
53375387expect_numeric :
5388+ 	if  (cb_enable_expect_numeric_error ) {
5389+ 		return  move_error2  (src , dst , is_value , 1 , 0 ,
5390+ 				   _ ("Numeric value is expected" ));
5391+ 	}
5392+ 
53385393	return  move_error  (src , dst , is_value , cb_warn_strict_typing , 0 ,
53395394			   _ ("Numeric value is expected" ));
53405395
@@ -6029,6 +6084,11 @@ cb_emit_move (cb_tree src, cb_tree dsts)
60296084	}
60306085
60316086	for  (l  =  dsts ; l ; l  =  CB_CHAIN  (l )) {
6087+ 		if  (cb_enable_expect_numeric_error ) {
6088+ 			if  (CB_TREE_TAG  (src ) ==  CB_TAG_REFERENCE ) {
6089+ 				cb_emit  (cb_build_funcall_2  ("cob_check_mvstrnum" , src , CB_VALUE  (l )));
6090+ 			}
6091+ 		}
60326092		cb_emit  (cb_build_move  (src , CB_VALUE  (l )));
60336093	}
60346094}
@@ -7717,3 +7777,22 @@ cb_build_write_advancing_page (cb_tree pos)
77177777
77187778	return  cb_int  (opt  | COB_WRITE_PAGE );
77197779}
7780+ 
7781+ cb_tree 
7782+ cb_check_zero_division  (cb_tree  x )
7783+ {
7784+ 	if  (x  ==  cb_error_node ) {
7785+ 		return  cb_error_node ;
7786+ 	}
7787+ 
7788+ 	if  (! CB_NUMERIC_LITERAL_P  (x )) {
7789+ 		return  x ;
7790+ 	}
7791+ 
7792+ 	if  (cb_get_int (x ) ==  0 ) {
7793+ 		cb_error_x  (x , _ ("Detected division by zero." ));	
7794+ 		return  cb_error_node ;
7795+ 	}
7796+ 
7797+ 	return  x ;
7798+ }
0 commit comments