From: Manuel López-Ibáñez Date: Tue, 2 Jan 2007 20:07:44 +0000 (+0000) Subject: re PR c/19977 (overflow in non-static initializer should not be pedwarn) X-Git-Tag: releases/gcc-4.3.0~7750 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b405ac807c267bea1ac27db96cafb5ddf6d68a0b;p=thirdparty%2Fgcc.git re PR c/19977 (overflow in non-static initializer should not be pedwarn) 2007-01-02 Manuel Lopez-Ibanez PR c/19977 * c-typeck.c (store_init_value): Don't emit pedantic overflow warning for non-static initializers. testsuite/ * gcc/testsuite/gcc.dg/overflow-warn-3.c: Remove XFAIL. * gcc/testsuite/gcc.dg/overflow-warn-4.c: Remove XFAIL. From-SVN: r120355 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7e62e9caf3b..a6a1232ecb70 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-01-02 Manuel Lopez-Ibanez + + PR c/19977 + * c-typeck.c (store_init_value): Don't emit pedantic overflow + warning for non-static initializers. + 2007-01-02 Steven Bosscher * config/alpha/alpha.md, arm/arm.c, darwin.c, frv/frv.md, diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 08f7d4a3a796..955bfd959f81 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4292,7 +4292,7 @@ store_init_value (tree decl, tree init) /* ANSI wants warnings about out-of-range constant initializers. */ STRIP_TYPE_NOPS (value); - constant_expression_warning (value); + if (TREE_STATIC (decl)) constant_expression_warning (value); /* Check if we need to set array size from compound literal size. */ if (TREE_CODE (type) == ARRAY_TYPE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5f17a946fe67..9b38348651d2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-01-02 Manuel Lopez-Ibanez + + PR c/19977 + * gcc/testsuite/gcc.dg/overflow-warn-3.c: Remove XFAIL. + * gcc/testsuite/gcc.dg/overflow-warn-4.c: Remove XFAIL. + 2006-01-02 Ian Lance Taylor * g++.dg/warn/Wparentheses-22.C: New test. diff --git a/gcc/testsuite/gcc.dg/overflow-warn-3.c b/gcc/testsuite/gcc.dg/overflow-warn-3.c index f20940efdcd1..2aa8b7f7eb67 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-3.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-3.c @@ -40,7 +40,7 @@ f (void) /* This expression is not required to be a constant expression, so it should just involve undefined behavior at runtime. */ int c = INT_MAX + 1; /* { dg-warning "warning: integer overflow in expression" } */ - /* { dg-bogus "warning: overflow in constant expression" "constant" { xfail *-*-* } 42 } */ + } /* But this expression does need to be constant. */ diff --git a/gcc/testsuite/gcc.dg/overflow-warn-4.c b/gcc/testsuite/gcc.dg/overflow-warn-4.c index acf2c876bf21..a36f66f14fe1 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-4.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-4.c @@ -40,7 +40,7 @@ f (void) /* This expression is not required to be a constant expression, so it should just involve undefined behavior at runtime. */ int c = INT_MAX + 1; /* { dg-warning "warning: integer overflow in expression" } */ - /* { dg-bogus "error: overflow in constant expression" "constant" { xfail *-*-* } 42 } */ + } /* But this expression does need to be constant. */