Skip to content
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

clang accepts friend that g++/Comeau reject #12361

Closed
llvmbot opened this issue Feb 12, 2012 · 4 comments · Fixed by #91430
Closed

clang accepts friend that g++/Comeau reject #12361

llvmbot opened this issue Feb 12, 2012 · 4 comments · Fixed by #91430
Labels
accepts-invalid bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 12, 2012

Bugzilla Link 11989
Version 3.0
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@tkremenek

Extended Description

This code:

 class D {
     class E{
         class F{};
         friend  void foo1(D::E::F& q);
         };
     friend  void foo1(D::E::F& q);
     };

 void foo1(D::E::F& q) {}

 int main(int argc, char** argv) { return 0; }

is accepted by clang but rejected by g++ and Comeau. Gnu says they are right to reject (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52212), so I'm filing it with you. One of you guys is right; perhaps you can get together and agree who it is?

@tkremenek
Copy link
Contributor

cloned to rdar://problem/10869563

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@philnik777 philnik777 added clang:frontend Language frontend issues, e.g. anything involving "Sema" accepts-invalid labels Aug 15, 2023
@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 15, 2023

@llvm/issue-subscribers-clang-frontend

@widberg
Copy link

widberg commented Jan 8, 2024

This is still an issue. gcc 13.2 rejects the code while clang 17.0.1 and trunk (60c4f82) accept it. https://godbolt.org/z/3oje3KbeW

@Endilll
Copy link
Contributor

Endilll commented Jan 8, 2024

EDG, GCC, and MSVC agree that F is not accessible in the second friend declaration: https://godbolt.org/z/9xTb6WP7T
But I wonder if their conclusion still holds against post-P1787 wording. That said, this paper doesn't seem to have changed much for qualified name lookup in friend declarations, but this is not an observation made with confidence.

@Endilll Endilll added the confirmed Verified by a second party label Jan 8, 2024
jcsxky added a commit that referenced this issue May 10, 2024
…ayed (#91430)

attempt to fix #12361
Consider this example:
```cpp
class D {
    class E{
        class F{};
        friend  void foo(D::E::F& q);
        };
    friend  void foo(D::E::F& q);
    };

void foo(D::E::F& q) {}
```
The first friend declaration of foo is correct. After that, the second
friend declaration delayed access checking and set its previous
declaration to be the first one. When doing access checking of `F`(which
is private filed of `E`), we put its canonical declaration(the first
friend declaration) into `EffectiveContext.Functions`. Actually, we are
still checking the first one. This is incorrect due to the delayed
checking.
Creating a new scope to indicate we are parsing a friend declaration and
doing access checking in time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts-invalid bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants