comparison gcc/optc-gen.awk @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 # Copyright (C) 2003-2017 Free Software Foundation, Inc. 1 # Copyright (C) 2003-2018 Free Software Foundation, Inc.
2 # Contributed by Kelley Cook, June 2004. 2 # Contributed by Kelley Cook, June 2004.
3 # Original code from Neil Booth, May 2003. 3 # Original code from Neil Booth, May 2003.
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify it 5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the 6 # under the terms of the GNU General Public License as published by the
272 indices[opts[i]] = j; 272 indices[opts[i]] = j;
273 } 273 }
274 j++; 274 j++;
275 } 275 }
276 276
277 optindex = 0
277 for (i = 0; i < n_opts; i++) { 278 for (i = 0; i < n_opts; i++) {
278 # With identical flags, pick only the last one. The 279 # With identical flags, pick only the last one. The
279 # earlier loop ensured that it has all flags merged, 280 # earlier loop ensured that it has all flags merged,
280 # and a nonempty help text if one of the texts was nonempty. 281 # and a nonempty help text if one of the texts was nonempty.
281 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) { 282 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
301 s = substr(" ", length (opts[i])) 302 s = substr(" ", length (opts[i]))
302 if (i + 1 == n_opts) 303 if (i + 1 == n_opts)
303 comma = "" 304 comma = ""
304 305
305 if (help[i] == "") 306 if (help[i] == "")
306 hlp = "0" 307 hlp = "NULL"
307 else 308 else
308 hlp = quote help[i] quote; 309 hlp = quote help[i] quote;
309 310
310 missing_arg_error = opt_args("MissingArgError", flags[i]) 311 missing_arg_error = opt_args("MissingArgError", flags[i])
311 if (missing_arg_error == "") 312 if (missing_arg_error == "")
312 missing_arg_error = "0" 313 missing_arg_error = "NULL"
313 else 314 else
314 missing_arg_error = quote missing_arg_error quote 315 missing_arg_error = quote missing_arg_error quote
315 316
316 317
317 warn_message = opt_args("Warn", flags[i]) 318 warn_message = opt_args("Warn", flags[i])
318 if (warn_message == "") 319 if (warn_message == "")
319 warn_message = "0" 320 warn_message = "NULL"
320 else 321 else
321 warn_message = quote warn_message quote 322 warn_message = quote warn_message quote
322 323
323 alias_arg = opt_args("Alias", flags[i]) 324 alias_arg = opt_args("Alias", flags[i])
324 if (alias_arg == "") { 325 if (alias_arg == "") {
325 if (flag_set_p("Ignore", flags[i])) 326 if (flag_set_p("Ignore", flags[i])) {
326 alias_data = "NULL, NULL, OPT_SPECIAL_ignore" 327 alias_data = "NULL, NULL, OPT_SPECIAL_ignore"
328 if (warn_message != "NULL")
329 print "#error Ignored option with Warn"
330 if (var_name(flags[i]) != "")
331 print "#error Ignored option with Var"
332 if (flag_set_p("Report", flags[i]))
333 print "#error Ignored option with Report"
334 }
335 else if (flag_set_p("Deprecated", flags[i])) {
336 alias_data = "NULL, NULL, OPT_SPECIAL_deprecated"
337 if (warn_message != "NULL")
338 print "#error Deprecated option with Warn"
339 if (flag_set_p("Report", flags[i]))
340 print "#error Deprecated option with Report"
341 }
327 else 342 else
328 alias_data = "NULL, NULL, N_OPTS" 343 alias_data = "NULL, NULL, N_OPTS"
329 if (flag_set_p("Enum.*", flags[i])) { 344 if (flag_set_p("Enum.*", flags[i])) {
330 if (!flag_set_p("RejectNegative", flags[i]) \ 345 if (!flag_set_p("RejectNegative", flags[i]) \
331 && opts[i] ~ "^[Wfgm]") 346 && opts[i] ~ "^[Wfgm]")
376 idx = -1; 391 idx = -1;
377 } 392 }
378 } 393 }
379 # Split the printf after %u to work around an ia64-hp-hpux11.23 394 # Split the printf after %u to work around an ia64-hp-hpux11.23
380 # awk bug. 395 # awk bug.
381 printf(" { %c-%s%c,\n %s,\n %s,\n %s,\n %s, %s, %u,", 396 printf(" /* [%i] = */ {\n", optindex)
397 printf(" %c-%s%c,\n %s,\n %s,\n %s,\n %s, %s, %u,",
382 quote, opts[i], quote, hlp, missing_arg_error, warn_message, 398 quote, opts[i], quote, hlp, missing_arg_error, warn_message,
383 alias_data, back_chain[i], len) 399 alias_data, back_chain[i], len)
384 printf(" %d,\n", idx) 400 printf(" /* .neg_idx = */ %d,\n", idx)
385 condition = opt_args("Condition", flags[i]) 401 condition = opt_args("Condition", flags[i])
386 cl_flags = switch_flags(flags[i]) 402 cl_flags = switch_flags(flags[i])
387 cl_bit_fields = switch_bit_fields(flags[i]) 403 cl_bit_fields = switch_bit_fields(flags[i])
388 cl_zero_bit_fields = switch_bit_fields("") 404 cl_zero_bit_fields = switch_bit_fields("")
389 if (condition != "") 405 if (condition != "")
400 " 0, %s,\n", 416 " 0, %s,\n",
401 cl_flags, cl_bit_fields) 417 cl_flags, cl_bit_fields)
402 printf(" %s, %s, %s }%s\n", var_ref(opts[i], flags[i]), 418 printf(" %s, %s, %s }%s\n", var_ref(opts[i], flags[i]),
403 var_set(flags[i]), integer_range_info(opt_args("IntegerRange", flags[i]), 419 var_set(flags[i]), integer_range_info(opt_args("IntegerRange", flags[i]),
404 opt_args("Init", flags[i]), opts[i]), comma) 420 opt_args("Init", flags[i]), opts[i]), comma)
405 } 421
422 # Bump up the informational option index.
423 ++optindex
424 }
406 425
407 print "};" 426 print "};"
408 427
409 print "\n\n" 428 print "\n\n"
410 print "bool " 429 print "bool "
415 print " location_t loc, " 434 print " location_t loc, "
416 print " const struct cl_option_handlers *handlers, " 435 print " const struct cl_option_handlers *handlers, "
417 print " diagnostic_context *dc) " 436 print " diagnostic_context *dc) "
418 print "{ " 437 print "{ "
419 print " size_t scode = decoded->opt_index; " 438 print " size_t scode = decoded->opt_index; "
420 print " int value = decoded->value; " 439 print " HOST_WIDE_INT value = decoded->value; "
421 print " enum opt_code code = (enum opt_code) scode; " 440 print " enum opt_code code = (enum opt_code) scode; "
422 print " " 441 print " "
423 print " gcc_assert (decoded->canonical_option_num_elements <= 2); " 442 print " gcc_assert (decoded->canonical_option_num_elements <= 2); "
424 print " " 443 print " "
425 print " switch (code) " 444 print " switch (code) "
465 484
466 print "\n\n" 485 print "\n\n"
467 print "bool " 486 print "bool "
468 print lang_name "_handle_option_auto (struct gcc_options *opts" mark_unused ", " 487 print lang_name "_handle_option_auto (struct gcc_options *opts" mark_unused ", "
469 print " struct gcc_options *opts_set" mark_unused ", " 488 print " struct gcc_options *opts_set" mark_unused ", "
470 print " size_t scode" mark_unused ", const char *arg" mark_unused ", int value" mark_unused ", " 489 print " size_t scode" mark_unused ", const char *arg" mark_unused ", HOST_WIDE_INT value" mark_unused ", "
471 print " unsigned int lang_mask" mark_unused ", int kind" mark_unused ", " 490 print " unsigned int lang_mask" mark_unused ", int kind" mark_unused ", "
472 print " location_t loc" mark_unused ", " 491 print " location_t loc" mark_unused ", "
473 print " const struct cl_option_handlers *handlers" mark_unused ", " 492 print " const struct cl_option_handlers *handlers" mark_unused ", "
474 print " diagnostic_context *dc" mark_unused ") " 493 print " diagnostic_context *dc" mark_unused ") "
475 print "{ " 494 print "{ "