From: Marek Polacek Date: Wed, 3 Sep 2014 11:16:29 +0000 (+0000) Subject: re PR c/62024 (__atomic_always_lock_free is not a constant expression) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d95fe25c52092393ae58669bc956fab9802e390;p=gcc.git re PR c/62024 (__atomic_always_lock_free is not a constant expression) 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. From-SVN: r214871 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 2d02c7b9466..af175a4a914 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-09-03 Marek Polacek + + PR c/62024 + * c-parser.c (c_parser_static_assert_declaration_no_semi): Strip no-op + conversions. + 2014-09-02 Jakub Jelinek Balaji V. Iyer Igor Zamyatin diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 03c68309493..3f4a92ba8b4 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -2060,6 +2060,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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4065e49dc9a..5d1cf61248a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-09-03 Marek Polacek + + PR c/62024 + * g++.dg/cpp0x/pr62024.C: New test. + * gcc.dg/pr62024.c: New test. + 2014-09-03 Ilya Tocar * gcc.target/i386/adx-addcarryx32-1.c: Test addcarry, subborrow. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr62024.C b/gcc/testsuite/g++.dg/cpp0x/pr62024.C new file mode 100644 index 00000000000..5f0640ac123 --- /dev/null +++ b/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 a/gcc/testsuite/gcc.dg/pr62024.c b/gcc/testsuite/gcc.dg/pr62024.c new file mode 100644 index 00000000000..79a0b791f05 --- /dev/null +++ b/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" } */