]> git.ipfire.org Git - people/ms/gcc.git/commit
preprocessor: Support #warning for standard C2x
authorJoseph Myers <joseph@codesourcery.com>
Thu, 18 Aug 2022 23:01:01 +0000 (23:01 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 18 Aug 2022 23:01:01 +0000 (23:01 +0000)
commitd7c3000147c1d8090f66a2baf4623d2c0dfe8eb6
treebd7d06ce9c89f25ee43e73644ed143f5947147a7
parent8731aa98674eda56425ffd652918ce4979631f67
preprocessor: Support #warning for standard C2x

ISO C2x standardizes the existing #warning extension.  Arrange
accordingly for it not to be diagnosed with -std=c2x -pedantic, but to
be diagnosed with -Wc11-c2x-compat.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/testsuite/
* gcc.dg/cpp/c11-warning-1.c, gcc.dg/cpp/c11-warning-2.c,
gcc.dg/cpp/c11-warning-3.c, gcc.dg/cpp/c11-warning-4.c,
gcc.dg/cpp/c2x-warning-1.c, gcc.dg/cpp/c2x-warning-2.c,
gcc.dg/cpp/gnu11-warning-1.c, gcc.dg/cpp/gnu11-warning-2.c,
gcc.dg/cpp/gnu11-warning-3.c, gcc.dg/cpp/gnu11-warning-4.c,
gcc.dg/cpp/gnu2x-warning-1.c, gcc.dg/cpp/gnu2x-warning-2.c: New
tests.

libcpp/
* include/cpplib.h (struct cpp_options): Add warning_directive.
* init.cc (struct lang_flags, lang_defaults): Add
warning_directive.
* directives.cc (DIRECTIVE_TABLE): Mark #warning as STDC2X not
EXTENSION.
(directive_diagnostics): Diagnose #warning with -Wc11-c2x-compat,
or with -pedantic for a standard not supporting #warning.
15 files changed:
gcc/testsuite/gcc.dg/cpp/c11-warning-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/c11-warning-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/c11-warning-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/c11-warning-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/c2x-warning-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/c2x-warning-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/gnu11-warning-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/gnu11-warning-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/gnu11-warning-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/gnu11-warning-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/gnu2x-warning-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/gnu2x-warning-2.c [new file with mode: 0644]
libcpp/directives.cc
libcpp/include/cpplib.h
libcpp/init.cc