This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Fix PR 43574


flag_var_tracking and flag_var_tracking_assignments can have negative values. But the generated options.c asserts that their values must be in range [0, 255]. This patch adds a new option property "Signed". So options like flag_var_tracking and flag_var_tracking_assignments can use this new property to specify that they can take negative value. "signed char" instead of "unsigned char" will be used as the type for such options and their values will be checked in range between [-128, 127]. No regressions are found on x86_64 with this patch. Is it OK?


-- Jie Zhang CodeSourcery (650) 331-3385 x735
	PR 43574
	* opts.h (CL_SIGNED): Add.
	* common.opt (flag_var_tracking): Add Signed.
	(flag_var_tracking_assignments): Add Signed.
	* opt-functions.awk (switch_flags): Handle Signed.
	(var_type_struct): Handle Signed.
	* doc/options.texi: Document Signed.


Index: doc/options.texi
===================================================================
--- doc/options.texi	(revision 157794)
+++ doc/options.texi	(working copy)
@@ -243,4 +243,7 @@ the @option{--help} output.
 Build the @code{cl_target_option} structure to hold a copy of the
 option, add the functions @code{cl_target_option_save} and
 @code{cl_target_option_restore} to save and restore the options.
+
+@item Signed
+The option might take negative value.
 @end table
Index: opts.h
===================================================================
--- opts.h	(revision 157794)
+++ opts.h	(working copy)
@@ -89,6 +89,7 @@ extern const unsigned int cl_lang_count;
 #define CL_MISSING_OK		(1 << 28) /* Missing argument OK (joined).  */
 #define CL_UINTEGER		(1 << 29) /* Argument is an integer >=0.  */
 #define CL_UNDOCUMENTED		(1 << 30) /* Do not output with --help.  */
+#define CL_SIGNED		(1 << 31) /* Argument might be <0.  */
 
 /* Input file names.  */
 
Index: common.opt
===================================================================
--- common.opt	(revision 157794)
+++ common.opt	(working copy)
@@ -1405,11 +1405,11 @@ fuse-linker-plugin
 Common Undocumented
 
 fvar-tracking
-Common Report Var(flag_var_tracking) VarExists Optimization
+Common Report Var(flag_var_tracking) VarExists Optimization Signed
 Perform variable tracking
 
 fvar-tracking-assignments
-Common Report Var(flag_var_tracking_assignments) VarExists Optimization
+Common Report Var(flag_var_tracking_assignments) VarExists Optimization Signed
 Perform variable tracking by annotating assignments
 
 fvar-tracking-assignments-toggle
Index: opt-functions.awk
===================================================================
--- opt-functions.awk	(revision 157794)
+++ opt-functions.awk	(working copy)
@@ -86,7 +86,8 @@ function switch_flags (flags)
 	  test_flag("Undocumented", flags,  " | CL_UNDOCUMENTED") \
 	  test_flag("Warning", flags,  " | CL_WARNING") \
 	  test_flag("Optimization", flags,  " | CL_OPTIMIZATION") \
-	  test_flag("Report", flags, " | CL_REPORT")
+	  test_flag("Report", flags, " | CL_REPORT") \
+	  test_flag("Signed", flags, " | CL_SIGNED")
 	sub( "^0 \\| ", "", result )
 	return result
 }
@@ -145,6 +146,8 @@ function var_type_struct(flags)
 	else if (!flag_set_p("Joined.*", flags)) {
 		if (flag_set_p(".*Mask.*", flags))
 			return "int "
+		else if (flag_set_p("Signed", flags))
+			return "signed char "
 		else
 			return "unsigned char "
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]