diff options
-rw-r--r-- | src/Detect.cxx | 18 | ||||
-rw-r--r-- | test/cc-gnu.c | 4 | ||||
-rw-r--r-- | test/cc-msvc.c | 4 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-c-E.stdout.txt | 3 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-cxx-E.stdout.txt | 3 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-c-E.stdout.txt | 3 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-cxx-E.stdout.txt | 3 |
7 files changed, 34 insertions, 4 deletions
diff --git a/src/Detect.cxx b/src/Detect.cxx index 4db82f9..3714847 100644 --- a/src/Detect.cxx +++ b/src/Detect.cxx @@ -53,6 +53,22 @@ static bool failedCC(const char* id, } //---------------------------------------------------------------------------- +static void fixPredefines(Options& opts) +{ + // Remove any detected conflicting definition of a Clang builtin macro. + std::string::size_type beg = 0; + while ((beg = opts.Predefines.find("#define __has", beg), + beg != std::string::npos)) { + std::string::size_type end = opts.Predefines.find('\n', beg); + if (end != std::string::npos) { + opts.Predefines.erase(beg, end+1 - beg); + } else { + opts.Predefines.erase(beg); + } + } +} + +//---------------------------------------------------------------------------- static void setTriple(Options& opts) { std::string const& pd = opts.Predefines; @@ -133,6 +149,7 @@ static bool detectCC_GNU(const char* const* argBeg, } } } + fixPredefines(opts); setTriple(opts); return true; } else { @@ -173,6 +190,7 @@ static bool detectCC_MSVC(const char* const* argBeg, } } } + fixPredefines(opts); setTriple(opts); return true; } else { diff --git a/test/cc-gnu.c b/test/cc-gnu.c index 2bf616d..10332a5 100644 --- a/test/cc-gnu.c +++ b/test/cc-gnu.c @@ -4,6 +4,10 @@ int main(void) { fprintf(stdout, "#define __cc_gnu__ 1\n" + "#define __has_include(x) x\n" + "#define __has_include_next(x) x\n" + "#define __cc_gnu_minor__ 1\n" + "#define __has_last(x) x" ); fprintf(stderr, "#include <...> search starts here:\n" diff --git a/test/cc-msvc.c b/test/cc-msvc.c index 8ddbac1..8f439b4 100644 --- a/test/cc-msvc.c +++ b/test/cc-msvc.c @@ -5,6 +5,10 @@ int main(void) fprintf(stdout, "\n" "#define __cc_msvc__ 1\n" + "#define __has_include(x) x\n" + "#define __has_include_next(x) x\n" + "#define __cc_msvc_minor__ 1\n" + "#define __has_last(x) x" ); return 0; } diff --git a/test/expect/cmd.cc-gnu-c-E.stdout.txt b/test/expect/cmd.cc-gnu-c-E.stdout.txt index 0a4a576..83be182 100644 --- a/test/expect/cmd.cc-gnu-c-E.stdout.txt +++ b/test/expect/cmd.cc-gnu-c-E.stdout.txt @@ -1 +1,2 @@ -^#define __cc_gnu__ 1$ +^#define __cc_gnu__ 1 +#define __cc_gnu_minor__ 1$ diff --git a/test/expect/cmd.cc-gnu-cxx-E.stdout.txt b/test/expect/cmd.cc-gnu-cxx-E.stdout.txt index 0a4a576..83be182 100644 --- a/test/expect/cmd.cc-gnu-cxx-E.stdout.txt +++ b/test/expect/cmd.cc-gnu-cxx-E.stdout.txt @@ -1 +1,2 @@ -^#define __cc_gnu__ 1$ +^#define __cc_gnu__ 1 +#define __cc_gnu_minor__ 1$ diff --git a/test/expect/cmd.cc-msvc-c-E.stdout.txt b/test/expect/cmd.cc-msvc-c-E.stdout.txt index 21445c4..a4cc19c 100644 --- a/test/expect/cmd.cc-msvc-c-E.stdout.txt +++ b/test/expect/cmd.cc-msvc-c-E.stdout.txt @@ -1 +1,2 @@ -^#define __cc_msvc__ 1$ +^#define __cc_msvc__ 1 +#define __cc_msvc_minor__ 1$ diff --git a/test/expect/cmd.cc-msvc-cxx-E.stdout.txt b/test/expect/cmd.cc-msvc-cxx-E.stdout.txt index 21445c4..a4cc19c 100644 --- a/test/expect/cmd.cc-msvc-cxx-E.stdout.txt +++ b/test/expect/cmd.cc-msvc-cxx-E.stdout.txt @@ -1 +1,2 @@ -^#define __cc_msvc__ 1$ +^#define __cc_msvc__ 1 +#define __cc_msvc_minor__ 1$ |