Mercurial > hg > CbC > CbC_gcc
comparison gcc/params.c @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
130:e108057fa461 | 132:d34655255c78 |
---|---|
1 /* params.c - Run-time parameters. | 1 /* params.c - Run-time parameters. |
2 Copyright (C) 2001-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2001-2018 Free Software Foundation, Inc. |
3 Written by Mark Mitchell <mark@codesourcery.com>. | 3 Written by Mark Mitchell <mark@codesourcery.com>. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
23 #include "coretypes.h" | 23 #include "coretypes.h" |
24 #include "common/common-target.h" | 24 #include "common/common-target.h" |
25 #include "params.h" | 25 #include "params.h" |
26 #include "params-enum.h" | 26 #include "params-enum.h" |
27 #include "diagnostic-core.h" | 27 #include "diagnostic-core.h" |
28 #include "diagnostic.h" | |
28 #include "spellcheck.h" | 29 #include "spellcheck.h" |
29 | 30 |
30 /* An array containing the compiler parameters and their current | 31 /* An array containing the compiler parameters and their current |
31 values. */ | 32 values. */ |
32 | 33 |
56 #undef DEFPARAM | 57 #undef DEFPARAM |
57 #undef DEFPARAMENUM5 | 58 #undef DEFPARAMENUM5 |
58 { NULL, 0, 0, 0, NULL, NULL } | 59 { NULL, 0, 0, 0, NULL, NULL } |
59 }; | 60 }; |
60 | 61 |
62 static bool | |
63 validate_param (const int value, const param_info param, const int index); | |
64 | |
65 | |
61 /* Add the N PARAMS to the current list of compiler parameters. */ | 66 /* Add the N PARAMS to the current list of compiler parameters. */ |
62 | 67 |
63 void | 68 void |
64 add_params (const param_info params[], size_t n) | 69 add_params (const param_info params[], size_t n) |
65 { | 70 { |
66 gcc_assert (!params_finished); | 71 gcc_assert (!params_finished); |
67 | 72 |
68 /* Allocate enough space for the new parameters. */ | 73 /* Allocate enough space for the new parameters. */ |
69 compiler_params = XRESIZEVEC (param_info, compiler_params, | 74 compiler_params = XRESIZEVEC (param_info, compiler_params, |
70 num_compiler_params + n); | 75 num_compiler_params + n); |
76 param_info *dst_params = compiler_params + num_compiler_params; | |
77 | |
71 /* Copy them into the table. */ | 78 /* Copy them into the table. */ |
72 memcpy (compiler_params + num_compiler_params, | 79 memcpy (dst_params, params, n * sizeof (param_info)); |
73 params, | 80 |
74 n * sizeof (param_info)); | |
75 /* Keep track of how many parameters we have. */ | 81 /* Keep track of how many parameters we have. */ |
76 num_compiler_params += n; | 82 num_compiler_params += n; |
83 | |
84 /* Initialize the pretty printing machinery in case we need to print an error, | |
85 but be sure not to initialize it if something else already has, e.g. a | |
86 language front-end like cc1. */ | |
87 if (!diagnostic_ready_p ()) | |
88 diagnostic_initialize (global_dc, 0); | |
89 | |
90 /* Now perform some validation and validation failures trigger an error so | |
91 initialization will stop. */ | |
92 for (size_t i = num_compiler_params - n; i < n; i++) | |
93 validate_param (params[i].default_value, params[i], (int)i); | |
77 } | 94 } |
78 | 95 |
79 /* Add all parameters and default values that can be set in both the | 96 /* Add all parameters and default values that can be set in both the |
80 driver and the compiler proper. */ | 97 driver and the compiler proper. */ |
81 | 98 |
123 gcc_assert (params_finished); | 140 gcc_assert (params_finished); |
124 | 141 |
125 params[i] = value; | 142 params[i] = value; |
126 if (explicit_p) | 143 if (explicit_p) |
127 params_set[i] = true; | 144 params_set[i] = true; |
145 } | |
146 | |
147 /* Validate PARAM and write an error if invalid. */ | |
148 | |
149 static bool | |
150 validate_param (const int value, const param_info param, const int index) | |
151 { | |
152 /* These paremeters interpret bounds of 0 to be unbounded, as such don't | |
153 perform any range validation on 0 parameters. */ | |
154 if (value < param.min_value && param.min_value != 0) | |
155 { | |
156 error ("minimum value of parameter %qs is %u", | |
157 param.option, param.min_value); | |
158 return false; | |
159 } | |
160 else if (param.max_value > param.min_value && value > param.max_value) | |
161 { | |
162 error ("maximum value of parameter %qs is %u", | |
163 param.option, param.max_value); | |
164 return false; | |
165 } | |
166 else if (targetm_common.option_validate_param (value, index)) | |
167 return true; | |
168 | |
169 return false; | |
128 } | 170 } |
129 | 171 |
130 /* Return true if it can find the matching entry for NAME in the parameter | 172 /* Return true if it can find the matching entry for NAME in the parameter |
131 table, and assign the entry index to INDEX. Return false otherwise. */ | 173 table, and assign the entry index to INDEX. Return false otherwise. */ |
132 | 174 |
198 error ("invalid parameter %qs", name); | 240 error ("invalid parameter %qs", name); |
199 return; | 241 return; |
200 } | 242 } |
201 i = (size_t)index; | 243 i = (size_t)index; |
202 | 244 |
203 if (value < compiler_params[i].min_value) | 245 if (validate_param (value, compiler_params[i], i)) |
204 error ("minimum value of parameter %qs is %u", | |
205 compiler_params[i].option, | |
206 compiler_params[i].min_value); | |
207 else if (compiler_params[i].max_value > compiler_params[i].min_value | |
208 && value > compiler_params[i].max_value) | |
209 error ("maximum value of parameter %qs is %u", | |
210 compiler_params[i].option, | |
211 compiler_params[i].max_value); | |
212 else | |
213 set_param_value_internal ((compiler_param) i, value, | 246 set_param_value_internal ((compiler_param) i, value, |
214 params, params_set, true); | 247 params, params_set, true); |
215 } | 248 } |
216 | 249 |
217 /* Set the value of the parameter given by NUM to VALUE in PARAMS and | 250 /* Set the value of the parameter given by NUM to VALUE in PARAMS and |
218 PARAMS_SET, implicitly, if it has not been set explicitly by the | 251 PARAMS_SET, implicitly, if it has not been set explicitly by the |
219 user. */ | 252 user either via the commandline or configure. */ |
220 | 253 |
221 void | 254 void |
222 maybe_set_param_value (compiler_param num, int value, | 255 maybe_set_param_value (compiler_param num, int value, |
223 int *params, int *params_set) | 256 int *params, int *params_set) |
224 { | 257 { |