<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 - C++11 lacks Errors when thread safety attribute is applied to static members"
   href="https://bugs.llvm.org/show_bug.cgi?id=32066">32066</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>C++11 lacks Errors when thread safety attribute is applied to static members
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>charles_li@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling at C++11, no error is issued when thread safety attributes
applied to static members.

I discovered this while updating the following Lit test to be C++11 compatible.
test/SemaCXX/warn-thread-safety-parsing.cpp


Here is a reduced test case.

$ cat b.cpp
#define LOCKABLE            __attribute__ ((lockable))
#define EXCLUSIVE_LOCKS_REQUIRED(...)   __attribute__
((exclusive_locks_required(__VA_ARGS__)))
#define GUARDED_BY(x)       __attribute__ ((guarded_by(x)))

class LOCKABLE Mutex { };

class FooStream;

class Foo {
public:
  Mutex mu;

  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
  static int si GUARDED_BY(mu);
  friend FooStream& operator<<(FooStream& s, const Foo& f)
EXCLUSIVE_LOCKS_REQUIRED(mu);
};


Compiling the above test at C++98 gives three errors

$ clang -c -Wthread-safety b.cpp -std=c++98
b.cpp:13:46: error: invalid use of member 'mu' in static member function
  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
                                             ^~
b.cpp:2:82: note: expanded from macro 'EXCLUSIVE_LOCKS_REQUIRED'
#define EXCLUSIVE_LOCKS_REQUIRED(...)   __attribute__
((exclusive_locks_required(__VA_ARGS__)))
                                                                               
 ^~~~~~~~~~~
b.cpp:14:28: error: invalid use of non-static data member 'mu'
  static int si GUARDED_BY(mu);
                           ^~
b.cpp:3:56: note: expanded from macro 'GUARDED_BY'
#define GUARDED_BY(x)       __attribute__ ((guarded_by(x)))
                                                       ^
b.cpp:15:85: error: invalid use of non-static data member 'mu'
  friend FooStream& operator<<(FooStream& s, const Foo& f)
EXCLUSIVE_LOCKS_REQUIRED(mu);
                                                                               
    ^~
b.cpp:2:82: note: expanded from macro 'EXCLUSIVE_LOCKS_REQUIRED'
#define EXCLUSIVE_LOCKS_REQUIRED(...)   __attribute__
((exclusive_locks_required(__VA_ARGS__)))
                                                                               
 ^~~~~~~~~~~
3 errors generated.


Compiling the same test at C++11 gives no error.
$ /home/chli/Source/uclsvn/build/bin/clang -c -Wthread-safety b.cpp -std=c++11</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>