This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Implement C1X _Alignas, _Alignof, max_align_t, stdalign.h
On 7 November 2011 00:43, Jonathan Wakely wrote:
> On 7 November 2011 00:37, Joseph S. Myers wrote:
>> On Mon, 7 Nov 2011, Jonathan Wakely wrote:
>>
>>> On 6 November 2011 23:53, Joseph S. Myers wrote:
>>> >
>>> > As with stdnoreturn.h, the contents of stdalign.h are conditioned out
>>> > for C++; I'll leave it to C++ people to work out what's most useful
>>> > there if something nonempty is wanted (stdnoreturn.h is empty for C++,
>>> > stdbool.h defines _Bool and bool to bool, true to true etc.).
>>>
>>> Thanks Joseph, that will allow use to provide <cstdalign> in libstdc++.
>>>
>>> By my reading of the C++11 standard, the __alignas_is_defined macro
>>> should still be defined in C++, and alignof isn't mentioned, was that
>>> a late addition to C1X?
>>
>> The move from alignof as a keyword to _Alignof as a keyword with alignof
>> as a macro in stdalign.h was done at the London meeting (March 2011) in
>> response to comment US20. ?stdnoreturn.h was also added at that meeting.
>
> Thanks for the info. ?I think treating alignof identically to alignas
> for C++ makes sense then - the __alignof_is_defined macro is in the
> reserved namespace so it's OK for a conforming C++11 implementation to
> define it.
>
>> It looks like what GCC defines in stdbool.h for C++ goes beyond what C++11
>> says it should ("The header <cstdbool> and the header <stdbool.h> shall
>> not define macros named bool, true, or false.") ?stdint.h is another case
>> needing adjustment for C++11, though there what I've suggested is that GCC
>> should predefine __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS in C++11
>> mode as the best way to work with all implementations of that header that
>> follow what C99 footnotes suggest.
>
> Indeed - I was just noticing that the libstdc++ testsuite doesn't
> check that stdbool.h doesn't define those macros.
This patch adds <cstdalign> to libstdc++
* acinclude.m4: Check for <stdalign.h>
* configure: Regenerate.
* config.h.in: Likewise.
* include/Makefile.am: Add <cstdalign>.
* include/Makefile.in: Regenerate.
* include/c_global/cstdalign: New.
* testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: New.
* doc/xml/manual/backwards_compatibility.xml: Update.
* doc/xml/manual/status_cxx2011.xml: Update.
Tested x86_64-linux, committed to trunk.
Index: acinclude.m4
===================================================================
--- acinclude.m4 (revision 181054)
+++ acinclude.m4 (working copy)
@@ -1641,6 +1641,9 @@
# Check for the existence of the <stdbool.h> header.
AC_CHECK_HEADERS(stdbool.h)
+ # Check for the existence of the <stdalign.h> header.
+ AC_CHECK_HEADERS(stdalign.h)
+
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
Index: include/Makefile.am
===================================================================
--- include/Makefile.am (revision 181054)
+++ include/Makefile.am (working copy)
@@ -634,6 +634,7 @@
${c_base_srcdir}/cmath \
${c_base_srcdir}/csetjmp \
${c_base_srcdir}/csignal \
+ ${c_base_srcdir}/cstdalign \
${c_base_srcdir}/cstdarg \
${c_base_srcdir}/cstdbool \
${c_base_srcdir}/cstddef \
Index: include/c_global/cstdalign
===================================================================
--- include/c_global/cstdalign (revision 0)
+++ include/c_global/cstdalign (revision 0)
@@ -0,0 +1,44 @@
+// <cstdalign> -*- C++ -*-
+
+// Copyright (C) 2011 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file include/cstdalign
+ * This is a Standard C++ Library header.
+ */
+
+#pragma GCC system_header
+
+#ifndef _GLIBCXX_CSTDALIGN
+#define _GLIBCXX_CSTDALIGN 1
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+# include <bits/c++0x_warning.h>
+#else
+# include <bits/c++config.h>
+# if _GLIBCXX_HAVE_STDALIGN_H
+# include <stdalign.h>
+# endif
+#endif
+
+#endif
+
Index: testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc
===================================================================
--- testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc (revision 0)
+++ testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc (revision 0)
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++98" }
+
+// Copyright (C) 2011 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/>.
+
+#include <cstdalign>
+
+// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 }
+
Index: doc/xml/manual/backwards_compatibility.xml
===================================================================
--- doc/xml/manual/backwards_compatibility.xml (revision 181054)
+++ doc/xml/manual/backwards_compatibility.xml (working copy)
@@ -1135,7 +1135,7 @@
#include <cmath>
#include <csetjmp>
#include <csignal>
- // #include <cstdalign>
+ #include <cstdalign>
#include <cstdarg>
#include <cstdbool>
#include <cstddef>
Index: doc/xml/manual/status_cxx2011.xml
===================================================================
--- doc/xml/manual/status_cxx2011.xml (revision 181054)
+++ doc/xml/manual/status_cxx2011.xml (working copy)
@@ -253,11 +253,10 @@
<entry/>
</row>
<row>
- <?dbhtml bgcolor="#B0B0B0" ?>
<entry>18.10</entry>
<entry>Other runtime support</entry>
- <entry>Partial</entry>
- <entry>Missing <filename class="headerfile"><cstdalign></filename> </entry>
+ <entry>Y</entry>
+ <entry/>
</row>
<row>
<entry>
- References:
- Implement C1X _Alignas, _Alignof, max_align_t, stdalign.h
- Re: Implement C1X _Alignas, _Alignof, max_align_t, stdalign.h
- Re: Implement C1X _Alignas, _Alignof, max_align_t, stdalign.h
- Re: Implement C1X _Alignas, _Alignof, max_align_t, stdalign.h