mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 16:05: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:
parent
7112819c9b
commit
047a6f8f29
4 changed files with 31 additions and 10 deletions
|
@ -7029,4 +7029,13 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
assertNotNull(num);
|
assertNotNull(num);
|
||||||
assertEquals(1, num.longValue());
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Andrew Ferguson (Symbian) - Initial Implementation
|
* Andrew Ferguson (Symbian) - Initial Implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -68,11 +69,17 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
|
||||||
name.setBinding(null);
|
name.setBinding(null);
|
||||||
namedTypeSpec.setName(name);
|
namedTypeSpec.setName(name);
|
||||||
}
|
}
|
||||||
} else if (node instanceof IASTIdExpression) {
|
} else {
|
||||||
IASTIdExpression id= (IASTIdExpression) node;
|
// Unwrap variadic pack expansion if necessary.
|
||||||
final IASTName name = id.getName();
|
if (node instanceof ICPPASTPackExpansionExpression)
|
||||||
name.setBinding(null);
|
node= ((ICPPASTPackExpansionExpression) node).getPattern();
|
||||||
id.setName(name);
|
|
||||||
|
if (node instanceof IASTIdExpression) {
|
||||||
|
IASTIdExpression id= (IASTIdExpression) node;
|
||||||
|
final IASTName name = id.getName();
|
||||||
|
name.setBinding(null);
|
||||||
|
id.setName(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Natan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
@ -74,7 +76,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
|
||||||
} else {
|
} else {
|
||||||
type= new CPPParameterPackType(type);
|
type= new CPPParameterPackType(type);
|
||||||
}
|
}
|
||||||
fEvaluation= new EvalFixed(type, PRVALUE, Value.UNKNOWN);
|
fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
|
||||||
}
|
}
|
||||||
return fEvaluation;
|
return fEvaluation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2226,6 +2226,9 @@ public class CPPTemplates {
|
||||||
pType= instantiateType(pType, map, -1, null, point);
|
pType= instantiateType(pType, map, -1, null, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argType instanceof ICPPParameterPackType) {
|
||||||
|
argType = ((ICPPParameterPackType) argType).getType();
|
||||||
|
}
|
||||||
if (argType instanceof ICPPUnknownType) {
|
if (argType instanceof ICPPUnknownType) {
|
||||||
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
|
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue