]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: c-typeck.c (pedantic_lvalue_warning): Deprecate compound expressions as...
authorIan Lance Taylor <ian@wasabisystems.com>
Wed, 17 Mar 2004 20:13:20 +0000 (20:13 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 17 Mar 2004 20:13:20 +0000 (20:13 +0000)
Backport:
2003-11-08  Joseph S. Myers  <jsm@polyomino.org.uk>

* c-typeck.c (pedantic_lvalue_warning): Deprecate compound
expressions as lvalues.
* doc/extend.texi: Document that all extended lvalues are now
deprecated.

2003-11-05  Joseph S. Myers  <jsm@polyomino.org.uk>

* c-typeck.c (pedantic_lvalue_warning): Deprecate use of
conditional expressions as lvalues.

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.

From-SVN: r79600

gcc/ChangeLog
gcc/c-typeck.c
gcc/doc/extend.texi
gcc/fixinc/fixincl.x
gcc/fixinc/inclhack.def

index af99edc81d5d4d87b16f7c9f20dedcfe8377cad4..431df9b51cf283b3917e900dbf07b094f0d2f399 100644 (file)
@@ -1,3 +1,25 @@
+2004-03-17  Ian Lance Taylor  <ian@wasabisystems.com>
+
+       Backport:
+       2003-11-08  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * c-typeck.c (pedantic_lvalue_warning): Deprecate compound
+       expressions as lvalues.
+       * doc/extend.texi: Document that all extended lvalues are now
+       deprecated.
+
+       2003-11-05  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * c-typeck.c (pedantic_lvalue_warning): Deprecate use of
+       conditional expressions as lvalues.
+
+       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.
+
 2004-03-15  Richard Henderson  <rth@redhat.com>
 
         PR middle-end/14535
index e50ce5b100ae57e6260245abbd34faa8d712b372..a3ef0f69fb5965e00eeca60224ba6268f8f66c39 100644 (file)
@@ -3234,19 +3234,18 @@ static void
 pedantic_lvalue_warning (code)
      enum tree_code code;
 {
-  if (pedantic)
-    switch (code)
-      {
-      case COND_EXPR:
-       pedwarn ("ISO C forbids use of conditional expressions as lvalues");
-       break;
-      case COMPOUND_EXPR:
-       pedwarn ("ISO C forbids use of compound expressions as lvalues");
-       break;
-      default:
-       pedwarn ("ISO C forbids use of cast expressions as lvalues");
-       break;
-      }
+  switch (code)
+    {
+    case COND_EXPR:
+      pedwarn ("use of conditional expressions as lvalues is deprecated");
+      break;
+    case COMPOUND_EXPR:
+      pedwarn ("use of compound expressions as lvalues is deprecated");
+      break;
+    default:
+      pedwarn ("use of cast expressions as lvalues is deprecated");
+      break;
+    }
 }
 \f
 /* Warn about storing in something that is `const'.  */
index f4fd28ea8e3275dba9adc4f71fade3ab8a08c92b..5d7479e50d2fa1b9a3a5bde0925cb0407cbab3d8 100644 (file)
@@ -1037,9 +1037,7 @@ Compound expressions, conditional expressions and casts are allowed as
 lvalues provided their operands are lvalues.  This means that you can take
 their addresses or store values into them.
 
-Standard C++ allows compound expressions and conditional expressions as
-lvalues, and permits casts to reference type, so use of this extension
-is deprecated for C++ code.
+All these extensions are deprecated.
 
 For example, a compound expression can be assigned, provided the last
 expression in the sequence is an lvalue.  These two expressions are
index 0f20f3a5806bbf64253b8c08108286fb6f4ed539..c2d27b0414b5d496a95910812d77bec0091b987d 100644 (file)
@@ -5,7 +5,7 @@
  * files which are fixed to work correctly with ANSI C and placed in a
  * directory that GNU C will search.
  *
- * This file contains 163 fixup descriptions.
+ * This file contains 164 fixup descriptions.
  *
  * See README for more information.
  *
@@ -3806,6 +3806,41 @@ static const char* apzNodeent_SyntaxPatch[] = {
     "%0;",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  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
@@ -6418,9 +6453,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          177
+#define REGEX_COUNT          178
 #define MACH_LIST_SIZE_LIMIT 334
-#define FIX_COUNT            163
+#define FIX_COUNT            164
 
 /*
  *  Enumerate the fixes
@@ -6521,6 +6556,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,
@@ -7067,6 +7103,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,
index 676463e24be765e3fde73e98c0207d98c8135944..959cb569da0b09ae720403f253c57f6ffc8b8149 100644 (file)
@@ -2131,6 +2131,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