On Wed, Aug 27, 2014 at 03:06:38PM -0400, Jason Merrill wrote: > On 08/25/2014 07:43 AM, Marek Polacek wrote: > > * semantics.c (finish_static_assert): Strip no-op conversions. > > I think I'd rather strip these in cxx_eval_builtin_function_call so that we > don't have to deal with them in various consumers.
I was playing with this again today and I've found out that I actually don't need to touch C++ FE at all; maybe_constant_value returns integer_cst in this case. Don't know how I flubbed that. Given that the C part are approved, I'm going to commit the following. Bootstrapped/regtested on x86_64-linux. 2014-09-02 Marek Polacek <pola...@redhat.com> PR c/62024 * c-parser.c (c_parser_static_assert_declaration_no_semi): Strip no-op conversions. * g++.dg/cpp0x/pr62024.C: New test. * gcc.dg/pr62024.c: New test. diff --git gcc/c/c-parser.c gcc/c/c-parser.c index d634bb1..fc7bbaf 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -2058,6 +2058,8 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) if (TREE_CODE (value) != INTEGER_CST) { value = c_fully_fold (value, false, NULL); + /* Strip no-op conversions. */ + STRIP_TYPE_NOPS (value); if (TREE_CODE (value) == INTEGER_CST) pedwarn (value_loc, OPT_Wpedantic, "expression in static assertion " "is not an integer constant expression"); diff --git gcc/testsuite/g++.dg/cpp0x/pr62024.C gcc/testsuite/g++.dg/cpp0x/pr62024.C index e69de29..5f0640a 100644 --- gcc/testsuite/g++.dg/cpp0x/pr62024.C +++ gcc/testsuite/g++.dg/cpp0x/pr62024.C @@ -0,0 +1,7 @@ +// PR c/62024 +// { dg-do compile { target c++11 } } +// { dg-require-effective-target sync_char_short } + +int *p; +static_assert (__atomic_always_lock_free (1, p), ""); +static_assert (__atomic_always_lock_free (1, 0), ""); diff --git gcc/testsuite/gcc.dg/pr62024.c gcc/testsuite/gcc.dg/pr62024.c index e69de29..79a0b79 100644 --- gcc/testsuite/gcc.dg/pr62024.c +++ gcc/testsuite/gcc.dg/pr62024.c @@ -0,0 +1,8 @@ +/* PR c/62024 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wpedantic" } */ +/* { dg-require-effective-target sync_char_short } */ + +int *p; +_Static_assert (__atomic_always_lock_free (1, p), ""); /* { dg-warning "is not an integer constant" } */ +_Static_assert (__atomic_always_lock_free (1, 0), ""); /* { dg-warning "is not an integer constant" } */ Marek