<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wmissing-variable-declarations and Wmissing-prototypes should also suggest inline"
   href="https://bugs.llvm.org/show_bug.cgi?id=44305">44305</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wmissing-variable-declarations and Wmissing-prototypes should also suggest inline
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david@doublewise.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre><source>:1:5: warning: no previous extern declaration for non-static variable
'x' [-Wmissing-variable-declarations]

int x = 5;

    ^

<source>:1:1: note: declare 'static' if the variable is not intended to be used
outside of this translation unit

int x = 5;

^

<source>:3:6: warning: no previous prototype for function 'f'
[-Wmissing-prototypes]

void f() {}

     ^

<source>:3:1: note: declare 'static' if the function is not intended to be used
outside of this translation unit

void f() {}

^

static 

2 warnings generated.

Compiler returned: 0




The warning message just suggests "static" if the variable / function is not
supposed to be used outside of this translation unit. This is not the best fix
for things declared in headers, where the suggestion should be to declare them
inline (variables in C++17 mode). Ideally, the compiler would be smart and see
that this variable / function arrived in the current translation unit via
`include` and tell me to use inline in that case, otherwise tell me to use
static.

This is somewhat related to <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Confusing warning description [-Wmissing-variable-declarations]"
   href="show_bug.cgi?id=17566">https://bugs.llvm.org/show_bug.cgi?id=17566</a>, which
is complaining about the emphasis of "extern" on a variable declaration,
despite that usage being (probably?) less common than static variables.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>