Mercurial > hg > CbC > CbC_gcc
comparison libcpp/directives.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
102 static const char *parse_include (cpp_reader *, int *, const cpp_token ***, | 102 static const char *parse_include (cpp_reader *, int *, const cpp_token ***, |
103 source_location *); | 103 source_location *); |
104 static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *); | 104 static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *); |
105 static unsigned int read_flag (cpp_reader *, unsigned int); | 105 static unsigned int read_flag (cpp_reader *, unsigned int); |
106 static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *); | 106 static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *); |
107 static void do_diagnostic (cpp_reader *, int, int); | 107 static void do_diagnostic (cpp_reader *, int, int, int); |
108 static cpp_hashnode *lex_macro_node (cpp_reader *, bool); | 108 static cpp_hashnode *lex_macro_node (cpp_reader *, bool); |
109 static int undefine_macros (cpp_reader *, cpp_hashnode *, void *); | 109 static int undefine_macros (cpp_reader *, cpp_hashnode *, void *); |
110 static void do_include_common (cpp_reader *, enum include_type); | 110 static void do_include_common (cpp_reader *, enum include_type); |
111 static struct pragma_entry *lookup_pragma_entry (struct pragma_entry *, | 111 static struct pragma_entry *lookup_pragma_entry (struct pragma_entry *, |
112 const cpp_hashnode *); | 112 const cpp_hashnode *); |
353 && CPP_PEDANTIC (pfile)) | 353 && CPP_PEDANTIC (pfile)) |
354 cpp_error (pfile, CPP_DL_PEDWARN, "#%s is a GCC extension", dir->name); | 354 cpp_error (pfile, CPP_DL_PEDWARN, "#%s is a GCC extension", dir->name); |
355 else if (((dir->flags & DEPRECATED) != 0 | 355 else if (((dir->flags & DEPRECATED) != 0 |
356 || (dir == &dtable[T_IMPORT] && !CPP_OPTION (pfile, objc))) | 356 || (dir == &dtable[T_IMPORT] && !CPP_OPTION (pfile, objc))) |
357 && CPP_OPTION (pfile, warn_deprecated)) | 357 && CPP_OPTION (pfile, warn_deprecated)) |
358 cpp_error (pfile, CPP_DL_WARNING, "#%s is a deprecated GCC extension", | 358 cpp_warning (pfile, CPP_W_DEPRECATED, |
359 dir->name); | 359 "#%s is a deprecated GCC extension", dir->name); |
360 } | 360 } |
361 | 361 |
362 /* Traditionally, a directive is ignored unless its # is in | 362 /* Traditionally, a directive is ignored unless its # is in |
363 column 1. Therefore in code intended to work with K+R | 363 column 1. Therefore in code intended to work with K+R |
364 compilers, directives added by C89 must have their # | 364 compilers, directives added by C89 must have their # |
366 This is true even of directives in skipped conditional | 366 This is true even of directives in skipped conditional |
367 blocks. #elif cannot be used at all. */ | 367 blocks. #elif cannot be used at all. */ |
368 if (CPP_WTRADITIONAL (pfile)) | 368 if (CPP_WTRADITIONAL (pfile)) |
369 { | 369 { |
370 if (dir == &dtable[T_ELIF]) | 370 if (dir == &dtable[T_ELIF]) |
371 cpp_error (pfile, CPP_DL_WARNING, | 371 cpp_warning (pfile, CPP_W_TRADITIONAL, |
372 "suggest not using #elif in traditional C"); | 372 "suggest not using #elif in traditional C"); |
373 else if (indented && dir->origin == KANDR) | 373 else if (indented && dir->origin == KANDR) |
374 cpp_error (pfile, CPP_DL_WARNING, | 374 cpp_warning (pfile, CPP_W_TRADITIONAL, |
375 "traditional C ignores #%s with the # indented", | 375 "traditional C ignores #%s with the # indented", |
376 dir->name); | 376 dir->name); |
377 else if (!indented && dir->origin != KANDR) | 377 else if (!indented && dir->origin != KANDR) |
378 cpp_error (pfile, CPP_DL_WARNING, | 378 cpp_warning (pfile, CPP_W_TRADITIONAL, |
379 "suggest hiding #%s from traditional C with an indented #", | 379 "suggest hiding #%s from traditional C with an indented #", |
380 dir->name); | 380 dir->name); |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 /* Check if we have a known directive. INDENTED is nonzero if the | 384 /* Check if we have a known directive. INDENTED is nonzero if the |
385 '#' of the directive was indented. This function is in this file | 385 '#' of the directive was indented. This function is in this file |
1043 } | 1043 } |
1044 | 1044 |
1045 /* Report a warning or error detected by the program we are | 1045 /* Report a warning or error detected by the program we are |
1046 processing. Use the directive's tokens in the error message. */ | 1046 processing. Use the directive's tokens in the error message. */ |
1047 static void | 1047 static void |
1048 do_diagnostic (cpp_reader *pfile, int code, int print_dir) | 1048 do_diagnostic (cpp_reader *pfile, int code, int reason, int print_dir) |
1049 { | 1049 { |
1050 const unsigned char *dir_name; | 1050 const unsigned char *dir_name; |
1051 unsigned char *line; | 1051 unsigned char *line; |
1052 source_location src_loc = pfile->cur_token[-1].src_loc; | 1052 source_location src_loc = pfile->cur_token[-1].src_loc; |
1053 | 1053 |
1057 dir_name = NULL; | 1057 dir_name = NULL; |
1058 pfile->state.prevent_expansion++; | 1058 pfile->state.prevent_expansion++; |
1059 line = cpp_output_line_to_string (pfile, dir_name); | 1059 line = cpp_output_line_to_string (pfile, dir_name); |
1060 pfile->state.prevent_expansion--; | 1060 pfile->state.prevent_expansion--; |
1061 | 1061 |
1062 cpp_error_with_line (pfile, code, src_loc, 0, "%s", line); | 1062 if (code == CPP_DL_WARNING_SYSHDR && reason) |
1063 cpp_warning_with_line_syshdr (pfile, reason, src_loc, 0, "%s", line); | |
1064 else if (code == CPP_DL_WARNING && reason) | |
1065 cpp_warning_with_line (pfile, reason, src_loc, 0, "%s", line); | |
1066 else | |
1067 cpp_error_with_line (pfile, code, src_loc, 0, "%s", line); | |
1063 free (line); | 1068 free (line); |
1064 } | 1069 } |
1065 | 1070 |
1066 static void | 1071 static void |
1067 do_error (cpp_reader *pfile) | 1072 do_error (cpp_reader *pfile) |
1068 { | 1073 { |
1069 do_diagnostic (pfile, CPP_DL_ERROR, 1); | 1074 do_diagnostic (pfile, CPP_DL_ERROR, 0, 1); |
1070 } | 1075 } |
1071 | 1076 |
1072 static void | 1077 static void |
1073 do_warning (cpp_reader *pfile) | 1078 do_warning (cpp_reader *pfile) |
1074 { | 1079 { |
1075 /* We want #warning diagnostics to be emitted in system headers too. */ | 1080 /* We want #warning diagnostics to be emitted in system headers too. */ |
1076 do_diagnostic (pfile, CPP_DL_WARNING_SYSHDR, 1); | 1081 do_diagnostic (pfile, CPP_DL_WARNING_SYSHDR, CPP_W_WARNING_DIRECTIVE, 1); |
1077 } | 1082 } |
1078 | 1083 |
1079 /* Report program identification. */ | 1084 /* Report program identification. */ |
1080 static void | 1085 static void |
1081 do_ident (cpp_reader *pfile) | 1086 do_ident (cpp_reader *pfile) |
1593 cpp_error (pfile, CPP_DL_WARNING, | 1598 cpp_error (pfile, CPP_DL_WARNING, |
1594 "current file is older than %s", fname); | 1599 "current file is older than %s", fname); |
1595 if (cpp_get_token (pfile)->type != CPP_EOF) | 1600 if (cpp_get_token (pfile)->type != CPP_EOF) |
1596 { | 1601 { |
1597 _cpp_backup_tokens (pfile, 1); | 1602 _cpp_backup_tokens (pfile, 1); |
1598 do_diagnostic (pfile, CPP_DL_WARNING, 0); | 1603 do_diagnostic (pfile, CPP_DL_WARNING, 0, 0); |
1599 } | 1604 } |
1600 } | 1605 } |
1601 | 1606 |
1602 free ((void *) fname); | 1607 free ((void *) fname); |
1603 } | 1608 } |