aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeLesley Hutchins <delesley@google.com>2013-02-07 19:01:07 +0000
committerDeLesley Hutchins <delesley@google.com>2013-02-07 19:01:07 +0000
commited4330bc159b8311080d03caacac9a8cbf42370c (patch)
tree5b03f6396adbc0a1da0e84ad96bb8d609a4c69f4
parentb30c0382022abc891f1c6586b80db14550442d25 (diff)
Thread safety analysis: make sure that expressions in attributes are parsed
in an unevaluated context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174644 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseDecl.cpp1
-rw-r--r--test/SemaCXX/warn-thread-safety-analysis.cpp13
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 8e24a14d0b..14fd581ddc 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -1023,6 +1023,7 @@ void Parser::ParseThreadSafetyAttribute(IdentifierInfo &AttrName,
// now parse the list of expressions
while (Tok.isNot(tok::r_paren)) {
+ EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
ExprResult ArgExpr(ParseAssignmentExpression());
if (ArgExpr.isInvalid()) {
ArgExprsOk = false;
diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp
index 26a3df0ef3..3f41124d47 100644
--- a/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -3902,3 +3902,16 @@ class Foo {
} // end namespace TestThrowExpr
+namespace UnevaluatedContextTest {
+
+// parse attribute expressions in an unevaluated context.
+
+static inline Mutex* getMutex1();
+static inline Mutex* getMutex2();
+
+void bar() EXCLUSIVE_LOCKS_REQUIRED(getMutex1());
+
+void bar2() EXCLUSIVE_LOCKS_REQUIRED(getMutex1(), getMutex2());
+
+} // end namespace UnevaluatedContextTest
+