@@ -164,12 +164,17 @@ extern const struct cl_var cl_vars[];
164164extern const char * const lang_names [];
165165extern const unsigned int cl_lang_count ;
166166
167- #define CL_PARAMS (1U << 16) /* Fake entry. Used to display --param info with --help. */
168- #define CL_WARNING (1U << 17) /* Enables an (optional) warning message. */
169- #define CL_OPTIMIZATION (1U << 18) /* Enables an (optional) optimization. */
170- #define CL_DRIVER (1U << 19) /* Driver option. */
171- #define CL_TARGET (1U << 20) /* Target-specific option. */
172- #define CL_COMMON (1U << 21) /* Language-independent. */
167+ /* Bits 0 to cl_lang_count - 1 are reserved for the languages declared by the
168+ Language records in the .opt files; see CL_LANG_ALL in options.h. When a
169+ front end is added, every macro below has to be shifted up by one bit to
170+ make room for it. */
171+
172+ #define CL_PARAMS (1U << 17) /* Fake entry. Used to display --param info with --help. */
173+ #define CL_WARNING (1U << 18) /* Enables an (optional) warning message. */
174+ #define CL_OPTIMIZATION (1U << 19) /* Enables an (optional) optimization. */
175+ #define CL_DRIVER (1U << 20) /* Driver option. */
176+ #define CL_TARGET (1U << 21) /* Target-specific option. */
177+ #define CL_COMMON (1U << 22) /* Language-independent. */
173178
174179#define CL_MIN_OPTION_CLASS CL_PARAMS
175180#define CL_MAX_OPTION_CLASS CL_COMMON
@@ -179,11 +184,22 @@ extern const unsigned int cl_lang_count;
179184 This distinction is important because --help will not list options
180185 which only have these higher bits set. */
181186
182- #define CL_JOINED (1U << 22) /* If takes joined argument. */
183- #define CL_SEPARATE (1U << 23) /* If takes a separate argument. */
184- #define CL_UNDOCUMENTED (1U << 24) /* Do not output with --help. */
185- #define CL_NO_DWARF_RECORD (1U << 25) /* Do not add to producer string. */
186- #define CL_PCH_IGNORE (1U << 26) /* Do compare state for pch. */
187+ #define CL_JOINED (1U << 23) /* If takes joined argument. */
188+ #define CL_SEPARATE (1U << 24) /* If takes a separate argument. */
189+ #define CL_UNDOCUMENTED (1U << 25) /* Do not output with --help. */
190+ #define CL_NO_DWARF_RECORD (1U << 26) /* Do not add to producer string. */
191+ #define CL_PCH_IGNORE (1U << 27) /* Do compare state for pch. */
192+
193+ /* The language bits must not collide with the option class and attribute bits
194+ defined above; adding a Language record to a .opt file without shifting
195+ those macros up would give a language the same bit as CL_PARAMS.
196+ optc-gen.awk emits an equivalent #error into options.cc, but that only
197+ covers the one generated file, so state the invariant here too, where the
198+ bits are actually laid out. CL_LANG_ALL comes from the generated
199+ options.h, which a few users of this header include only afterwards. */
200+ #ifdef CL_LANG_ALL
201+ STATIC_ASSERT ((CL_LANG_ALL & CL_MIN_OPTION_CLASS ) == 0 );
202+ #endif
187203
188204/* Flags for an enumerated option argument. */
189205#define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */
0 commit comments