aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2003-10-22 23:28:39 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2003-10-22 23:28:39 +0100
commitdc70e81d6e03635053815aba4360da3356ae5b24 (patch)
tree28a0768008d74d4ffb87685f8213007c87501bc9 /gcc
parent3c21d6e0f7c7b6d02686e24d0967ffffe85b61ad (diff)
downloadgcc-dc70e81d6e03635053815aba4360da3356ae5b24.zip
gcc-dc70e81d6e03635053815aba4360da3356ae5b24.tar.gz
gcc-dc70e81d6e03635053815aba4360da3356ae5b24.tar.bz2
obstack.h: Merge the following change from gnulib...
include: * obstack.h: Merge the following change from gnulib: 2003-10-21 Paul Eggert <eggert@twinsun.com> * obstack.h (obstack_1grow_fast): Properly parenthesize arg. (obstack_ptr_grow_fast, obstack_int_grow_fast): Don't use lvalue casts, as GCC plans to remove support for them in GCC 3.5. Reported by Joseph S. Myers. This bug was also present in the non-GCC version, indicating that this code had always been buggy and had never been widely used. (obstack_1grow, obstack_ptr_grow, obstack_int_grow, obstack_blank): Use the fast variant of each macro, rather than copying the definiens of the fast variant; that way, we'll be more likely to catch future bugs in the fast variants. gcc: * c-typeck.c (pedantic_lvalue_warning): Unconditionally warn of deprecation of casts as lvalues. * fixinc/inclhack.def (obstack_lvalue_cast): New fix. * fixinc/fixincl.x: Regenerate. * fixinc/tests/base/obstack.h: New test. gcc/testsuite: * gcc.dg/cast-lvalue-1.c: New test. From-SVN: r72826
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-typeck.c23
-rw-r--r--gcc/fixinc/fixincl.x51
-rw-r--r--gcc/fixinc/inclhack.def25
-rw-r--r--gcc/fixinc/tests/base/obstack.h14
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/cast-lvalue-1.c12
7 files changed, 121 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a3df896..5cf4a4b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2003-10-22 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ * c-typeck.c (pedantic_lvalue_warning): Unconditionally warn of
+ deprecation of casts as lvalues.
+ * fixinc/inclhack.def (obstack_lvalue_cast): New fix.
+ * fixinc/fixincl.x: Regenerate.
+ * fixinc/tests/base/obstack.h: New test.
+
2003-10-22 Andreas Schwab <schwab@suse.de>
PR target/12676
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index eaad4fe..598e249 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2585,19 +2585,20 @@ unary_complex_lvalue (enum tree_code code, tree arg, int flag)
static void
pedantic_lvalue_warning (enum tree_code code)
{
- if (pedantic)
- switch (code)
- {
- case COND_EXPR:
+ switch (code)
+ {
+ case COND_EXPR:
+ if (pedantic)
pedwarn ("ISO C forbids use of conditional expressions as lvalues");
- break;
- case COMPOUND_EXPR:
+ break;
+ case COMPOUND_EXPR:
+ if (pedantic)
pedwarn ("ISO C forbids use of compound expressions as lvalues");
- break;
- default:
- pedwarn ("ISO C forbids use of cast expressions as lvalues");
- break;
- }
+ break;
+ default:
+ pedwarn ("use of cast expressions as lvalues is deprecated");
+ break;
+ }
}
/* Warn about storing in something that is `const'. */
diff --git a/gcc/fixinc/fixincl.x b/gcc/fixinc/fixincl.x
index 609fc62..5aa85b2 100644
--- a/gcc/fixinc/fixincl.x
+++ b/gcc/fixinc/fixincl.x
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed Monday October 20, 2003 at 01:29:54 PM PDT
+ * It has been AutoGen-ed Wednesday October 22, 2003 at 10:23:00 PM UTC
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT CVS-MERGE THIS FILE, EITHER Mon Oct 20 13:29:54 PDT 2003
+/* DO NOT CVS-MERGE THIS FILE, EITHER Wed Oct 22 22:23:00 UTC 2003
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -15,7 +15,7 @@
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
- * This file contains 160 fixup descriptions.
+ * This file contains 161 fixup descriptions.
*
* See README for more information.
*
@@ -3571,6 +3571,41 @@ static const char* apzNodeent_SyntaxPatch[] = {
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
+ * Description of Obstack_Lvalue_Cast fix
+ */
+tSCC zObstack_Lvalue_CastName[] =
+ "obstack_lvalue_cast";
+
+/*
+ * File name selection pattern
+ */
+tSCC zObstack_Lvalue_CastList[] =
+ "|obstack.h|";
+/*
+ * Machine/OS name selection pattern
+ */
+#define apzObstack_Lvalue_CastMachs (const char**)NULL
+
+/*
+ * content selection pattern - do fix if pattern found
+ */
+tSCC zObstack_Lvalue_CastSelect0[] =
+ "\\*\\(\\(([^()]*)\\*\\)(.*)\\)\\+\\+ = \\(([^()]*)\\)";
+
+#define OBSTACK_LVALUE_CAST_TEST_CT 1
+static tTestDesc aObstack_Lvalue_CastTests[] = {
+ { TT_EGREP, zObstack_Lvalue_CastSelect0, (regex_t*)NULL }, };
+
+/*
+ * Fix Command Arguments for Obstack_Lvalue_Cast
+ */
+static const char* apzObstack_Lvalue_CastPatch[] = {
+ "format",
+ "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))",
+ (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
* Description of Osf_Namespace_A fix
*/
tSCC zOsf_Namespace_AName[] =
@@ -6344,9 +6379,9 @@ static const char* apzX11_SprintfPatch[] = {
*
* List of all fixes
*/
-#define REGEX_COUNT 180
+#define REGEX_COUNT 181
#define MACH_LIST_SIZE_LIMIT 261
-#define FIX_COUNT 160
+#define FIX_COUNT 161
/*
* Enumerate the fixes
@@ -6440,6 +6475,7 @@ typedef enum {
NEXT_VOLITILE_FIXIDX,
NEXT_WAIT_UNION_FIXIDX,
NODEENT_SYNTAX_FIXIDX,
+ OBSTACK_LVALUE_CAST_FIXIDX,
OSF_NAMESPACE_A_FIXIDX,
OSF_NAMESPACE_C_FIXIDX,
PTHREAD_PAGE_SIZE_FIXIDX,
@@ -6955,6 +6991,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
NODEENT_SYNTAX_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aNodeent_SyntaxTests, apzNodeent_SyntaxPatch, 0 },
+ { zObstack_Lvalue_CastName, zObstack_Lvalue_CastList,
+ apzObstack_Lvalue_CastMachs,
+ OBSTACK_LVALUE_CAST_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aObstack_Lvalue_CastTests, apzObstack_Lvalue_CastPatch, 0 },
+
{ zOsf_Namespace_AName, zOsf_Namespace_AList,
apzOsf_Namespace_AMachs,
OSF_NAMESPACE_A_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/gcc/fixinc/inclhack.def b/gcc/fixinc/inclhack.def
index 45a0bb8..2f285f5 100644
--- a/gcc/fixinc/inclhack.def
+++ b/gcc/fixinc/inclhack.def
@@ -1997,6 +1997,31 @@ fix = {
/*
+ * obstack.h used casts as lvalues.
+ *
+ * We need to change postincrements of casted pointers (which are
+ * then dereferenced and assigned into) of the form
+ *
+ * *((TYPE*)PTRVAR)++ = (VALUE)
+ *
+ * into expressions like
+ *
+ * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
+ *
+ * which is correct for the cases used in obstack.h since PTRVAR is
+ * of type char * and the value of the expression is not used.
+ */
+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.
diff --git a/gcc/fixinc/tests/base/obstack.h b/gcc/fixinc/tests/base/obstack.h
new file mode 100644
index 0000000..ea8e8dd
--- /dev/null
+++ b/gcc/fixinc/tests/base/obstack.h
@@ -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 */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5153e07..d50d0fb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-10-22 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ * gcc.dg/cast-lvalue-1.c: New test.
+
2003-10-21 Mark Mitchell <mark@codesourcery.com>
PR c++/11962
diff --git a/gcc/testsuite/gcc.dg/cast-lvalue-1.c b/gcc/testsuite/gcc.dg/cast-lvalue-1.c
new file mode 100644
index 0000000..1e0f04a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cast-lvalue-1.c
@@ -0,0 +1,12 @@
+/* Test for deprecation of casts as lvalues. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int x;
+
+void
+foo (void)
+{
+ (char) x = 1; /* { dg-warning "lvalue" "cast as lvalue deprecated" } */
+}