-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[cling] Decls in an unnamed namespace cannot be looked up after a unload-load cycle #7483
Labels
Comments
jalopezg-git
changed the title
Cannot redefine entities in unnamed namespace
[cling] Decls in an unnamed namespace cannot be looked up after a unload-load cycle
Feb 28, 2022
jalopezg-git
added a commit
to jalopezg-git/root
that referenced
this issue
Feb 28, 2022
From SemaDeclCXX.cpp: ``` C++ [namespace.unnamed]p1. An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences of 'unique' in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program. ``` Thus, the first declaration of an unnamed namespace creates an implicit UsingDirectiveDecl that makes the names available in the parent DC. If we are reverting such first declaration, make sure we reset the anonymous namespace for the parent DeclContext so that the implicit UsingDirectiveDecl is created again when parsing the next anonymous namespace. Fixes issue root-project#7483.
jalopezg-git
added a commit
to jalopezg-git/root
that referenced
this issue
Feb 28, 2022
jalopezg-git
added a commit
to jalopezg-git/root
that referenced
this issue
Feb 28, 2022
From SemaDeclCXX.cpp: ``` C++ [namespace.unnamed]p1. An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences of 'unique' in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program. ``` Thus, the first declaration of an unnamed namespace creates an implicit UsingDirectiveDecl that makes the names available in the parent DC. If we are reverting such first declaration, make sure we reset the anonymous namespace for the parent DeclContext so that the implicit UsingDirectiveDecl is created again when parsing the next anonymous namespace. Fixes issue root-project#7483.
jalopezg-git
added a commit
to jalopezg-git/root
that referenced
this issue
Feb 28, 2022
Merged
1 task
jalopezg-git
added a commit
to jalopezg-git/root
that referenced
this issue
Feb 28, 2022
From SemaDeclCXX.cpp: ``` C++ [namespace.unnamed]p1. An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences of 'unique' in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program. ``` Thus, the first declaration of an unnamed namespace creates an implicit UsingDirectiveDecl that makes the names available in the parent DC. If we are reverting such first declaration, make sure we reset the anonymous namespace for the parent DeclContext so that the implicit UsingDirectiveDecl is created again when parsing the next anonymous namespace. Fixes issue root-project#7483.
jalopezg-git
added a commit
that referenced
this issue
Mar 1, 2022
From SemaDeclCXX.cpp: ``` C++ [namespace.unnamed]p1. An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences of 'unique' in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program. ``` Thus, the first declaration of an unnamed namespace creates an implicit UsingDirectiveDecl that makes the names available in the parent DC. If we are reverting such first declaration, make sure we reset the anonymous namespace for the parent DeclContext so that the implicit UsingDirectiveDecl is created again when parsing the next anonymous namespace. Fixes issue #7483.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
A definition in an unnamed namespace cannot be redeclared by re-running the same code.
Expected behavior
A new declaration is provided;
13
is printed twice.To Reproduce
Setup
ROOT master Ubuntu
The text was updated successfully, but these errors were encountered: