diff mbox

Fix PRs c/52283/37985

Message ID 4F7C0382.2080701@st.com
State New
Headers show

Commit Message

Christian Bruel April 4, 2012, 8:17 a.m. UTC
Hello,

Is it OK to push the cleaning of TREE_NO_WARNING to fix the constant 
expressions errors discrepancies, as discussed in bugzilla #52283, now 
that the trunk is open ?

Many thanks,

Comments

Manuel López-Ibáñez April 4, 2012, 9:38 a.m. UTC | #1
Hi Christian,

You have to add the testcases from both PR52283 and PR37985, and an
appropriate Changelog, and bootstrap+regression test everything and
double-check that the new testcases don't fail and no old testcases
fail with the patch (by comparing with the testcases that fail without
the patch).

Cheers,

Manuel.

On 4 April 2012 10:17, Christian Bruel <christian.bruel@st.com> wrote:
> Hello,
>
> Is it OK to push the cleaning of TREE_NO_WARNING to fix the constant
> expressions errors discrepancies, as discussed in bugzilla #52283, now that
> the trunk is open ?
>
> Many thanks,
>
>
>
Christian Bruel April 4, 2012, 11:05 a.m. UTC | #2
On 04/04/2012 11:38 AM, Manuel López-Ibáñez wrote:
> Hi Christian,
>
> You have to add the testcases from both PR52283 and PR37985, and an
> appropriate Changelog, and bootstrap+regression test everything and
> double-check that the new testcases don't fail and no old testcases
> fail with the patch (by comparing with the testcases that fail without
> the patch).


The testscase was part of the attached patch, along with the ChangeLog 
entries

It was bootstrapped and regtested for C and C++ on x86 (that was in 
bugzilla comment #22), sorry I should have mentioned it here too. done 
now :)

Cheers

Christian


>
> Cheers,
>
> Manuel.
>
> On 4 April 2012 10:17, Christian Bruel<christian.bruel@st.com>  wrote:
>> Hello,
>>
>> Is it OK to push the cleaning of TREE_NO_WARNING to fix the constant
>> expressions errors discrepancies, as discussed in bugzilla #52283, now that
>> the trunk is open ?
>>
>> Many thanks,
>>
>>
>>
Manuel López-Ibáñez April 4, 2012, 11:25 a.m. UTC | #3
On 4 April 2012 13:05, Christian Bruel <christian.bruel@st.com> wrote:
>
>
> The testscase was part of the attached patch, along with the ChangeLog
> entries

You are right! Sorry, I may have been looking at the wrong place.

> It was bootstrapped and regtested for C and C++ on x86 (that was in bugzilla
> comment #22), sorry I should have mentioned it here too. done now :)

Thanks for taking care of this.

Cheers,

Manuel.
Manuel López-Ibáñez April 14, 2012, 2:53 p.m. UTC | #4
As far as I know, this patch hasn't been reviewed:

http://patchwork.ozlabs.org/patch/150636/

Cheers,

Manuel.


On 4 April 2012 10:17, Christian Bruel <christian.bruel@st.com> wrote:
> Hello,
>
> Is it OK to push the cleaning of TREE_NO_WARNING to fix the constant
> expressions errors discrepancies, as discussed in bugzilla #52283, now that
> the trunk is open ?
>
> Many thanks,
>
>
>
diff mbox

Patch

2012-03-29   Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/52283/37985
	* stmt.c (warn_if_unused_value): Skip NOP_EXPR.
	* convert.c (convert_to_integer): Don't set TREE_NO_WARNING.

2010-03-29  Christian Bruel  <christian.bruel@st.com>

	PR c/52283
	* gcc.dg/case-const-1.c: Test constant expression.
	* gcc.dg/case-const-2.c: Likewise.
	* gcc.dg/case-const-3.c: Likewise.

2012-03-29   Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* gcc/testsuite/gcc.dg/pr37985.c: New test.

Index: gcc/testsuite/gcc.dg/pr37985.c
===================================================================
--- gcc/testsuite/gcc.dg/pr37985.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr37985.c	(revision 0)
@@ -0,0 +1,8 @@ 
+/* PR c/37985 */
+/* { dg-do compile } */
+/* { dg-options " -Wall -Wextra " } */
+unsigned char foo(unsigned char a)
+{
+  a >> 2; /* { dg-warning "no effect" } */
+  return a;
+}
Index: gcc/testsuite/gcc.dg/case-const-1.c
===================================================================
--- gcc/testsuite/gcc.dg/case-const-1.c	(revision 186082)
+++ gcc/testsuite/gcc.dg/case-const-1.c	(working copy)
@@ -1,9 +1,11 @@ 
 /* Test for case labels not integer constant expressions but folding
-   to integer constants (used in Linux kernel, PR 39613).  */
+   to integer constants (used in Linux kernel, PR 39613, 52283).  */
 /* { dg-do compile } */
 /* { dg-options "" } */
 
 extern int i;
+extern unsigned int u;
+
 void
 f (int c)
 {
@@ -13,3 +15,13 @@ 
       ;
     }
 }
