mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 03:35:37 +02:00
Bug 401400 - Another error involving variadic non-type template
parameters Change-Id: Ic5c64de6d32a203d13274053da61923d9d8e2ad3 Reviewed-on: https://git.eclipse.org/r/10559 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
895e0aa394
commit
f0a597bc2b
4 changed files with 40 additions and 1 deletions
|
@ -7312,4 +7312,26 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testVariadicNonTypeTemplateParameter_401142() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <bool... Args>
|
||||
// struct ice_or;
|
||||
// template <>
|
||||
// struct ice_or<> {
|
||||
// static const bool value = false;
|
||||
// };
|
||||
// template <bool First, bool... Rest>
|
||||
// struct ice_or<First, Rest...> {
|
||||
// static const bool value = ice_or<Rest...>::value;
|
||||
// };
|
||||
// template <bool> struct S {};
|
||||
// template <>
|
||||
// struct S<false> {
|
||||
// typedef int type;
|
||||
// };
|
||||
// int main() {
|
||||
// S<ice_or<false, false>::value>::type t;
|
||||
// }
|
||||
public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,15 @@ public interface ICPPTemplateParameterMap {
|
|||
*/
|
||||
public ICPPTemplateArgument[] getPackExpansion(ICPPTemplateParameter param);
|
||||
|
||||
/**
|
||||
* If 'param' is not a parameter pack, returns the value for 'param' in the map.
|
||||
* If 'param' is a parmameter pack, returns the value at position 'packOffset'
|
||||
* in the pack of values for 'param' in the map.
|
||||
* Returns <code>null</code> is 'param' is not mapped.
|
||||
* @since 5.5
|
||||
*/
|
||||
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param, int packOffset);
|
||||
|
||||
/**
|
||||
* Returns the array of template parameter positions, for which a mapping exists.
|
||||
*/
|
||||
|
|
|
@ -114,6 +114,7 @@ public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument getArgument(ICPPTemplateParameter tpar, int packOffset) {
|
||||
return getArgument(tpar.getParameterID(), packOffset);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
|
@ -246,6 +247,12 @@ public class EvalBinding extends CPPDependentEvaluation {
|
|||
}
|
||||
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||
// If the binding is a non-type parameter pack, it must have been
|
||||
// referenced from inside the expansion pattern of a pack expansion.
|
||||
// In such a context, the type of the binding is the type of each
|
||||
// parameter in the parameter pack, not the type of the pack itself.
|
||||
if (type instanceof ICPPParameterPackType)
|
||||
type = ((ICPPParameterPackType) type).getType();
|
||||
return prvalueType(type);
|
||||
}
|
||||
if (binding instanceof IVariable) {
|
||||
|
@ -329,7 +336,7 @@ public class EvalBinding extends CPPDependentEvaluation {
|
|||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IBinding origBinding = getBinding();
|
||||
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding);
|
||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
|
||||
if (argument != null && argument.isNonTypeValue()) {
|
||||
return argument.getNonTypeEvaluation();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue