From fe1bb977eef136daecec0d5717fbd7379f139e8a Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Feb 2015 16:23:45 -0500 Subject: Detect: Provide __float128 when simulating GNU compilers GNU compilers provide a __float128 builtin type on Intel architectures. When simulating such GNU compiler preprocessing, define a __float128 type with the expected size and alignment in case the translation unit references it. --- src/Detect.cxx | 16 ++++++++++++++++ test/CMakeLists.txt | 2 ++ test/expect/gccxml.any.GNU-float128.xml.txt | 25 +++++++++++++++++++++++++ test/expect/gccxml.c89.GNU-float128.xml.txt | 13 +++++++++++++ test/input/GNU-float128.c | 1 + test/input/GNU-float128.cxx | 1 + 6 files changed, 58 insertions(+) create mode 100644 test/expect/gccxml.any.GNU-float128.xml.txt create mode 100644 test/expect/gccxml.c89.GNU-float128.xml.txt create mode 100644 test/input/GNU-float128.c create mode 100644 test/input/GNU-float128.cxx diff --git a/src/Detect.cxx b/src/Detect.cxx index 70b6a74..d9d2607 100644 --- a/src/Detect.cxx +++ b/src/Detect.cxx @@ -67,6 +67,22 @@ static void fixPredefines(Options& opts) pd.erase(beg); } } + + // Provide __float128 if simulating the actual GNU compiler. + if (pd.find("#define __GNUC__ ") != pd.npos && + pd.find("#define __clang__ ") == pd.npos && + pd.find("#define __INTEL_COMPILER ") == pd.npos && + pd.find("#define __CUDACC__ ") == pd.npos && + pd.find("#define __PGI ") == pd.npos && + (pd.find("#define __i386__ ") != pd.npos || + pd.find("#define __x86_64__ ") != pd.npos || + pd.find("#define __ia64__ ") != pd.npos)) { + pd += "\n" + "typedef struct { " + " char x[16] __attribute__((aligned(16))); " + "} __float128;\n" + ; + } } //---------------------------------------------------------------------------- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1430dca..9febe91 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -259,10 +259,12 @@ endforeach() if(TEST_GNU_C) set(castxml_test_gccxml_extra_arguments --castxml-cc-gnu ${TEST_GNU_C}) + castxml_test_gccxml_c(GNU-float128) unset(castxml_test_gccxml_extra_arguments) endif() if(TEST_GNU_CXX) set(castxml_test_gccxml_extra_arguments --castxml-cc-gnu ${TEST_GNU_CXX}) + castxml_test_gccxml(GNU-float128) unset(castxml_test_gccxml_extra_arguments) endif() diff --git a/test/expect/gccxml.any.GNU-float128.xml.txt b/test/expect/gccxml.any.GNU-float128.xml.txt new file mode 100644 index 0000000..61b11fa --- /dev/null +++ b/test/expect/gccxml.any.GNU-float128.xml.txt @@ -0,0 +1,25 @@ +^<\?xml version="1.0"\?> +]*> + + + + + + + + + + + + + + + + + + + + + + +$ diff --git a/test/expect/gccxml.c89.GNU-float128.xml.txt b/test/expect/gccxml.c89.GNU-float128.xml.txt new file mode 100644 index 0000000..8195cff --- /dev/null +++ b/test/expect/gccxml.c89.GNU-float128.xml.txt @@ -0,0 +1,13 @@ +^<\?xml version="1.0"\?> +]*> + + + + + + + + + + +$ diff --git a/test/input/GNU-float128.c b/test/input/GNU-float128.c new file mode 100644 index 0000000..fbb07e1 --- /dev/null +++ b/test/input/GNU-float128.c @@ -0,0 +1 @@ +__float128 start(__float128); diff --git a/test/input/GNU-float128.cxx b/test/input/GNU-float128.cxx new file mode 100644 index 0000000..fbb07e1 --- /dev/null +++ b/test/input/GNU-float128.cxx @@ -0,0 +1 @@ +__float128 start(__float128); -- cgit v0.12