This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to deprecate casts as lvalues for C
On Mon, 20 Oct 2003, Zack Weinberg wrote:
> is glibc) and you must also write a fixincludes edit so that systems
> that shipped an old version of obstack.h in /usr/include are not
How does this fixincludes patch (which passes the fixincludes testsuite
and tst-obstack.c in glibc with the fixed obstack.h, but I don't think
that's a thorough testcase) seem?
2003-10-20 Joseph S. Myers <jsm@polyomino.org.uk>
* fixinc/inclhack.def (obstack_lvalue_cast): New fix.
* fixinc/fixincl.x: Regenerate.
* fixinc/tests/base/obstack.h: New test.
--- GCC/gcc/fixinc/inclhack.def.orig 2003-10-15 08:05:56.000000000 +0000
+++ GCC/gcc/fixinc/inclhack.def 2003-10-20 19:55:05.000000000 +0000
@@ -1978,6 +1978,19 @@
/*
+ * obstack.h used casts as lvalues.
+ */
+fix = {
+ hackname = obstack_lvalue_cast;
+ files = obstack.h;
+ select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
+ c_fix = format;
+ c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
+ test_text = "*((void **) (h)->next_free)++ = (aptr)";
+};
+
+
+/*
* sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
* defining regex.h related types. This causes libg++ build and usage
* failures. Fixing this correctly requires checking and modifying 3 files.
--- GCC/gcc/fixinc/tests/base/obstack.h 2002-08-26 16:21:36.000000000 +0000
+++ GCC/gcc/fixinc/tests/base/obstack.h 2003-10-20 20:00:25.000000000 +0000
@@ -0,0 +1,14 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/obstack.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( OBSTACK_LVALUE_CAST_CHECK )
+((*((void **) (h)->next_free) = (aptr)), ( (h)->next_free += sizeof (void *)))
+#endif /* OBSTACK_LVALUE_CAST_CHECK */
--
Joseph S. Myers
jsm@polyomino.org.uk