Skip to content

Commit 27e93eb

Browse files
author
Doug Wyatt
committed
more tests
1 parent a24d2f4 commit 27e93eb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clang/test/Sema/attr-nonblocking-constraints.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,19 @@ void nb8d() [[clang::nonblocking]]
108108
{
109109
// Blocking methods of a local CXXRecordDecl do not generate diagnostics
110110
// for the outer function.
111-
struct Functor1 {
111+
struct F1 {
112112
void method() { void* ptr = new int; }
113113
};
114+
115+
// Skipping the CXXRecordDecl does not skip a following VarDecl.
116+
struct F2 {
117+
F2() { void* ptr = new int; } // 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+
struct F3 {
122+
void method() [[clang::nonblocking]] { void* ptr = new int; }// expected-warning {{function with 'nonblocking' attribute must not allocate or deallocate memory}}
123+
};
114124
}
115125

116126
// Make sure template expansions are found and verified.

0 commit comments

Comments
 (0)