[llvm-bugs] [Bug 32066] New: C++11 lacks Errors when thread safety attribute is applied to static members
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 24 11:55:18 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=32066
Bug ID: 32066
Summary: C++11 lacks Errors when thread safety attribute is
applied to static members
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: charles_li at playstation.sony.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170224/46b7a2d5/attachment.html>
More information about the llvm-bugs
mailing list