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
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ Improvements to Clang's diagnostics
name was a reserved name, which we improperly allowed to suppress the
diagnostic.

- Clang now diagnoses [[deprecated]] attribute usage on local variables (#GH90073).

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

Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Sema/SemaAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ static bool ShouldDiagnoseAvailabilityInContext(
return false;
}

if (K == AR_Deprecated) {
if (const auto *VD = dyn_cast<VarDecl>(OffendingDecl))
if (VD->isLocalVarDecl() && VD->isDeprecated())
return true;
}

// Checks if we should emit the availability diagnostic in the context of C.
auto CheckContext = [&](const Decl *C) {
if (K == AR_NotYetIntroduced) {
Expand Down
14 changes: 14 additions & 0 deletions clang/test/SemaCXX/deprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,19 @@ namespace ArrayComp {
bool b7 = arr1 == +f();
}

namespace GH90073 {
[[deprecated]] int f() { // expected-note {{'f' has been explicitly marked deprecated here}}
[[deprecated]] int a; // expected-note {{'a' has been explicitly marked deprecated here}} \
// expected-note {{'a' has been explicitly marked deprecated here}}
a = 0; // expected-warning {{'a' is deprecated}}
return a; // expected-warning {{'a' is deprecated}}
}

int main() {
f(); // expected-warning {{'f' is deprecated}}
return 0;
}
}

# 1 "/usr/include/system-header.h" 1 3
void system_header_function(void) throw();
Loading