Mercurial > hg > CbC > CbC_gcc
comparison libcpp/files.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
286 | 286 |
287 /* No PCH on <stdin> or if not requested. */ | 287 /* No PCH on <stdin> or if not requested. */ |
288 if (file->name[0] == '\0' || !pfile->cb.valid_pch) | 288 if (file->name[0] == '\0' || !pfile->cb.valid_pch) |
289 return false; | 289 return false; |
290 | 290 |
291 /* If the file is not included as first include from either the toplevel | |
292 file or the command-line it is not a valid use of PCH. */ | |
293 if (pfile->all_files | |
294 && pfile->all_files->next_file) | |
295 return false; | |
296 | |
291 flen = strlen (path); | 297 flen = strlen (path); |
292 len = flen + sizeof (extension); | 298 len = flen + sizeof (extension); |
293 pchname = XNEWVEC (char, len); | 299 pchname = XNEWVEC (char, len); |
294 memcpy (pchname, path, flen); | 300 memcpy (pchname, path, flen); |
295 memcpy (pchname + flen, extension, sizeof (extension)); | 301 memcpy (pchname + flen, extension, sizeof (extension)); |
379 } | 385 } |
380 | 386 |
381 /* We copy the path name onto an obstack partly so that we don't | 387 /* We copy the path name onto an obstack partly so that we don't |
382 leak the memory, but mostly so that we don't fragment the | 388 leak the memory, but mostly so that we don't fragment the |
383 heap. */ | 389 heap. */ |
384 copy = obstack_copy0 (&pfile->nonexistent_file_ob, path, | 390 copy = (char *) obstack_copy0 (&pfile->nonexistent_file_ob, path, |
385 strlen (path)); | 391 strlen (path)); |
386 free (path); | 392 free (path); |
387 pp = htab_find_slot_with_hash (pfile->nonexistent_file_hash, | 393 pp = htab_find_slot_with_hash (pfile->nonexistent_file_hash, |
388 copy, hv, INSERT); | 394 copy, hv, INSERT); |
389 *pp = copy; | 395 *pp = copy; |
390 | 396 |
486 file->next_file = pfile->all_files; | 492 file->next_file = pfile->all_files; |
487 pfile->all_files = file; | 493 pfile->all_files = file; |
488 return file; | 494 return file; |
489 } | 495 } |
490 | 496 |
491 open_file_failed (pfile, file, angle_brackets); | |
492 if (invalid_pch) | 497 if (invalid_pch) |
493 { | 498 { |
494 cpp_error (pfile, CPP_DL_ERROR, | 499 cpp_error (pfile, CPP_DL_ERROR, |
495 "one or more PCH files were found, but they were invalid"); | 500 "one or more PCH files were found, but they were invalid"); |
496 if (!cpp_get_options (pfile)->warn_invalid_pch) | 501 if (!cpp_get_options (pfile)->warn_invalid_pch) |
497 cpp_error (pfile, CPP_DL_ERROR, | 502 cpp_error (pfile, CPP_DL_ERROR, |
498 "use -Winvalid-pch for more information"); | 503 "use -Winvalid-pch for more information"); |
499 } | 504 } |
505 open_file_failed (pfile, file, angle_brackets); | |
500 break; | 506 break; |
501 } | 507 } |
502 | 508 |
503 /* Only check the cache for the starting location (done above) | 509 /* Only check the cache for the starting location (done above) |
504 and the quote and bracket chain heads because there are no | 510 and the quote and bracket chain heads because there are no |
910 if (!dir) | 916 if (!dir) |
911 return false; | 917 return false; |
912 | 918 |
913 file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); | 919 file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); |
914 | 920 |
915 /* Compensate for the increment in linemap_add. In the case of a | 921 /* Compensate for the increment in linemap_add that occurs in |
916 normal #include, we're currently at the start of the line | 922 _cpp_stack_file. In the case of a normal #include, we're |
917 *following* the #include. A separate source_location for this | 923 currently at the start of the line *following* the #include. A |
918 location makes no sense (until we do the LC_LEAVE), and | 924 separate source_location for this location makes no sense (until |
919 complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we | 925 we do the LC_LEAVE), and complicates LAST_SOURCE_LINE_LOCATION. |
920 found a PCH file (in which case linemap_add is not called) or we | 926 This does not apply if we found a PCH file (in which case |
921 were included from the command-line. */ | 927 linemap_add is not called) or we were included from the |
928 command-line. */ | |
922 if (file->pchname == NULL && file->err_no == 0 && type != IT_CMDLINE) | 929 if (file->pchname == NULL && file->err_no == 0 && type != IT_CMDLINE) |
923 pfile->line_table->highest_location--; | 930 pfile->line_table->highest_location--; |
924 | 931 |
925 return _cpp_stack_file (pfile, file, type == IT_IMPORT); | 932 return _cpp_stack_file (pfile, file, type == IT_IMPORT); |
926 } | 933 } |
932 int sysp = pfile->line_table->highest_line > 1 && pfile->buffer ? pfile->buffer->sysp : 0; | 939 int sysp = pfile->line_table->highest_line > 1 && pfile->buffer ? pfile->buffer->sysp : 0; |
933 bool print_dep = CPP_OPTION (pfile, deps.style) > (angle_brackets || !!sysp); | 940 bool print_dep = CPP_OPTION (pfile, deps.style) > (angle_brackets || !!sysp); |
934 | 941 |
935 errno = file->err_no; | 942 errno = file->err_no; |
936 if (print_dep && CPP_OPTION (pfile, deps.missing_files) && errno == ENOENT) | 943 if (print_dep && CPP_OPTION (pfile, deps.missing_files) && errno == ENOENT) |
937 deps_add_dep (pfile->deps, file->name); | 944 { |
945 deps_add_dep (pfile->deps, file->name); | |
946 /* If the preprocessor output (other than dependency information) is | |
947 being used, we must also flag an error. */ | |
948 if (CPP_OPTION (pfile, deps.need_preprocessor_output)) | |
949 cpp_errno (pfile, CPP_DL_FATAL, file->path); | |
950 } | |
938 else | 951 else |
939 { | 952 { |
940 /* If we are outputting dependencies but not for this file then | 953 /* If we are not outputting dependencies, or if we are and dependencies |
941 don't error because we can still produce correct output. */ | 954 were requested for this file, or if preprocessor output is needed |
942 if (CPP_OPTION (pfile, deps.style) && ! print_dep) | 955 in addition to dependency information, this is an error. |
956 | |
957 Otherwise (outputting dependencies but not for this file, and not | |
958 using the preprocessor output), we can still produce correct output | |
959 so it's only a warning. */ | |
960 if (CPP_OPTION (pfile, deps.style) == DEPS_NONE | |
961 || print_dep | |
962 || CPP_OPTION (pfile, deps.need_preprocessor_output)) | |
963 cpp_errno (pfile, CPP_DL_FATAL, file->path); | |
964 else | |
943 cpp_errno (pfile, CPP_DL_WARNING, file->path); | 965 cpp_errno (pfile, CPP_DL_WARNING, file->path); |
944 else | |
945 cpp_errno (pfile, CPP_DL_ERROR, file->path); | |
946 } | 966 } |
947 } | 967 } |
948 | 968 |
949 /* Search in the chain beginning at HEAD for a file whose search path | 969 /* Search in the chain beginning at HEAD for a file whose search path |
950 started at START_DIR != NULL. */ | 970 started at START_DIR != NULL. */ |
1141 /* Compare entries in the nonexistent file hash table. These are just | 1161 /* Compare entries in the nonexistent file hash table. These are just |
1142 strings. */ | 1162 strings. */ |
1143 static int | 1163 static int |
1144 nonexistent_file_hash_eq (const void *p, const void *q) | 1164 nonexistent_file_hash_eq (const void *p, const void *q) |
1145 { | 1165 { |
1146 return strcmp (p, q) == 0; | 1166 return strcmp ((const char *) p, (const char *) q) == 0; |
1147 } | 1167 } |
1148 | 1168 |
1149 /* Initialize everything in this source file. */ | 1169 /* Initialize everything in this source file. */ |
1150 void | 1170 void |
1151 _cpp_init_files (cpp_reader *pfile) | 1171 _cpp_init_files (cpp_reader *pfile) |