+
+void
+b (int c)
+{
+  switch (c)
+    {
+    case (int) (2  | ((4 < 8) ? 8 : u)):
+      ;
+    }
+}
Index: gcc/testsuite/gcc.dg/case-const-2.c
===================================================================
--- gcc/testsuite/gcc.dg/case-const-2.c	(revision 186082)
+++ gcc/testsuite/gcc.dg/case-const-2.c	(working copy)
@@ -1,9 +1,11 @@ 
 /* Test for case labels not integer constant expressions but folding
-   to integer constants (used in Linux kernel, PR 39613).  */
+   to integer constants (used in Linux kernel, PR 39613, 52283).  */
 /* { dg-do compile } */
 /* { dg-options "-pedantic" } */
 
 extern int i;
+extern unsigned int u;
+
 void
 f (int c)
 {
@@ -13,3 +15,14 @@ 
       ;
     }
 }
+
+void
+b (int c)
+{
+  switch (c)
+    {
+    case (int) (2  | ((4 < 8) ? 8 : u)): /* { dg-warning "case label is not an integer constant expression" } */
+      ;
+    }
+}
+
Index: gcc/testsuite/gcc.dg/case-const-3.c
===================================================================
--- gcc/testsuite/gcc.dg/case-const-3.c	(revision 186082)
+++ gcc/testsuite/gcc.dg/case-const-3.c	(working copy)
@@ -1,9 +1,11 @@ 
 /* Test for case labels not integer constant expressions but folding
-   to integer constants (used in Linux kernel, PR 39613).  */
+   to integer constants (used in Linux kernel, PR 39613, 52283, ).  */
 /* { dg-do compile } */
 /* { dg-options "-pedantic-errors" } */
 
 extern int i;
+extern unsigned int u;
+
 void
 f (int c)
 {
@@ -13,3 +15,16 @@ 
       ;
     }
 }
+
+void
+b (int c)
+{
+  switch (c)
+    {
+    case (int) (2  | ((4 < 8) ? 8 : u)): /* { dg-error "case label is not an integer constant expression" } */
+      ;
+    }
+}
+
+
+
Index: gcc/stmt.c
===================================================================
--- gcc/stmt.c	(revision 186082)
+++ gcc/stmt.c	(working copy)
@@ -1515,6 +1515,7 @@ 
 
     case SAVE_EXPR:
     case NON_LVALUE_EXPR:
+    case NOP_EXPR:
       exp = TREE_OPERAND (exp, 0);
       goto restart;
 
Index: gcc/convert.c
===================================================================
--- gcc/convert.c	(revision 186082)
+++ gcc/convert.c	(working copy)
@@ -542,7 +542,6 @@ 
       else if (outprec >= inprec)
 	{
 	  enum tree_code code;
-	  tree tem;
 
 	  /* If the precision of the EXPR's type is K bits and the
 	     destination mode has more bits, and the sign is changing,
@@ -560,13 +559,7 @@ 
 	  else
 	    code = NOP_EXPR;
 
-	  tem = fold_unary (code, type, expr);
-	  if (tem)
-	    return tem;
-
-	  tem = build1 (code, type, expr);
-	  TREE_NO_WARNING (tem) = 1;
-	  return tem;
+	  return fold_build1 (code, type, expr);
 	}
 
       /* If TYPE is an enumeral type or a type with a precision less