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 {
|
public void testNestedTemplateAmbiguity_363609() throws Exception {
|
||||||
parseAndCheckBindings();
|
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.ICPPParameterPackType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
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.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTExpression getDefault() {
|
public IASTExpression getDefault() {
|
||||||
IASTInitializerClause def= getDefaultClause();
|
IASTInitializerClause def= getDefaultClause();
|
||||||
if (def instanceof IASTExpression) {
|
if (def instanceof IASTExpression) {
|
||||||
|
@ -59,7 +61,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||||
IASTNode parent = name.getParent();
|
IASTNode parent = name.getParent();
|
||||||
assert parent instanceof IASTDeclarator;
|
assert parent instanceof IASTDeclarator;
|
||||||
if (parent instanceof IASTDeclarator) {
|
if (parent instanceof IASTDeclarator) {
|
||||||
IASTDeclarator dtor = (IASTDeclarator) parent;
|
IASTDeclarator dtor = ASTQueries.findOutermostDeclarator((IASTDeclarator) parent);
|
||||||
IASTInitializer initializer = dtor.getInitializer();
|
IASTInitializer initializer = dtor.getInitializer();
|
||||||
if (initializer instanceof IASTEqualsInitializer) {
|
if (initializer instanceof IASTEqualsInitializer) {
|
||||||
return ((IASTEqualsInitializer) initializer).getInitializerClause();
|
return ((IASTEqualsInitializer) initializer).getInitializerClause();
|
||||||
|
@ -70,6 +72,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ICPPTemplateArgument getDefaultValue() {
|
public ICPPTemplateArgument getDefaultValue() {
|
||||||
IASTInitializerClause dc= getDefault();
|
IASTInitializerClause dc= getDefault();
|
||||||
IASTExpression d= null;
|
IASTExpression d= null;
|
||||||
|
@ -96,6 +99,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||||
return new CPPTemplateArgument(val, t);
|
return new CPPTemplateArgument(val, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
IASTNode parent= getPrimaryDeclaration().getParent();
|
IASTNode parent= getPrimaryDeclaration().getParent();
|
||||||
|
@ -110,28 +114,36 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isParameterPack() {
|
public boolean isParameterPack() {
|
||||||
return getType() instanceof ICPPParameterPackType;
|
return getType() instanceof ICPPParameterPackType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isExternC() {
|
public boolean isExternC() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue