public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Add #error to some files that depend on a specific standard mode
@ 2021-08-12 14:04 Jonathan Wakely
  2021-08-12 14:22 ` François Dumont
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2021-08-12 14:04 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 284 bytes --]

Give more explicit errors if these files are not built with the correct
-std options.

libstdc++-v3/ChangeLog:

	* src/c++98/locale_init.cc: Require C++11.
	* src/c++98/localename.cc: Likewise.
	* src/c++98/misc-inst.cc: Require C++98.

Tested powerpc64le-linux. Committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1943 bytes --]

commit d3a7fbcb7c7a1016ceac2ceaf79b28c17ce9fcd7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 12 13:33:43 2021

    libstdc++: Add #error to some files that depend on a specific standard mode
    
    Give more explicit errors if these files are not built with the correct
    -std options.
    
    libstdc++-v3/ChangeLog:
    
            * src/c++98/locale_init.cc: Require C++11.
            * src/c++98/localename.cc: Likewise.
            * src/c++98/misc-inst.cc: Require C++98.

diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index 4bec50bf595..e96b1a336aa 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -20,6 +20,10 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
+#if __cplusplus != 201103L
+# error This file must be compiled as C++11
+#endif
+
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <clocale>
 #include <cstring>
diff --git a/libstdc++-v3/src/c++98/localename.cc b/libstdc++-v3/src/c++98/localename.cc
index 350dcf5ad0f..9c707b2327c 100644
--- a/libstdc++-v3/src/c++98/localename.cc
+++ b/libstdc++-v3/src/c++98/localename.cc
@@ -20,6 +20,10 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
+#if __cplusplus != 201103L
+# error This file must be compiled as C++11
+#endif
+
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <clocale>
 #include <cstring>
diff --git a/libstdc++-v3/src/c++98/misc-inst.cc b/libstdc++-v3/src/c++98/misc-inst.cc
index 09851903600..85a4287e113 100644
--- a/libstdc++-v3/src/c++98/misc-inst.cc
+++ b/libstdc++-v3/src/c++98/misc-inst.cc
@@ -26,6 +26,10 @@
 // ISO C++ 14882:
 //
 
+#if __cplusplus != 199711L
+# error This file must be compiled as C++98
+#endif
+
 #define _GLIBCXX_USE_CXX11_ABI 1
 #define _GLIBCXX_DISAMBIGUATE_REPLACE_INST 1
 #include <string>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [committed] libstdc++: Add #error to some files that depend on a specific standard mode
  2021-08-12 14:04 [committed] libstdc++: Add #error to some files that depend on a specific standard mode Jonathan Wakely
@ 2021-08-12 14:22 ` François Dumont
  2021-08-12 16:15   ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: François Dumont @ 2021-08-12 14:22 UTC (permalink / raw)
  To: libstdc++

On 12/08/21 4:04 pm, Jonathan Wakely via Libstdc++ wrote:
> Give more explicit errors if these files are not built with the correct
> -std options.
>
> libstdc++-v3/ChangeLog:
>
> 	* src/c++98/locale_init.cc: Require C++11.
> 	* src/c++98/localename.cc: Likewise.
> 	* src/c++98/misc-inst.cc: Require C++98.
>
> Tested powerpc64le-linux. Committed to trunk.
>
Shouldn't they be moved to src/c++11 ?

I thought that things in src/c++98 were built with -std=c++98 making 
your patch wrong but I see it is not the case.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [committed] libstdc++: Add #error to some files that depend on a specific standard mode
  2021-08-12 14:22 ` François Dumont
@ 2021-08-12 16:15   ` Jonathan Wakely
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2021-08-12 16:15 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++

On Thu, 12 Aug 2021 at 15:23, François Dumont wrote:
>
> On 12/08/21 4:04 pm, Jonathan Wakely via Libstdc++ wrote:
> > Give more explicit errors if these files are not built with the correct
> > -std options.
> >
> > libstdc++-v3/ChangeLog:
> >
> >       * src/c++98/locale_init.cc: Require C++11.
> >       * src/c++98/localename.cc: Likewise.
> >       * src/c++98/misc-inst.cc: Require C++98.
> >
> > Tested powerpc64le-linux. Committed to trunk.
> >
> Shouldn't they be moved to src/c++11 ?

Yes, see src/c++98/Makefile.am

# XXX TODO move locale_init.cc and localename.cc to src/c++11
locale_init.lo: locale_init.cc
    $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $<
locale_init.o: locale_init.cc
    $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $<
localename.lo: localename.cc
    $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $<
localename.o: localename.cc
    $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $<


I didn't do that years ago because it would have lost the file history
with subversion. With Git, it should be OK because Git will track the
history across the move. I'll add it to my TODO list.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-12 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 14:04 [committed] libstdc++: Add #error to some files that depend on a specific standard mode Jonathan Wakely
2021-08-12 14:22 ` François Dumont
2021-08-12 16:15   ` 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).