-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong specialization becomes friend as checked by requires-expression #53364
Labels
c++20
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
concepts
C++20 concepts
Comments
zero9178
added
c++20
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
concepts
C++20 concepts
and removed
new issue
labels
Jan 23, 2022
@llvm/issue-subscribers-c-20 |
@llvm/issue-subscribers-clang-frontend |
CarlosAlbertoEnciso
pushed a commit
to SNSystems/llvm-debuginfo-analyzer
that referenced
this issue
Jan 12, 2023
> Dependent access checks. Fixes: llvm/llvm-project#53364 We previously ignored dependent access checks to private members. These are visible only to the `RequiresExprBodyExpr` (through `PerformDependentDiagnositcs`) and not to the individual requirements. --- > Non-dependent access checks. Fixes: llvm/llvm-project#53334 Access to members in a non-dependent context would always yield an invalid expression. When it appears in a requires-expression, then this is a hard error as this would always result in a substitution failure. https://eel.is/c++draft/expr.prim.req#general-note-1 > Note 1: If a requires-expression contains invalid types or expressions in its requirements, and it does not appear within the declaration of a templated entity, then the program is ill-formed. — end note] > If the substitution of template arguments into a requirement would always result in a substitution failure, the program is ill-formed; no diagnostic required. The main issue here is the delaying of the diagnostics. Use a `ParsingDeclRAIIObject` creates a separate diagnostic pool for diagnositcs associated to the `RequiresExprBodyDecl`. This is important because dependent diagnostics should not be leaked/delayed to higher scopes (Eg. inside a template function or in a trailing requires). These dependent diagnostics must be attached to the `DeclContext` of the parameters of `RequiresExpr` (which is the `RequiresExprBodyDecl` in this case). Non dependent diagnostics, on the other hand, should not delayed and surfaced as hard errors. Differential Revision: https://reviews.llvm.org/D140547
veselypeta
pushed a commit
to veselypeta/cherillvm
that referenced
this issue
Jun 12, 2024
> Dependent access checks. Fixes: llvm/llvm-project#53364 We previously ignored dependent access checks to private members. These are visible only to the `RequiresExprBodyExpr` (through `PerformDependentDiagnositcs`) and not to the individual requirements. --- > Non-dependent access checks. Fixes: llvm/llvm-project#53334 Access to members in a non-dependent context would always yield an invalid expression. When it appears in a requires-expression, then this is a hard error as this would always result in a substitution failure. https://eel.is/c++draft/expr.prim.req#general-note-1 > Note 1: If a requires-expression contains invalid types or expressions in its requirements, and it does not appear within the declaration of a templated entity, then the program is ill-formed. — end note] > If the substitution of template arguments into a requirement would always result in a substitution failure, the program is ill-formed; no diagnostic required. The main issue here is the delaying of the diagnostics. Use a `ParsingDeclRAIIObject` creates a separate diagnostic pool for diagnositcs associated to the `RequiresExprBodyDecl`. This is important because dependent diagnostics should not be leaked/delayed to higher scopes (Eg. inside a template function or in a trailing requires). These dependent diagnostics must be attached to the `DeclContext` of the parameters of `RequiresExpr` (which is the `RequiresExprBodyDecl` in this case). Non dependent diagnostics, on the other hand, should not delayed and surfaced as hard errors. Differential Revision: https://reviews.llvm.org/D140547
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c++20
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
concepts
C++20 concepts
In the following code, there is template
struct A
with not-type template argument, andclass B
declaresA<0>
as its friend. Then the member functionA<x>::has_access()
is used to check that it has access to privateB::p()
:And in Clang
A<1>
gets access to private fields ofB
. Not so in other compilers. Demo: https://gcc.godbolt.org/z/f7qPo6fnjRelated discussion: https://stackoverflow.com/q/70812488/7325599
The text was updated successfully, but these errors were encountered: