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]

Re: [tree-ssa] Merge status


Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

> Ian Lance Taylor <ian@wasabisystems.com> writes:
> 
> | Yes, this is why I think it would be wise to have an unconditional
> | warning for lvalue casts for two or three releases before actually
> | removing the code.  It gives people a reasonable chance to fix their
> | code, while letting their users simply ignore the warnings.
> 
> If you prepare such patch against 3.3.4, I would accept it.

Here is the 3.3.4 patch.  This is minimal--I didn't try to add any new
test cases or anything like that.

It passed the C testsuite.  I'm running a i686-pc-linux-gnu bootstrap
now.

Ian


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.


Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.213.2.13
diff -p -u -r1.213.2.13 c-typeck.c
--- gcc/c-typeck.c	12 Mar 2004 22:43:24 -0000	1.213.2.13
+++ gcc/c-typeck.c	17 Mar 2004 18:09:37 -0000
@@ -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;
+    }
 }
 
 /* Warn about storing in something that is `const'.  */
Index: gcc/fixinc/fixincl.x
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/fixincl.x,v
retrieving revision 1.132.4.15
diff -p -u -r1.132.4.15 fixincl.x
--- gcc/fixinc/fixincl.x	3 Dec 2003 20:10:43 -0000	1.132.4.15
+++ gcc/fixinc/fixincl.x	17 Mar 2004 18:09:44 -0000
@@ -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.
  *
@@ -3808,6 +3808,41 @@ static const char* apzNodeent_SyntaxPatc
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  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[] =
@@ -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,
@@ -7066,6 +7102,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      apzNodeent_SyntaxMachs,
      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,
Index: gcc/fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.139.4.16
diff -p -u -r1.139.4.16 inclhack.def
--- gcc/fixinc/inclhack.def	3 Dec 2003 20:10:42 -0000	1.139.4.16
+++ gcc/fixinc/inclhack.def	17 Mar 2004 18:09:45 -0000
@@ -2132,6 +2132,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.
Index: gcc/doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.109.2.27
diff -p -u -r1.109.2.27 extend.texi
--- gcc/doc/extend.texi	6 Feb 2004 19:43:32 -0000	1.109.2.27
+++ gcc/doc/extend.texi	17 Mar 2004 18:39:12 -0000
@@ -1037,9 +1037,7 @@ Compound expressions, conditional expres
 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]