[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/8] tests: check that C and C++ objects can be linked together.
From: |
Akim Demaille |
Subject: |
[PATCH 5/8] tests: check that C and C++ objects can be linked together. |
Date: |
Tue, 6 Nov 2012 17:47:14 +0100 |
* tests/local.at (AT_SKIP_IF_CANNOT_LINK_C_AND_CXX): New.
* tests/headers.at (Several parsers): Use it.
---
tests/headers.at | 9 ++++++---
tests/local.at | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/tests/headers.at b/tests/headers.at
index 8e70a7e..a60e315 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -240,9 +240,6 @@ AT_TEST([x7], [%define api.push-pull both])
AT_TEST([x8], [%define api.pure %define api.push-pull both])
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
-AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
-AT_CHECK([./parser], [0], [[expout]])
-
# Check that the headers are self-contained, and protected against
# multiple inclusions. While at it, check they are sane for C++.
for h in *.h *.hh
@@ -256,6 +253,12 @@ EOF
AT_COMPILE_CXX([$h.o])
done
+# Do this late, so that other checks have been performed.
+AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
+
+AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
+AT_CHECK([./parser], [0], [[expout]])
+
m4_popdef([AT_TEST])
AT_CLEANUP
diff --git a/tests/local.at b/tests/local.at
index 73680c7..8882521 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -683,6 +683,44 @@ m4_define([AT_FULL_COMPILE],
])
+
+# AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
+# --------------------------------
+# Check that we can link together C and C++ objects.
+m4_define([AT_SKIP_IF_CANNOT_LINK_C_AND_CXX],
+[AT_DATA([c-and-cxx.h],
+[[#ifdef __cplusplus
+extern "C"
+{
+#endif
+ int fortytwo (void);
+#ifdef __cplusplus
+}
+#endif
+]])
+AT_DATA([c-only.c],
+[[#include "c-and-cxx.h"
+int
+main (void)
+{
+ return fortytwo () == 42 ? 0 : 1;
+}
+]])
+AT_DATA([cxx-only.cc],
+[[#include "c-and-cxx.h"
+int fortytwo ()
+{
+ return 42;
+}
+]])
+AT_COMPILE([c-only.o], [c-only.c])
+AT_COMPILE_CXX([cxx-only.o], [cxx-only.cc])
+AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS c-only.o cxx-only.o -o c-and-cxx ||
+ exit 77], [ignore], [ignore])
+AT_CHECK([./c-and-cxx])
+])
+
+
## ---------------------------- ##
## Running a generated parser. ##
## ---------------------------- ##
--
1.8.0
- [PATCH 0/8] {branch-2.6} more fixes for -Wuninitialized warnings, Akim Demaille, 2012/11/06
- [PATCH 3/8] glr.cc, yacc.c: initialize yylloc properly, Akim Demaille, 2012/11/06
- [PATCH 4/8] yacc.c: also disable -Wuninitialized., Akim Demaille, 2012/11/06
- [PATCH 6/8] lalr1.cc: always initialize yylval., Akim Demaille, 2012/11/06
- [PATCH 2/8] yacc.c, glr.c: a better YY_LOCATION_PRINT, Akim Demaille, 2012/11/06
- [PATCH 8/8] tests: calc: modernize the use of locations, Akim Demaille, 2012/11/06
- [PATCH 1/8] yacc.c: simplify initialization, Akim Demaille, 2012/11/06
- [PATCH 5/8] tests: check that C and C++ objects can be linked together.,
Akim Demaille <=
- [PATCH 7/8] tests: remove useless location initializations, Akim Demaille, 2012/11/06