File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -424,6 +424,8 @@ Improvements to Clang's diagnostics
424424 name was a reserved name, which we improperly allowed to suppress the
425425 diagnostic.
426426
427+ - Clang now diagnoses ``[[deprecated]] `` attribute usage on local variables (#GH90073).
428+
427429Improvements to Clang's time-trace
428430----------------------------------
429431
Original file line number Diff line number Diff line change @@ -182,6 +182,12 @@ static bool ShouldDiagnoseAvailabilityInContext(
182182 return false ;
183183 }
184184
185+ if (K == AR_Deprecated) {
186+ if (const auto *VD = dyn_cast<VarDecl>(OffendingDecl))
187+ if (VD->isLocalVarDeclOrParm () && VD->isDeprecated ())
188+ return true ;
189+ }
190+
185191 // Checks if we should emit the availability diagnostic in the context of C.
186192 auto CheckContext = [&](const Decl *C) {
187193 if (K == AR_NotYetIntroduced) {
Original file line number Diff line number Diff line change @@ -260,5 +260,25 @@ namespace ArrayComp {
260260 bool b7 = arr1 == +f();
261261}
262262
263+ namespace GH90073 {
264+ [[deprecated]] int f1 () { // expected-note {{'f1' has been explicitly marked deprecated here}}
265+ [[deprecated]] int a; // expected-note {{'a' has been explicitly marked deprecated here}} \
266+ // expected-note {{'a' has been explicitly marked deprecated here}}
267+ a = 0 ; // expected-warning {{'a' is deprecated}}
268+ return a; // expected-warning {{'a' is deprecated}}
269+ }
270+
271+ [[deprecated]] void f2 ([[deprecated]] int x) { // expected-note {{'f2' has been explicitly marked deprecated here}} \
272+ // expected-note {{'x' has been explicitly marked deprecated here}}
273+ x = 4 ; // expected-warning {{'x' is deprecated}}
274+ }
275+
276+ int main () {
277+ f1 (); // expected-warning {{'f1' is deprecated}}
278+ f2 (1 ); // expected-warning {{'f2' is deprecated}}
279+ return 0 ;
280+ }
281+ }
282+
263283# 1 " /usr/include/system-header.h" 1 3
264284void system_header_function (void ) throw();
You can’t perform that action at this time.
0 commit comments