* Re: [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib
@ 2016-01-21 9:27 Dominique d'Humières
2016-01-21 13:36 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: Dominique d'Humières @ 2016-01-21 9:27 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc-patches
Jonathan,
> PR libstdc++/69386
> * include/c_global/ccomplex: Ensure C++ language linkage.
> * include/c_global/cmath: Likewise.
> * include/c_global/cstdlib: Likewise.
> * include/c_global/ctgmath: Likewise.
> * testsuite/17_intro/headers/c++2011/linkage.cc: New.
The test testsuite/17_intro/headers/c++2011/linkage.cc fails on darwin
/opt/gcc/work/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc:47:19: fatal error: uchar.h: No such file or directory
TIA
Dominique
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib
2016-01-21 9:27 [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib Dominique d'Humières
@ 2016-01-21 13:36 ` Jonathan Wakely
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2016-01-21 13:36 UTC (permalink / raw)
To: Dominique d'Humières; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 810 bytes --]
On 21/01/16 10:27 +0100, Dominique d'Humières wrote:
>Jonathan,
>> PR libstdc++/69386
>> * include/c_global/ccomplex: Ensure C++ language linkage.
>> * include/c_global/cmath: Likewise.
>> * include/c_global/cstdlib: Likewise.
>> * include/c_global/ctgmath: Likewise.
>> * testsuite/17_intro/headers/c++2011/linkage.cc: New.
>
>The test testsuite/17_intro/headers/c++2011/linkage.cc fails on darwin
>
>/opt/gcc/work/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc:47:19: fatal error: uchar.h: No such file or directory
I should have been checking which headers are actually supported,
fixed like this. This also adds extern "C++" to some more headers, so
that the order of including <math.h> and <complex.h> doesn't matter.
Tested powerpc64le-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 5470 bytes --]
commit 77a9e07d731a90aceb17f6fded227003b1c9c510
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jan 21 13:07:01 2016 +0000
libstdc++/69406 Fix test to check for supported headers
PR libstdc++/69406
* include/bits/cpp_type_traits.h: Ensure C++ language linkage.
* include/ext/type_traits.h: Likewise.
* testsuite/17_intro/headers/c++2011/linkage.cc: Check autoconf macros
for presence of C headers.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Adjust
dg-error line number.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Likewise.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Likewise.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Likewise.
diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index 3b188d4..fff1e99 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -64,6 +64,8 @@
// removed.
//
+extern "C++" {
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -408,5 +410,6 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3)
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
+} // extern "C++"
#endif //_CPP_TYPE_TRAITS_H
diff --git a/libstdc++-v3/include/ext/type_traits.h b/libstdc++-v3/include/ext/type_traits.h
index 0a4f425..dd27657 100644
--- a/libstdc++-v3/include/ext/type_traits.h
+++ b/libstdc++-v3/include/ext/type_traits.h
@@ -34,6 +34,8 @@
#include <bits/c++config.h>
#include <bits/cpp_type_traits.h>
+extern "C++" {
+
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -214,5 +216,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
+} // extern "C++"
#endif
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
index 33e7053..67c384b 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
@@ -20,15 +20,23 @@
// libstdc++/69386
+#include <bits/c++config.h>
+
extern "C"
{
#include <assert.h>
+#ifdef _GLIBCXX_HAVE_COMPLEX_H
#include <complex.h>
+#endif
#include <ctype.h>
#include <errno.h>
+#ifdef _GLIBCXX_HAVE_FENV_H
#include <fenv.h>
+#endif
#include <float.h>
+#ifdef _GLIBCXX_HAVE_INTTYPES_H
#include <inttypes.h>
+#endif
#include <iso646.h>
#include <limits.h>
#include <locale.h>
@@ -36,15 +44,27 @@ extern "C"
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
+#ifdef _GLIBCXX_HAVE_STDBOOL_H
#include <stdbool.h>
+#endif
#include <stddef.h>
+#ifdef _GLIBCXX_HAVE_STDINT_H
#include <stdint.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef _GLIBCXX_HAVE_TGMATH_H
#include <tgmath.h>
+#endif
#include <time.h>
+#if __has_include(<uchar.h>)
#include <uchar.h>
+#endif
+#ifdef _GLIBCXX_HAVE_WCHAR_H
#include <wchar.h>
+#endif
+#ifdef _GLIBCXX_HAVE_WCTYPE_H
#include <wctype.h>
+#endif
}
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
index f0c48d0..09d2c7c 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
@@ -35,4 +35,4 @@ int main()
}
// { dg-error "required from" "" { target *-*-* } 28 }
-// { dg-error "no type" "" { target *-*-* } 69 }
+// { dg-error "no type" "" { target *-*-* } 71 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
index cee08a3..567684e 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
@@ -36,5 +36,5 @@ int main()
}
// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
-// { dg-error "declaration of" "" { target *-*-* } 98 }
-// { dg-error "declaration of" "" { target *-*-* } 101 }
+// { dg-error "declaration of" "" { target *-*-* } 100 }
+// { dg-error "declaration of" "" { target *-*-* } 103 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
index 98ba8a6..c946a4f 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
@@ -35,4 +35,4 @@ int main()
}
// { dg-error "required from" "" { target *-*-* } 28 }
-// { dg-error "no type" "" { target *-*-* } 112 }
+// { dg-error "no type" "" { target *-*-* } 114 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
index 14e671d..a2cc4c7 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
@@ -36,5 +36,5 @@ int main()
}
// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
-// { dg-error "declaration of" "" { target *-*-* } 141 }
-// { dg-error "declaration of" "" { target *-*-* } 144 }
+// { dg-error "declaration of" "" { target *-*-* } 143 }
+// { dg-error "declaration of" "" { target *-*-* } 146 }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib
2016-01-20 12:34 ` [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib Jonathan Wakely
@ 2016-01-21 13:39 ` Jonathan Wakely
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2016-01-21 13:39 UTC (permalink / raw)
To: libstdc++, gcc-patches
On 20/01/16 12:34 +0000, Jonathan Wakely wrote:
>--- a/libstdc++-v3/include/c_global/ccomplex
>+++ b/libstdc++-v3/include/c_global/ccomplex
>@@ -35,6 +35,8 @@
> # include <bits/c++0x_warning.h>
> #endif
>
>+extern "C++" {
> #include <complex>
>+}
P.S. I would have preferred not to do this around <complex> and add
the linkage specification inside <complex>, but that would also mean
adding it inside <sstream>, which includes the entire iostream
hierarchy and <string> and bits/stl_algobase.h and lots of other
headers. Maybe I'll clean that up in stage 1 but it's a big patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib
2016-01-19 21:44 ` Jonathan Wakely
@ 2016-01-20 12:34 ` Jonathan Wakely
2016-01-21 13:39 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2016-01-20 12:34 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 873 bytes --]
On 19/01/16 21:43 +0000, Jonathan Wakely wrote:
>On 08/01/16 19:18 +0000, Jonathan Wakely wrote:
>>This resolves the longstanding issue that #include <math.h> uses the C
>>library header, which on most targets doesn't declare the additional
>>overloads required by C++11 26.8 [c.math], and similarly for
>><stdlib.h>.
>>
>>With this patch libstdc++ provides its own <math.h> and <stdlib.h>
>>wrappers, which are equivalent to <cmath> or <cstdlib> followed by
>>using-directives for all standard names. This means there are no more
>>inconsistencies in the contents of the <cxxx> and <xxx.h> headers.
The new wrappers might get included as:
extern "C" {
#include <stdlib.h>
}
which then includes <cstdlib> inside the extern "C" block, so we need
to ensure that the definitions in <cstdlib> get the right language
linkage.
Tested powerpc64le-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3775 bytes --]
commit d5175d037f6d1a5951d3a023dca71bed16ec0434
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jan 20 11:41:47 2016 +0000
Ensure C++ language linkage in cmath and cstdlib
PR libstdc++/69386
* include/c_global/ccomplex: Ensure C++ language linkage.
* include/c_global/cmath: Likewise.
* include/c_global/cstdlib: Likewise.
* include/c_global/ctgmath: Likewise.
* testsuite/17_intro/headers/c++2011/linkage.cc: New.
diff --git a/libstdc++-v3/include/c_global/ccomplex b/libstdc++-v3/include/c_global/ccomplex
index 8879e20..df2e413 100644
--- a/libstdc++-v3/include/c_global/ccomplex
+++ b/libstdc++-v3/include/c_global/ccomplex
@@ -35,6 +35,8 @@
# include <bits/c++0x_warning.h>
#endif
+extern "C++" {
#include <complex>
+}
#endif
diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath
index 45e40ab3..c4ee3f5 100644
--- a/libstdc++-v3/include/c_global/cmath
+++ b/libstdc++-v3/include/c_global/cmath
@@ -74,6 +74,8 @@
#undef tan
#undef tanh
+extern "C++"
+{
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -1790,4 +1792,6 @@ _GLIBCXX_END_NAMESPACE_VERSION
# include <bits/specfun.h>
#endif
+} // extern "C++"
+
#endif
diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib
index 44b6e5c..1ba5fb7 100644
--- a/libstdc++-v3/include/c_global/cstdlib
+++ b/libstdc++-v3/include/c_global/cstdlib
@@ -115,6 +115,8 @@ namespace std
#undef wcstombs
#undef wctomb
+extern "C++"
+{
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -272,6 +274,8 @@ namespace std
#endif // _GLIBCXX_USE_C99_STDLIB
+} // extern "C++"
+
#endif // !_GLIBCXX_HOSTED
#endif
diff --git a/libstdc++-v3/include/c_global/ctgmath b/libstdc++-v3/include/c_global/ctgmath
index 2fee958..4314516 100644
--- a/libstdc++-v3/include/c_global/ctgmath
+++ b/libstdc++-v3/include/c_global/ctgmath
@@ -35,7 +35,9 @@
# include <bits/c++0x_warning.h>
#else
# include <cmath>
+extern "C++" {
# include <complex>
+}
#endif
#endif
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
new file mode 100644
index 0000000..33e7053
--- /dev/null
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// libstdc++/69386
+
+extern "C"
+{
+#include <assert.h>
+#include <complex.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fenv.h>
+#include <float.h>
+#include <inttypes.h>
+#include <iso646.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <tgmath.h>
+#include <time.h>
+#include <uchar.h>
+#include <wchar.h>
+#include <wctype.h>
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-21 13:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-21 9:27 [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib Dominique d'Humières
2016-01-21 13:36 ` Jonathan Wakely
-- strict thread matches above, loose matches on Subject: below --
2016-01-08 19:19 [patch] libstdc++/14608 Add C++-conforming wrappers for stdlib.h and math.h Jonathan Wakely
2016-01-19 21:44 ` Jonathan Wakely
2016-01-20 12:34 ` [patch] libstdc++/69386 Ensure C++ language linkage in cmath and cstdlib Jonathan Wakely
2016-01-21 13:39 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).