mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-04 01:04:26 +08:00
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
This commit is contained in:
parent
3c21d6e0f7
commit
dc70e81d6e
@ -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
|
||||
|
@ -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'. */
|
||||
|
@ -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.
|
||||
*
|
||||
@ -3569,6 +3569,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
|
||||
@ -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,
|
||||
|
@ -1996,6 +1996,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
|
||||
|
14
gcc/fixinc/tests/base/obstack.h
Normal file
14
gcc/fixinc/tests/base/obstack.h
Normal file
@ -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 */
|
@ -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
|
||||
|
12
gcc/testsuite/gcc.dg/cast-lvalue-1.c
Normal file
12
gcc/testsuite/gcc.dg/cast-lvalue-1.c
Normal file
@ -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" } */
|
||||
}
|
@ -1,3 +1,18 @@
|
||||
2003-10-22 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* 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.
|
||||
|
||||
2003-09-22 Andrew Cagney <cagney@redhat.com>
|
||||
|
||||
* floatformat.h (struct floatformat): Add field "is_valid".
|
||||
|
@ -343,7 +343,7 @@ extern int obstack_exit_failure;
|
||||
|
||||
#endif
|
||||
|
||||
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
|
||||
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
|
||||
|
||||
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
|
||||
|
||||
@ -411,7 +411,7 @@ __extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + 1 > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, 1); \
|
||||
*(__o->next_free)++ = (datum); \
|
||||
obstack_1grow_fast (__o, datum); \
|
||||
(void) 0; })
|
||||
|
||||
/* These assume that the obstack alignment is good enough for pointers or ints,
|
||||
@ -423,19 +423,28 @@ __extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (void *)); \
|
||||
*((void **)__o->next_free)++ = ((void *)datum); \
|
||||
(void) 0; })
|
||||
obstack_ptr_grow_fast (__o, datum); })
|
||||
|
||||
# define obstack_int_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (int)); \
|
||||
*((int *)__o->next_free)++ = ((int)datum); \
|
||||
obstack_int_grow_fast (__o, datum); })
|
||||
|
||||
# define obstack_ptr_grow_fast(OBSTACK,aptr) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o1 = (OBSTACK); \
|
||||
*(const void **) __o1->next_free = (aptr); \
|
||||
__o1->next_free += sizeof (const void *); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
# define obstack_int_grow_fast(OBSTACK,aint) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o1 = (OBSTACK); \
|
||||
*(int *) __o1->next_free = (aint); \
|
||||
__o1->next_free += sizeof (int); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_blank(OBSTACK,length) \
|
||||
__extension__ \
|
||||
@ -443,7 +452,7 @@ __extension__ \
|
||||
int __len = (length); \
|
||||
if (__o->chunk_limit - __o->next_free < __len) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
__o->next_free += __len; \
|
||||
obstack_blank_fast (__o, __len); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_alloc(OBSTACK,length) \
|
||||
@ -530,26 +539,29 @@ __extension__ \
|
||||
# define obstack_1grow(h,datum) \
|
||||
( (((h)->next_free + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), 1), 0) : 0), \
|
||||
(*((h)->next_free)++ = (datum)))
|
||||
obstack_1grow_fast (h, datum))
|
||||
|
||||
# define obstack_ptr_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
|
||||
(*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
|
||||
obstack_ptr_grow_fast (h, datum))
|
||||
|
||||
# define obstack_int_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
|
||||
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
|
||||
obstack_int_grow_fast (h, datum))
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
# define obstack_ptr_grow_fast(h,aptr) \
|
||||
(((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
|
||||
|
||||
# define obstack_int_grow_fast(h,aint) \
|
||||
(((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr))
|
||||
|
||||
# define obstack_blank(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
((h)->next_free += (h)->temp))
|
||||
obstack_blank_fast (h, (h)->temp))
|
||||
|
||||
# define obstack_alloc(h,length) \
|
||||
(obstack_blank ((h), (length)), obstack_finish ((h)))
|
||||
|
Loading…
Reference in New Issue
Block a user