llvm / llvm/llvm-project

Clang accepts non-conforming [[deprecated]] attribute with parenthesized string literal

Open
#176,128 5 comments 0 reactions 0 assignees View on GitHub
accepts-invalid clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

**What code / commands /steps will reproduce the problem?**
Compile the below sample code for clang std c++17.

```c++
[[deprecated(("Use still allowed, but discouraged"))]] int a = 13;
int main() {}
```

**Compiler Explorer link:**
https://godbolt.org/z/eYWWGjsjM

**What is the expected result?**
As per C++17 standard,

_The attribute-token deprecated can be used to mark names and entities whose use is still allowed, but is
discouraged for some reason. [ Note: In particular, deprecated is appropriate for names and entities that
are deemed obsolescent or unsafe. — end note ] It shall appear at most once in each attribute-list. An
attribute-argument-clause may be present and, if present, it shall have the form:
( string-literal )
[ Note: The string-literal in the attribute-argument-clause could be used to explain the rationale for deprecation
and/or to suggest a replacing entity. — end note ]_

So, to meet the C++17 standard, Clang should throw diagnostic warning or error.

**What happens instead?**

Both Clang and GCC accept code, and do not emit any diagnostic warning or error. This does not conform to the C++17 standard.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.