https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90034

--- Comment #6 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Andreas Schwab from comment #4)
> You get the resolve part for free by opening it.

Thanks.

I'm wondering what the best cross-platform test ought to be.

Maybe something like this to input.c's add_file_to_cache_tab:

  int fd = fileno (fp);
  if (fstat (fd, &buf) == -1)
    {
      /* reject due to error */
      fclose (fp);
      return NULL;
    }
  if (!S_ISREG(buf.st_mode))
    {
      /* reject: not a regular file */
      fclose (fp);
      return NULL;
    }
  /* carry on */

input.c is re-reading the source file after the frontend has already opened it,
so this isn't going to work for pipes, and, as you mention, the resolution of
symlinks already happened when fp was opened.

Reply via email to