1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-22 00:15:25 +02:00

Bug 382074 - [C++11] Error involving variadic non-type template

parameters

Change-Id: I6f4e3672b4aca8e8ca878bccdec9c19a1838c74d
Reviewed-on: https://git.eclipse.org/r/9581
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Nathan Ridge 2013-01-29 14:54:20 -08:00 committed by Sergey Prigogin
parent 7112819c9b
commit 047a6f8f29
4 changed files with 31 additions and 10 deletions

View file

@ -7029,4 +7029,13 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(num);
assertEquals(1, num.longValue());
}
// template <int...> struct A {};
// template <int... I> void foo(A<I...>);
// int main() {
// foo(A<0>());
// }
public void testVariadicNonTypeTemplateParameter_382074() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Symbian Software Systems and others.
* Copyright (c) 2008, 2013 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Andrew Ferguson (Symbian) - Initial Implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
* Nathan Ridge
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -68,11 +69,17 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
name.setBinding(null);
namedTypeSpec.setName(name);
}
} else if (node instanceof IASTIdExpression) {
IASTIdExpression id= (IASTIdExpression) node;
final IASTName name = id.getName();
name.setBinding(null);
id.setName(name);
} else {
// Unwrap variadic pack expansion if necessary.
if (node instanceof ICPPASTPackExpansionExpression)
node= ((ICPPASTPackExpansionExpression) node).getPattern();
if (node instanceof IASTIdExpression) {
IASTIdExpression id= (IASTIdExpression) node;
final IASTName name = id.getName();
name.setBinding(null);
id.setName(name);
}
}
}

View file

@ -1,12 +1,13 @@
/*******************************************************************************
* Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
* Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
* Natan Ridge
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
@ -74,7 +76,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
} else {
type= new CPPParameterPackType(type);
}
fEvaluation= new EvalFixed(type, PRVALUE, Value.UNKNOWN);
fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
}
return fEvaluation;
}

View file

@ -2226,6 +2226,9 @@ public class CPPTemplates {
pType= instantiateType(pType, map, -1, null, point);
}
if (argType instanceof ICPPParameterPackType) {
argType = ((ICPPParameterPackType) argType).getType();
}
if (argType instanceof ICPPUnknownType) {
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
}