llvm / llvm/llvm-project

False positive deprecation and availability warnings on annotated `using` alias declarations

Open
#191,099 1 comment 0 reactions 0 assignees View on GitHub
clang:diagnostics false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When a `using` alias declaration is annotated with the same attribute as its aliased type, the compiler incorrectly warns that the aliased type is unavailable/deprecated.

```
// Deprecation
struct [[deprecated]] Foo {};
using Bar [[deprecated]] = Foo; // spurious: 'Foo' is deprecated
```

A natural use case is deprecating a chain of aliases together: if `Foo` and `Bar` were previously unannotated and you later decide to deprecate both, you should be able to annotate them without triggering warnings on the alias definitions themselves.

```
// Availability
using FeatureAlias __attribute__((availability(macosx, introduced=11.0))) = int;
using FeatureAlias2 __attribute__((availability(macosx, introduced=11.0))) = FeatureAlias; // spurious: 'FeatureAlias' is only available on macOS 11.0 or newer
```

In both cases the annotation on the `using` declaration should suppress the diagnostic.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the reported deprecation and availability snippets and confirm the diagnostics on the annotated using aliases. Trace the compiler's handling of attributes on using declarations and compare both cases. Done means the alias annotations suppress the warnings while unrelated availability or deprecation diagnostics remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.