mirror of git://gcc.gnu.org/git/gcc.git
files.c (_cpp_find_file): If returning early...
* files.c (_cpp_find_file): If returning early, before storing something to *hash_slot and *hash_slot is NULL, call htab_clear_slot on it. Access *hash_slot using void * type rather than struct file_hash_entry * to avoid aliasing issues. From-SVN: r196356
This commit is contained in:
parent
4c37612689
commit
15fd8332c0
|
|
@ -1,5 +1,10 @@
|
||||||
2013-02-28 Jakub Jelinek <jakub@redhat.com>
|
2013-02-28 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* files.c (_cpp_find_file): If returning early, before storing
|
||||||
|
something to *hash_slot and *hash_slot is NULL, call htab_clear_slot
|
||||||
|
on it. Access *hash_slot using void * type rather than
|
||||||
|
struct file_hash_entry * to avoid aliasing issues.
|
||||||
|
|
||||||
* configure.ac: Don't define ENABLE_CHECKING whenever
|
* configure.ac: Don't define ENABLE_CHECKING whenever
|
||||||
--enable-checking is seen, instead use similar --enable-checking=yes
|
--enable-checking is seen, instead use similar --enable-checking=yes
|
||||||
vs. --enable-checking=release default as gcc/ subdir has and
|
vs. --enable-checking=release default as gcc/ subdir has and
|
||||||
|
|
|
||||||
|
|
@ -492,7 +492,8 @@ _cpp_file *
|
||||||
_cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
_cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
bool fake, int angle_brackets, bool implicit_preinclude)
|
bool fake, int angle_brackets, bool implicit_preinclude)
|
||||||
{
|
{
|
||||||
struct file_hash_entry *entry, **hash_slot;
|
struct file_hash_entry *entry;
|
||||||
|
void **hash_slot;
|
||||||
_cpp_file *file;
|
_cpp_file *file;
|
||||||
bool invalid_pch = false;
|
bool invalid_pch = false;
|
||||||
bool saw_bracket_include = false;
|
bool saw_bracket_include = false;
|
||||||
|
|
@ -503,13 +504,12 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
if (start_dir == NULL)
|
if (start_dir == NULL)
|
||||||
cpp_error (pfile, CPP_DL_ICE, "NULL directory in find_file");
|
cpp_error (pfile, CPP_DL_ICE, "NULL directory in find_file");
|
||||||
|
|
||||||
hash_slot = (struct file_hash_entry **)
|
hash_slot
|
||||||
htab_find_slot_with_hash (pfile->file_hash, fname,
|
= htab_find_slot_with_hash (pfile->file_hash, fname,
|
||||||
htab_hash_string (fname),
|
htab_hash_string (fname), INSERT);
|
||||||
INSERT);
|
|
||||||
|
|
||||||
/* First check the cache before we resort to memory allocation. */
|
/* First check the cache before we resort to memory allocation. */
|
||||||
entry = search_cache (*hash_slot, start_dir);
|
entry = search_cache ((struct file_hash_entry *) *hash_slot, start_dir);
|
||||||
if (entry)
|
if (entry)
|
||||||
return entry->u.file;
|
return entry->u.file;
|
||||||
|
|
||||||
|
|
@ -533,6 +533,17 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
the list of all files so that #import works. */
|
the list of all files so that #import works. */
|
||||||
file->next_file = pfile->all_files;
|
file->next_file = pfile->all_files;
|
||||||
pfile->all_files = file;
|
pfile->all_files = file;
|
||||||
|
if (*hash_slot == NULL)
|
||||||
|
{
|
||||||
|
/* If *hash_slot is NULL, the above htab_find_slot_with_hash
|
||||||
|
call just created the slot, but we aren't going to store
|
||||||
|
there anything, so need to remove the newly created entry.
|
||||||
|
htab_clear_slot requires that it is non-NULL, so store
|
||||||
|
there some non-NULL pointer, htab_clear_slot will
|
||||||
|
overwrite it immediately. */
|
||||||
|
*hash_slot = file;
|
||||||
|
htab_clear_slot (pfile->file_hash, hash_slot);
|
||||||
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,6 +559,12 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
{
|
{
|
||||||
free ((char *) file->name);
|
free ((char *) file->name);
|
||||||
free (file);
|
free (file);
|
||||||
|
if (*hash_slot == NULL)
|
||||||
|
{
|
||||||
|
/* See comment on the above htab_clear_slot call. */
|
||||||
|
*hash_slot = file;
|
||||||
|
htab_clear_slot (pfile->file_hash, hash_slot);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -565,7 +582,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
entry = search_cache (*hash_slot, file->dir);
|
entry = search_cache ((struct file_hash_entry *) *hash_slot, file->dir);
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
found_in_cache = file->dir;
|
found_in_cache = file->dir;
|
||||||
|
|
@ -589,11 +606,11 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
|
|
||||||
/* Store this new result in the hash table. */
|
/* Store this new result in the hash table. */
|
||||||
entry = new_file_hash_entry (pfile);
|
entry = new_file_hash_entry (pfile);
|
||||||
entry->next = *hash_slot;
|
entry->next = (struct file_hash_entry *) *hash_slot;
|
||||||
entry->start_dir = start_dir;
|
entry->start_dir = start_dir;
|
||||||
entry->location = pfile->line_table->highest_location;
|
entry->location = pfile->line_table->highest_location;
|
||||||
entry->u.file = file;
|
entry->u.file = file;
|
||||||
*hash_slot = entry;
|
*hash_slot = (void *) entry;
|
||||||
|
|
||||||
/* If we passed the quote or bracket chain heads, cache them also.
|
/* If we passed the quote or bracket chain heads, cache them also.
|
||||||
This speeds up processing if there are lots of -I options. */
|
This speeds up processing if there are lots of -I options. */
|
||||||
|
|
@ -602,22 +619,22 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
|
||||||
&& found_in_cache != pfile->bracket_include)
|
&& found_in_cache != pfile->bracket_include)
|
||||||
{
|
{
|
||||||
entry = new_file_hash_entry (pfile);
|
entry = new_file_hash_entry (pfile);
|
||||||
entry->next = *hash_slot;
|
entry->next = (struct file_hash_entry *) *hash_slot;
|
||||||
entry->start_dir = pfile->bracket_include;
|
entry->start_dir = pfile->bracket_include;
|
||||||
entry->location = pfile->line_table->highest_location;
|
entry->location = pfile->line_table->highest_location;
|
||||||
entry->u.file = file;
|
entry->u.file = file;
|
||||||
*hash_slot = entry;
|
*hash_slot = (void *) entry;
|
||||||
}
|
}
|
||||||
if (saw_quote_include
|
if (saw_quote_include
|
||||||
&& pfile->quote_include != start_dir
|
&& pfile->quote_include != start_dir
|
||||||
&& found_in_cache != pfile->quote_include)
|
&& found_in_cache != pfile->quote_include)
|
||||||
{
|
{
|
||||||
entry = new_file_hash_entry (pfile);
|
entry = new_file_hash_entry (pfile);
|
||||||
entry->next = *hash_slot;
|
entry->next = (struct file_hash_entry *) *hash_slot;
|
||||||
entry->start_dir = pfile->quote_include;
|
entry->start_dir = pfile->quote_include;
|
||||||
entry->location = pfile->line_table->highest_location;
|
entry->location = pfile->line_table->highest_location;
|
||||||
entry->u.file = file;
|
entry->u.file = file;
|
||||||
*hash_slot = entry;
|
*hash_slot = (void *) entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue