]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Diagnose auto constexpr used with a type
authorJoseph Myers <joseph@codesourcery.com>
Wed, 7 Dec 2022 22:08:18 +0000 (22:08 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 7 Dec 2022 22:08:18 +0000 (22:08 +0000)
commit3db5bee0079d48ab7c82f8df1cc7efd87a6fed04
tree137adfaf9414292842beb57e96587a95820b1767
parent3ad0f470c16d5528a5283060b007f8b419c33c92
c: Diagnose auto constexpr used with a type

The constraints on auto in C2x disallow use with other storage-class
specifiers unless the type is inferred from an initializer.  That
includes constexpr; add the missing checks for this case (the
combination of auto, constexpr and a type specifier).

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

gcc/c/
* c-decl.cc (declspecs_add_type, declspecs_add_scspec): Check for
auto, constexpr and a type used together.

gcc/testsuite/
* gcc.dg/c2x-constexpr-1.c: Do not use auto, constexpr and a type
together.
* gcc.dg/c2x-constexpr-3.c: Add tests of auto, constexpr and type
used together.
gcc/c/c-decl.cc
gcc/testsuite/gcc.dg/c2x-constexpr-1.c
gcc/testsuite/gcc.dg/c2x-constexpr-3.c