mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 399145 - Point of declaration of template parameter
Change-Id: Ib5b192758d413ab1ac5116243ac2e4a7f7c7951c Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/32213 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
905d722c3e
commit
83600a15dc
2 changed files with 38 additions and 1 deletions
|
@ -8515,4 +8515,26 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testConstexprFunctionCallWithNonConstexprArguments_429891() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename> class A {};
|
||||
// template <int> class B {};
|
||||
// const int D = 4;
|
||||
//
|
||||
// // Type template parameter
|
||||
// template <typename A = A<int>>
|
||||
// struct C1 {};
|
||||
// C1<> c1;
|
||||
//
|
||||
// // Template template parameter
|
||||
// template <template <typename> class A = A>
|
||||
// struct C2 { typedef A<int> type; };
|
||||
// C2<>::type c2;
|
||||
//
|
||||
// // Non-type template parameter
|
||||
// template <int D = D>
|
||||
// struct C3 { typedef B<D> type; };
|
||||
// C3<>::type c3;
|
||||
public void testNameLookupInDefaultTemplateArgument_399145() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1906,7 +1906,13 @@ public class CPPSemantics {
|
|||
while (dtor.getParent() instanceof IASTDeclarator)
|
||||
dtor = (IASTDeclarator) dtor.getParent();
|
||||
IASTInitializer init = dtor.getInitializer();
|
||||
if (init != null)
|
||||
// [basic.scope.pdecl]/p9: The point of declaration for a template parameter
|
||||
// is immediately after its complete template-parameter.
|
||||
// Note: can't just check "dtor.getParent() instanceof ICPPASTTemplateParameter"
|
||||
// because function parameter declarations implement ICPPASTTemplateParameter too.
|
||||
boolean isTemplateParameter = dtor.getParent() instanceof ICPPASTTemplateParameter
|
||||
&& dtor.getParent().getPropertyInParent() == ICPPASTTemplateDeclaration.PARAMETER;
|
||||
if (init != null && !isTemplateParameter)
|
||||
pointOfDecl = ((ASTNode) init).getOffset() - 1;
|
||||
else
|
||||
pointOfDecl = ((ASTNode) dtor).getOffset() + ((ASTNode) dtor).getLength();
|
||||
|
@ -1926,6 +1932,15 @@ public class CPPSemantics {
|
|||
} else if (prop == ICPPASTNamespaceAlias.ALIAS_NAME) {
|
||||
nd = (ASTNode) nd.getParent();
|
||||
pointOfDecl = nd.getOffset() + nd.getLength();
|
||||
} else if (prop == ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME
|
||||
|| prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER_NAME) {
|
||||
// [basic.scope.pdecl]/p9: The point of declaration for a template parameter
|
||||
// is immediately after its complete template-parameter.
|
||||
// Type and template template parameters are handled here;
|
||||
// non-type template parameters are handled in the DECLARATOR_NAME
|
||||
// case above.
|
||||
nd = (ASTNode) nd.getParent();
|
||||
pointOfDecl = nd.getOffset() + nd.getLength();
|
||||
} else {
|
||||
pointOfDecl = nd.getOffset() + nd.getLength();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue