You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Clang] FunctionEffects: ignore (methods of) local CXXRecordDecls. (#166078)
In the following example, `Functor::method()` inappropriately triggers a
diagnostic that `outer()` is blocking by allocating memory.
```
void outer() [[clang::nonblocking]]
{
struct Functor {
int* ptr;
void method() { ptr = new int; }
};
}
```
---------
Co-authored-by: Doug Wyatt <[email protected]>
Copy file name to clipboardExpand all lines: clang/test/Sema/attr-nonblocking-constraints.cpp
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,25 @@ void nb8c()
104
104
};
105
105
}
106
106
107
+
voidnb8d() [[clang::nonblocking]]
108
+
{
109
+
// Blocking methods of a local CXXRecordDecl do not generate diagnostics
110
+
// for the outer function.
111
+
structF1 {
112
+
voidmethod() { void* ptr = newint; }
113
+
};
114
+
115
+
// Skipping the CXXRecordDecl does not skip a following VarDecl.
116
+
structF2 {
117
+
F2() { void* ptr = newint; } // expected-note {{constructor cannot be inferred 'nonblocking' because it allocates or deallocates memory}}
118
+
} f2; // expected-warning {{function with 'nonblocking' attribute must not call non-'nonblocking' constructor 'nb8d()::F2::F2'}}
119
+
120
+
// Nonblocking methods of a local CXXRecordDecl are verified independently.
121
+
structF3 {
122
+
voidmethod() [[clang::nonblocking]] { void* ptr = newint; }// expected-warning {{function with 'nonblocking' attribute must not allocate or deallocate memory}}
123
+
};
124
+
}
125
+
107
126
// Make sure template expansions are found and verified.
0 commit comments