Ping: https://gcc.gnu.org/ml/gcc-patches/2016-05/msg02216.html
On 05/27/2016 11:34 AM, Martin Sebor wrote:
The patch below adjusts the C alignof pedantic warning to avoid diagnosing the GCC extension (__alignof__) and only diagnose _Alignof in C99 and prior modes. This is consistent with how __attribute__ ((aligned)) and _Alignas is handled (among other extensions vs standard features). Martin PR c/69507 - bogus warning: ISO C does not allow ‘__alignof__ (expression)’ gcc/testsuite/ChangeLog: 2016-05-27 Martin Sebor <mse...@redhat.com> PR c/69507 * gcc.dg/alignof.c: New test. gcc/c/ChangeLog: 2016-05-27 Martin Sebor <mse...@redhat.com> PR c/69507 * c-parser.c (c_parser_alignof_expression): Avoid diagnosing __alignof__ (expression). Index: gcc/c/c-parser.c =================================================================== --- gcc/c/c-parser.c (revision 232841) +++ gcc/c/c-parser.c (working copy) @@ -7019,9 +7019,10 @@ c_parser_alignof_expression (c_parser *p mark_exp_read (expr.value); c_inhibit_evaluation_warnings--; in_alignof--; - pedwarn (start_loc, - OPT_Wpedantic, "ISO C does not allow %<%E (expression)%>", - alignof_spelling); + if (is_c11_alignof) + pedwarn (start_loc, + OPT_Wpedantic, "ISO C does not allow %<%E (expression)%>", + alignof_spelling); ret.value = c_alignof_expr (start_loc, expr.value); ret.original_code = ERROR_MARK; ret.original_type = NULL; Index: gcc/testsuite/gcc.dg/alignof.c =================================================================== --- gcc/testsuite/gcc.dg/alignof.c (revision 0) +++ gcc/testsuite/gcc.dg/alignof.c (working copy) @@ -0,0 +1,11 @@ +/* PR c/69507 - bogus warning: ISO C does not allow '__alignof__ (expression)' + */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wno-error -Wpedantic" } */ + +extern int e; + +int a[] = { + __alignof__ (e), + _Alignof (e) /* { dg-warning "ISO C does not allow ._Alignof \\(expression\\)." } */ +};