http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39029

--- Comment #5 from Johan Boulé <bohan.gnu at retropaganda dot info> 2012-04-28 
14:15:17 UTC ---
I believe my original bug report does not stand as a valid bug. Bug #47857 has
been marked as duplicate but is not: it's a spurious warning. Also, Olaf showed
a test case that seems problematic but is probably worth a separate bug report.

Following is a minimal test case for what I originally thought was a bug, but
might actually not be considered a bug:

==============
includes/a.hpp
==============

#pragma once
class a { a(); };

=========
src/a.cpp
=========

#include <a.hpp>
a::a() {}
int main() {}

========
Makefile
========

bin/a.out: src/a.cpp pch/a.hpp.gch
    mkdir -p bin

    # fails:
    g++ -include pch/a.hpp src/a.cpp -o bin/a.out

    # fails:
    g++ -include pch/a.hpp src/a.cpp -o bin/a.out -I pch

    # succeeds:
    g++ -include pch/a.hpp src/a.cpp -o bin/a.out -I includes

pch/a.hpp.gch: includes/a.hpp
    mkdir -p pch
    g++ -I includes -xc++-header includes/a.hpp -o pch/a.hpp.gch

clean:
    rm -Rf pch bin

=======
make -i
=======

mkdir -p pch
g++ -I includes -xc++-header includes/a.hpp -o pch/a.hpp.gch
includes/a.hpp:1:9: warning: #pragma once in main file
mkdir -p bin
# fails:
g++ -include pch/a.hpp src/a.cpp -o bin/a.out
src/a.cpp:1:17: error: a.hpp: No such file or directory
make: [bin/a.out] Error 1 (ignored)
# fails:
g++ -include pch/a.hpp src/a.cpp -o bin/a.out -I pch
src/a.cpp:1:17: error: a.hpp: No such file or directory
make: [bin/a.out] Error 1 (ignored)
# succeeds:
g++ -include pch/a.hpp src/a.cpp -o bin/a.out -I includes

Reply via email to