Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,12 @@ Improvements to Clang's diagnostics
- Improve the diagnostics for placement new expression when const-qualified
object was passed as the storage argument. (#GH143708)

- Added a separate diagnostic group `-Wfunction-effect-redeclarations``, for the more pedantic
diagnostics for function effects (``[[clang::nonblocking]]`` and ``[[clang::nonallocating]]``).
Moved the warning for a missing (though implied) attribute on a redeclaration into this group.
Added a new warning in this group for the case where the attribute is missing/implicit on
an override of a virtual method.

Improvements to Clang's time-trace
----------------------------------

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18700,8 +18700,8 @@ bool Sema::CheckOverridingFunctionAttributes(CXXMethodDecl *New,
NewFT->getParamTypes(), EPI);
New->setType(ModQT);
if (Errs.empty()) {
// A warning here is somewhat pedantic. Skip this if there was already
// a merge conflict, which is more serious.
// A warning here is somewhat pedantic. Skip this if there was
// already a merge conflict, which is more serious.
Diag(New->getLocation(), diag::warn_mismatched_func_effect_override)
<< Diff.effectName();
Diag(Old->getLocation(), diag::note_overridden_virtual_function)
Expand Down
8 changes: 7 additions & 1 deletion clang/test/Sema/attr-nonblocking-sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ void type_conversions_2()
#endif

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

struct Derived : public Base {
Expand All @@ -143,6 +144,11 @@ struct Derived : public Base {
void nonallocating() noexcept override; // expected-warning {{overriding function is missing 'nonallocating' attribute from base declaration}}
void f2() [[clang::allocating]] override; // expected-warning {{effects conflict when merging declarations; kept 'allocating', discarded 'nonallocating'}}
};

template <bool B>
struct TDerived : public Base {
void f3() [[clang::nonblocking(B)]] override; // expected-warning {{attribute 'nonblocking' on overriding function conflicts with base declaration}}
};
#endif // __cplusplus

// --- REDECLARATIONS ---
Expand Down