mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 483824 - Inline namespace reopened without inline keyword
Change-Id: Ia2e15b31356c2e2a2ab53ed6fd76138177ed40bb
This commit is contained in:
parent
bfea9deb90
commit
eb795e9518
3 changed files with 24 additions and 2 deletions
|
@ -1758,6 +1758,20 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
assertEquals("void (char)", ASTTypeUtil.getType(ref.getType()));
|
assertEquals("void (char)", ASTTypeUtil.getType(ref.getType()));
|
||||||
getBindingFromASTName("g(1)", 1);
|
getBindingFromASTName("g(1)", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// namespace std {
|
||||||
|
// inline namespace __cxx11 { }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// namespace std {
|
||||||
|
// namespace __cxx11 {
|
||||||
|
// class string {};
|
||||||
|
// }
|
||||||
|
// void regex_match(string); // Type 'string' could not be resolved
|
||||||
|
// }
|
||||||
|
public void testInlineNamespaceReopenedWithoutInlineKeyword_483824() {
|
||||||
|
checkBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// namespace ns {
|
// namespace ns {
|
||||||
// void fun();
|
// void fun();
|
||||||
|
|
|
@ -307,8 +307,8 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
||||||
@Override
|
@Override
|
||||||
public final void populateCache() {
|
public final void populateCache() {
|
||||||
if (!isCached) {
|
if (!isCached) {
|
||||||
|
isCached= true; // set to true before doing the work, to avoid recursion
|
||||||
CPPSemantics.populateCache(this);
|
CPPSemantics.populateCache(this);
|
||||||
isCached= true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1612,7 +1612,15 @@ public class CPPSemantics {
|
||||||
} else if (item instanceof ICPPASTNamespaceDefinition) {
|
} else if (item instanceof ICPPASTNamespaceDefinition) {
|
||||||
final ICPPASTNamespaceDefinition nsDef = (ICPPASTNamespaceDefinition) item;
|
final ICPPASTNamespaceDefinition nsDef = (ICPPASTNamespaceDefinition) item;
|
||||||
final boolean isUnnamed = nsDef.getName().getLookupKey().length == 0;
|
final boolean isUnnamed = nsDef.getName().getLookupKey().length == 0;
|
||||||
final boolean isInline = nsDef.isInline();
|
boolean isInline = nsDef.isInline();
|
||||||
|
// An inline namespace can be re-opened without repeating the inline keyword,
|
||||||
|
// so we need to consult the binding to check inlineness.
|
||||||
|
if (!isUnnamed && !isInline) {
|
||||||
|
IBinding nsBinding = nsDef.getName().resolveBinding();
|
||||||
|
if (nsBinding instanceof ICPPNamespace) {
|
||||||
|
isInline = ((ICPPNamespace) nsBinding).isInline();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isUnnamed || isInline) {
|
if (isUnnamed || isInline) {
|
||||||
if (scope instanceof CPPNamespaceScope) {
|
if (scope instanceof CPPNamespaceScope) {
|
||||||
final CPPNamespaceScope nsscope = (CPPNamespaceScope) scope;
|
final CPPNamespaceScope nsscope = (CPPNamespaceScope) scope;
|
||||||
|
|
Loading…
Add table
Reference in a new issue