<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/135481>135481</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [[deprecated]] attribute ignored after definition
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kimbarrett
      </td>
    </tr>
</table>

<pre>
    If a function declaration is adding the `[[deprecated]]` attribute to an
already defined but not deprecated function, that attribute is ignored. It
generates a `-Wignored-attribute` warning if that's enabled. The attribute is
successfully added if there are only prior non-definition declarations of the
function. There's not an obvious (to me) reason to ignore the added attribute
after a definition. Redeclarations to add this attribute are permitted by the
standard. And whether there is or is not a prior definition may depend on a
multitude of factors.

Test case:

---------- 
inline int frob(int x)
#ifdef DEFINE_BEFORE_DEPRECATE
{ return x; }
#else
;
#endif
[[deprecated]] int frob(int);
----------

Compile without defining DEFINE_BEFORE_DEPRECATE => no warnings.

Compile with -DDEFINE_BEFORE_DEPRECATE =>

ignored-deprecation-after-definition.cpp:7:3: warning: attribute declaration must precede definition [-Wignored-attributes]
    7 | [[deprecated]] int frob(int);
      | ^
ignored-deprecation-after-definition.cpp:1:12: note: previous definition is here
    1 | inline int frob(int x)
      |            ^

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVM2O4jgQfhpzKYGMHTpwyCE0IPVld9VqaY-jSlwh3k1sZFe6h7dfOYEmMzsz0kT8GJKvvh-XC2O0Z0dUiM1ebA4LHLj1ofjX9hWGQMyLyptr8dIAQjO4mq13YKjuMOC4thHQGOvOwC2BeJJjob2hS6AamYzYHNLrSQIyB1sNTMAe0AlZYhcIzRUMNdaRgWpgcJ7hgf4kFeoZuEWeVbER7Nn5QGYFLyxkeSZHAZkiYFKy_Pt2e_mJSTI-MLik1zZjQaHyCOSw6lKdt5a-YRCyjENdU4zN0HX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