From 8d95fe25c52092393ae58669bc956fab9802e390 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 3 Sep 2014 11:16:29 +0000 Subject: [PATCH] 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 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 2 ++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/pr62024.C | 7 +++++++ gcc/testsuite/gcc.dg/pr62024.c | 8 ++++++++ 5 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr62024.C create mode 100644 gcc/testsuite/gcc.dg/pr62024.c 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" } */ -- 2.30.2