mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 363743: Default arg for non-type template parameter.
This commit is contained in:
parent
c83768bd6f
commit
adb6029e27
2 changed files with 24 additions and 1 deletions
|
@ -5605,4 +5605,15 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testNestedTemplateAmbiguity_363609() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// struct A {
|
||||
// void m() {}
|
||||
// };
|
||||
// template <class T, void (T::*m)() = &T::m> struct B {};
|
||||
// void test() {
|
||||
// B<A> b1;
|
||||
// }
|
||||
public void testDefaultArgForNonTypeTemplateParameter_363743() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
|
@ -40,6 +41,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTExpression getDefault() {
|
||||
IASTInitializerClause def= getDefaultClause();
|
||||
if (def instanceof IASTExpression) {
|
||||
|
@ -59,7 +61,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
IASTNode parent = name.getParent();
|
||||
assert parent instanceof IASTDeclarator;
|
||||
if (parent instanceof IASTDeclarator) {
|
||||
IASTDeclarator dtor = (IASTDeclarator) parent;
|
||||
IASTDeclarator dtor = ASTQueries.findOutermostDeclarator((IASTDeclarator) parent);
|
||||
IASTInitializer initializer = dtor.getInitializer();
|
||||
if (initializer instanceof IASTEqualsInitializer) {
|
||||
return ((IASTEqualsInitializer) initializer).getInitializerClause();
|
||||
|
@ -70,6 +72,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
IASTInitializerClause dc= getDefault();
|
||||
IASTExpression d= null;
|
||||
|
@ -96,6 +99,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
return new CPPTemplateArgument(val, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
if (type == null) {
|
||||
IASTNode parent= getPrimaryDeclaration().getParent();
|
||||
|
@ -110,28 +114,36 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParameterPack() {
|
||||
return getType() instanceof ICPPParameterPackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IValue getInitialValue() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean isExternC() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue