https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107589

            Bug ID: 107589
           Summary: [C2x] `-Wold-style-declaration' triggers warning on
                    `const auto'
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p...@gcc-bugzilla.mail.kapsi.fi
  Target Milestone: ---

Hi.

`-Wold-style-declaration' currently triggers warning when used with C2x `const
auto' (`auto const' is not affected).

Apparently the standard is a bit vague about this case.  Grammar `const auto'
is accepted by LLVM [1].  Also, the corresponding GCC testcases (c2x-auto-1.c
and c2x-auto-2.c) use `const auto' (not `auto const').

Using version `13.0.0 20221109 (experimental)':

# echo 'void f() { const auto x [[maybe_unused]] = 0; }' | gcc -c -xc -std=c2x
-Wold-style-declaration -
<stdin>: In function 'f':
<stdin>:1:1: warning: 'auto' is not at beginning of declaration
[-Wold-style-declaration]

[1] https://reviews.llvm.org/D133289

Reply via email to