summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-12-03 19:38:44 (GMT)
committerBrad King <brad.king@kitware.com>2015-12-03 19:51:38 (GMT)
commitd2ef49b321a3a8f33662b46183a778478e834411 (patch)
treecba3d4b9536a67a9ab0de57ad9d89f568bf00f5a /test
parente79f75a52e3da64686dcf56a1befcd17b26bbb55 (diff)
downloadCastXML-d2ef49b321a3a8f33662b46183a778478e834411.zip
CastXML-d2ef49b321a3a8f33662b46183a778478e834411.tar.gz
CastXML-d2ef49b321a3a8f33662b46183a778478e834411.tar.bz2
Add predefined macros for versions of CastXML and internal Clang
Some translation units may need to know the real tool that is performing the preprocessing even when --castxml-cc-<id> switches predefined macros to those from another compiler. Provide dedicated version macros for both CastXML and the internal Clang against which it is built.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt8
-rw-r--r--test/expect/cmd.cc-gnu-c-src-c-E.stdout.txt6
-rw-r--r--test/expect/cmd.cc-gnu-src-cxx-E.stdout.txt4
-rw-r--r--test/expect/cmd.cc-msvc-c-src-c-E.stdout.txt6
-rw-r--r--test/expect/cmd.cc-msvc-src-cxx-E.stdout.txt4
-rw-r--r--test/expect/cmd.predefined-macros.stdout.txt.in9
6 files changed, 35 insertions, 2 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b9beed9..8efb924 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -146,6 +146,14 @@ castxml_test_cmd(rsp-empty @${input}/empty.rsp)
castxml_test_cmd(rsp-missing @${input}/does-not-exist.rsp)
castxml_test_cmd(rsp-o-missing @${input}/o-missing.rsp)
+# Test predefined macros when not using --castxml-cc-<id>.
+math(EXPR __castxml__ "1000000*${CastXML_VERSION_MAJOR} + 1000*${CastXML_VERSION_MINOR} + ${CastXML_VERSION_PATCH}")
+configure_file(expect/cmd.predefined-macros.stdout.txt.in
+ expect/cmd.predefined-macros.stdout.txt @ONLY)
+set(castxml_test_cmd_expect ${CMAKE_CURRENT_BINARY_DIR}/expect/cmd.predefined-macros)
+castxml_test_cmd(predefined-macros --castxml-gccxml ${empty_cxx} -E -dM)
+unset(castxml_test_cmd_expect)
+
# Test --castxml-cc-gnu detection.
add_executable(cc-gnu cc-gnu.c)
set_property(SOURCE cc-gnu.c APPEND PROPERTY COMPILE_DEFINITIONS
diff --git a/test/expect/cmd.cc-gnu-c-src-c-E.stdout.txt b/test/expect/cmd.cc-gnu-c-src-c-E.stdout.txt
index 0a0cc7e..d251114 100644
--- a/test/expect/cmd.cc-gnu-c-src-c-E.stdout.txt
+++ b/test/expect/cmd.cc-gnu-c-src-c-E.stdout.txt
@@ -1,2 +1,6 @@
^#define __GNUC_MINOR__ 1
-#define __GNUC__ 1$
+#define __GNUC__ 1
+#define __castxml__ [0-9]+
+#define __castxml_clang_major__ [0-9]+
+#define __castxml_clang_minor__ [0-9]+
+#define __castxml_clang_patchlevel__ [0-9]+$
diff --git a/test/expect/cmd.cc-gnu-src-cxx-E.stdout.txt b/test/expect/cmd.cc-gnu-src-cxx-E.stdout.txt
index e2e4866..a20a94d 100644
--- a/test/expect/cmd.cc-gnu-src-cxx-E.stdout.txt
+++ b/test/expect/cmd.cc-gnu-src-cxx-E.stdout.txt
@@ -1,3 +1,7 @@
^#define __GNUC_MINOR__ 1
#define __GNUC__ 1
+#define __castxml__ [0-9]+
+#define __castxml_clang_major__ [0-9]+
+#define __castxml_clang_minor__ [0-9]+
+#define __castxml_clang_patchlevel__ [0-9]+
#define __cplusplus 199711L$
diff --git a/test/expect/cmd.cc-msvc-c-src-c-E.stdout.txt b/test/expect/cmd.cc-msvc-c-src-c-E.stdout.txt
index 04ac327..c2b5320 100644
--- a/test/expect/cmd.cc-msvc-c-src-c-E.stdout.txt
+++ b/test/expect/cmd.cc-msvc-c-src-c-E.stdout.txt
@@ -1,2 +1,6 @@
^#define _MSC_VER 1600
-#define _WIN32 1$
+#define _WIN32 1
+#define __castxml__ [0-9]+
+#define __castxml_clang_major__ [0-9]+
+#define __castxml_clang_minor__ [0-9]+
+#define __castxml_clang_patchlevel__ [0-9]+$
diff --git a/test/expect/cmd.cc-msvc-src-cxx-E.stdout.txt b/test/expect/cmd.cc-msvc-src-cxx-E.stdout.txt
index dc5da68..ebc0301 100644
--- a/test/expect/cmd.cc-msvc-src-cxx-E.stdout.txt
+++ b/test/expect/cmd.cc-msvc-src-cxx-E.stdout.txt
@@ -1,3 +1,7 @@
^#define _MSC_VER 1600
#define _WIN32 1
+#define __castxml__ [0-9]+
+#define __castxml_clang_major__ [0-9]+
+#define __castxml_clang_minor__ [0-9]+
+#define __castxml_clang_patchlevel__ [0-9]+
#define __cplusplus 199711L$
diff --git a/test/expect/cmd.predefined-macros.stdout.txt.in b/test/expect/cmd.predefined-macros.stdout.txt.in
new file mode 100644
index 0000000..a2c60d4
--- /dev/null
+++ b/test/expect/cmd.predefined-macros.stdout.txt.in
@@ -0,0 +1,9 @@
+#define __castxml__ @__castxml__@
+#define __castxml_clang_major__ [0-9]+
+#define __castxml_clang_minor__ [0-9]+
+#define __castxml_clang_patchlevel__ [0-9]+
+#define __clang__ 1
+#define __clang_major__ [0-9]+
+#define __clang_minor__ [0-9]+
+#define __clang_patchlevel__ [0-9]+
+#define __clang_version__