Skip to content

[clang] Availability attribute only triggers on the second use of a variable #61815

@ldionne

Description

@ldionne
cat <<EOF | clang++ -xc++ - -fsyntax-only
template <class _ValueType = int>
class __attribute__((unavailable)) polymorphic_allocator { };

void f() {
    polymorphic_allocator<void> a;
    polymorphic_allocator<void> b;
}
EOF

This fails with:

<stdin>:6:5: error: 'polymorphic_allocator<void>' is unavailable
    polymorphic_allocator<void> b;
    ^
<stdin>:2:36: note: 'polymorphic_allocator<void>' has been explicitly marked unavailable here
class __attribute__((unavailable)) polymorphic_allocator { };
                                   ^
1 error generated.

In reality, it should have failed on the first usage of polymorphic_allocator<void>, which is when declaring a.

Also on Godbolt: https://godbolt.org/z/aEsfjcdT1

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions