Skip to content

Commit 81acc83

Browse files
author
Doug Wyatt
committed
Add test for conflicting attribute on virtual override.
1 parent 4326b88 commit 81acc83

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,15 @@ void type_conversions_2()
127127
#endif
128128

129129
// --- VIRTUAL METHODS ---
130-
// Attributes propagate to overridden methods, so no diagnostics except for conflicts.
130+
// Attributes propagate to overridden methods.
131131
// Check this in the syntax tests too.
132132
#ifdef __cplusplus
133133
struct Base {
134134
virtual void f1();
135135
virtual void nonblocking() noexcept [[clang::nonblocking]]; // expected-note {{overridden virtual function is here}}
136136
virtual void nonallocating() noexcept [[clang::nonallocating]]; // expected-note {{overridden virtual function is here}}
137137
virtual void f2() [[clang::nonallocating]]; // expected-note {{previous declaration is here}}
138+
virtual void f3() [[clang::nonblocking]]; // expected-note {{overridden virtual function is here}}
138139
};
139140

140141
struct Derived : public Base {
@@ -143,6 +144,11 @@ struct Derived : public Base {
143144
void nonallocating() noexcept override; // expected-warning {{overriding function is missing 'nonallocating' attribute from base declaration}}
144145
void f2() [[clang::allocating]] override; // expected-warning {{effects conflict when merging declarations; kept 'allocating', discarded 'nonallocating'}}
145146
};
147+
148+
template <bool B>
149+
struct TDerived : public Base {
150+
void f3() [[clang::nonblocking(B)]] override; // expected-warning {{attribute 'nonblocking' on overriding function conflicts with base declaration}}
151+
};
146152
#endif // __cplusplus
147153

148154
// --- REDECLARATIONS ---

0 commit comments

Comments
 (0)