From 30321c396e258cd2ed96e93b28a2ccd5b294b56f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sat, 8 Nov 2003 01:38:48 +0000 Subject: [PATCH] c-typeck.c (pedantic_lvalue_warning): Deprecate compound expressions as lvalues. * c-typeck.c (pedantic_lvalue_warning): Deprecate compound expressions as lvalues. (internal_build_compound_expr): Remove special handling for non-pedantic case. * doc/extend.texi: Document that all extended lvalues are now deprecated. testsuite: * gcc.dg/compound-lvalue-1.c: New test. * gcc.dg/c90-const-expr-2.c, gcc.dg/c99-const-expr-2.c: Remove some XFAILs. From-SVN: r73352 --- gcc/ChangeLog | 9 +++++++++ gcc/c-typeck.c | 8 +------- gcc/doc/extend.texi | 3 ++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/c90-const-expr-2.c | 2 +- gcc/testsuite/gcc.dg/c99-const-expr-2.c | 2 +- gcc/testsuite/gcc.dg/compound-lvalue-1.c | 12 ++++++++++++ 7 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/compound-lvalue-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 80f1b5f5dc27..af24a904bf45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2003-11-08 Joseph S. Myers + + * c-typeck.c (pedantic_lvalue_warning): Deprecate compound + expressions as lvalues. + (internal_build_compound_expr): Remove special handling for + non-pedantic case. + * doc/extend.texi: Document that all extended lvalues are now + deprecated. + 2003-11-07 Geoffrey Keating PR 11654 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 81eee375f39e..fc6dc5952ba7 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2591,8 +2591,7 @@ pedantic_lvalue_warning (enum tree_code code) pedwarn ("use of conditional expressions as lvalues is deprecated"); break; case COMPOUND_EXPR: - if (pedantic) - pedwarn ("ISO C forbids use of compound expressions as lvalues"); + pedwarn ("use of compound expressions as lvalues is deprecated"); break; default: pedwarn ("use of cast expressions as lvalues is deprecated"); @@ -2903,11 +2902,6 @@ internal_build_compound_expr (tree list, int first_p) && ! (TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR && VOID_TYPE_P (TREE_TYPE (TREE_VALUE (list))))) warning ("left-hand operand of comma expression has no effect"); - - /* When pedantic, a compound expression can be neither an lvalue - nor an integer constant expression. */ - if (! pedantic) - return rest; } /* With -Wunused, we should also warn if the left-hand operand does have diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index e2982929e587..fdc1c7c68276 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -1069,7 +1069,8 @@ This will work with all versions of GCC@. 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. +their addresses or store values into them. All these extensions are +deprecated. Standard C++ allows compound expressions and conditional expressions as lvalues, and permits casts to reference type, so use of this diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8390d0191436..9cf4afd7b8ba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2003-11-08 Joseph S. Myers + + * gcc.dg/compound-lvalue-1.c: New test. + * gcc.dg/c90-const-expr-2.c, gcc.dg/c99-const-expr-2.c: Remove + some XFAILs. + 2003-11-06 Geoffrey Keating * gcc.dg/altivec-varargs-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-2.c b/gcc/testsuite/gcc.dg/c90-const-expr-2.c index 746093bebcf1..7363e2a2e2cf 100644 --- a/gcc/testsuite/gcc.dg/c90-const-expr-2.c +++ b/gcc/testsuite/gcc.dg/c90-const-expr-2.c @@ -30,7 +30,7 @@ foo (void) ASSERT_NPC ((void *)0); ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ - ASSERT_NOT_NPC ((void *)(0, 0)); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ + ASSERT_NOT_NPC ((void *)(0, 0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ /* This last one is a null pointer constant in C99 only. */ ASSERT_NOT_NPC ((void *)(1 ? 0 : (0, 0))); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-2.c b/gcc/testsuite/gcc.dg/c99-const-expr-2.c index c9f8e0ffbc8c..1ba1b4a674a6 100644 --- a/gcc/testsuite/gcc.dg/c99-const-expr-2.c +++ b/gcc/testsuite/gcc.dg/c99-const-expr-2.c @@ -30,7 +30,7 @@ foo (void) ASSERT_NPC ((void *)0); ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ - ASSERT_NOT_NPC ((void *)(0, 0)); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ + ASSERT_NOT_NPC ((void *)(0, 0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */ /* This last one is a null pointer constant in C99 only. */ ASSERT_NPC ((void *)(1 ? 0 : (0, 0))); diff --git a/gcc/testsuite/gcc.dg/compound-lvalue-1.c b/gcc/testsuite/gcc.dg/compound-lvalue-1.c new file mode 100644 index 000000000000..c77403d02e30 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compound-lvalue-1.c @@ -0,0 +1,12 @@ +/* Test for deprecation of compound expressions as lvalues. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int x, y; + +void +foo (void) +{ + (x, y) = 1; /* { dg-warning "lvalue" "compound expression as lvalue deprecated" } */ +} -- 2.43.5