+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
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'. */
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
* 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.
*
"%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
*
* 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
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,
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,
};
+/*
+ * 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