This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] c-cppbuiltin.c bits for libstdc++/31518


Hi,

in order to resolve this library enhancement, I need a new predefined
macro, per the below patch. Is it ok?

Tested x86_64-linux.

Paolo.

///////////////
2007-07-02  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/31518
	* c-cppbuiltin.c (c_cpp_builtins): Define __GCC_MESSAGE_LENGTH__.
	* doc/cpp.texi ([Standard Predefined Macros]): Document.

2007-07-02  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/31518
	* gcc.dg/gcc.dg/gcc-message-length-1.c,
	 gcc.dg/gcc.dg/gcc-message-length-2.c: New testcases.
Index: doc/cpp.texi
===================================================================
--- doc/cpp.texi	(revision 126214)
+++ doc/cpp.texi	(working copy)
@@ -2194,6 +2194,9 @@
 These macros are defined when the target processor supports atomic compare
 and swap operations on operands 1, 2, 4, 8 or 16 bytes in length, respectively.
 
+@item __GCC_MESSAGE_LENGTH__
+This macro makes available the value of message-length.
+
 @end table
 
 @node System-specific Predefined Macros
Index: c-cppbuiltin.c
===================================================================
--- c-cppbuiltin.c	(revision 126214)
+++ c-cppbuiltin.c	(working copy)
@@ -34,6 +34,7 @@
 #include "toplev.h"
 #include "tm_p.h"		/* Target prototypes.  */
 #include "target.h"
+#include "diagnostic.h"
 
 #ifndef TARGET_OS_CPP_BUILTINS
 # define TARGET_OS_CPP_BUILTINS()
@@ -574,6 +575,10 @@
     cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
 #endif
 
+  /* Make available the value of message-length.  */
+  builtin_define_with_int_value ("__GCC_MESSAGE_LENGTH__",
+				 global_dc->printer->maximum_length);
+
   /* Make the choice of ObjC runtime visible to source code.  */
   if (c_dialect_objc () && flag_next_runtime)
     cpp_define (pfile, "__NEXT_RUNTIME__");
Index: testsuite/gcc.dg/gcc-message-length-1.c
===================================================================
--- testsuite/gcc.dg/gcc-message-length-1.c	(revision 0)
+++ testsuite/gcc.dg/gcc-message-length-1.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+
+extern void abort ();
+
+int main()
+{
+  if (__GCC_MESSAGE_LENGTH__ != 0)
+    abort ();
+  return 0;
+}
Index: testsuite/gcc.dg/gcc-message-length-2.c
===================================================================
--- testsuite/gcc.dg/gcc-message-length-2.c	(revision 0)
+++ testsuite/gcc.dg/gcc-message-length-2.c	(revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do run } */
+/* { dg-options "-fmessage-length=20" } */
+
+extern void abort ();
+
+int main()
+{
+  if (__GCC_MESSAGE_LENGTH__ != 20)
+    abort ();
+  return 0;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]