[clang] [Clang] prevent incorrect rejection of auto with reordered declaration specifiers in C23 (PR #177865)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 28 08:08:10 PST 2026


================
@@ -39,7 +39,9 @@ constexpr auto Ulong = 1L;
 constexpr auto CompoundLiteral = (int){13};
 constexpr auto DoubleCast = (double)(1 / 3);
 constexpr auto String = "this is a string"; // both-error {{constexpr pointer initializer is not null}}
-constexpr signed auto Long = 1L; // both-error {{'auto' cannot be signed or unsigned}}
+// both-error at +2 {{cannot combine with previous 'auto' declaration specifier}}
+// both-error at +1 {{illegal storage class on file-scoped variable}}
----------------
AaronBallman wrote:

The "cannot combine" diagnostic is unfortunate because what is the "previous" auto declaration specifier? I think the original diagnostic behavior was a bit better, though the "illegal storage class on file-scoped variable" is reasonable to emit as well.

https://github.com/llvm/llvm-project/pull/177865


More information about the cfe-commits mailing list