Created attachment 165715 [details]
tar file containing sources showing the bug via "make"
Seems I have found a clang++ bug if called with -x c++.
system is FreeBSD 10.2-STABLE (TESTBOX) #0 r290820M
compiler is clang 3.4.1, in particular
$ clang++ -v
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Thread model: posix
Selected GCC installation:
compiler clang 3.6 from ports also affected
compiler clang 3.7 to be checked
tar xf clang_x_cpp_bug.tar
It seems to me that it isn't a bug. For me clang does what it should do.
Taking from clang man page:
Treat subsequent input files as having type language.
So for me it means that it should treat every file after -x option as file of this type.
As you're passing object file (test-function.o) after -x c++ option, it tries to interpret this file like c++ source file, and it fails.
I think you should compile it this way:
clang++ -o test-x_cpp test-function.o -x c++ test-x_cpp.c
Unfortunately, there isn't an option to pass object file after using -x option, so object files should be passed before using any -x option.
(In reply to Hubert Drogosz from comment #3)
Yes, makes sense. Thank you.
The error message is misleading at first, though, but (with hindsight) makes sense, too.
:: test-function.o:1:1: error: expected unqualified-id
:: test-function.o:1:9: warning: null character ignored [-Wnull-character]
Far more obvious would be an error message like this:
:: test-function.o: not a C++ source file, aborting