1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Bug 399039 - Error involving variadic non-type template parameter

Change-Id: I61b19e1fc5aac9372ad756c1e33e412f4bee86e2

Reviewed-on: https://git.eclipse.org/r/9943
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 16:22:40 -08:00 committed by Sergey Prigogin
parent d4cf62a785
commit 95c1231336
4 changed files with 59 additions and 4 deletions

View file

@ -7069,6 +7069,33 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <bool...>
// struct ice_or {
// static const bool value = false;
// };
// template <typename T>
// struct is_foo {
// static const bool value = false;
// };
// template <typename... Args>
// struct contains_foo {
// static const bool value = ice_or<is_foo<Args>::value...>::value;
// };
// template <bool>
// struct meta;
// struct S { void bar(); };
// template <>
// struct meta<false> {
// typedef S type;
// };
// int main() {
// meta<contains_foo<>::value>::type t;
// t.bar();
// }
public void testVariadicNonTypeTemplateParameter_399039() throws Exception {
parseAndCheckBindings();
}
// template <typename...> // template <typename...>
// struct common_type; // struct common_type;
// template <typename T> // template <typename T>

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. * Copyright (c) 2012, 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
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -84,7 +85,15 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
IASTNode point); IASTNode point);
/** /**
* Determines size of the template parameter pack. * Searches the evaluation for a usage of a template parameter which is a parameter pack,
* and returns the number of arguments bound to that parameter pack in the given
* template parameter map.
*
* Can also return one of the special values CPPTemplates.PACK_SIZE_DEFER,
* CPPTemplates.PACK_SIZE_FAIL, and CPPTemplates.PACK_SIZE_NOT_FOUND. See their
* declarations for their meanings.
*
* See also CPPTemplates.determinePackSize().
* *
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.
*/ */

View file

@ -162,9 +162,23 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMod
* type instantiation. * type instantiation.
*/ */
public class CPPTemplates { public class CPPTemplates {
// The three constants below are used as special return values for the various overloads
// of CPPTemplates.determinePackSize() and for ICPPEvaluation.determinePackSize(), which
// search a type, template argument, or value for a usage of a template parameter pack
// and return the number of arguments bound to that parameter pack in an
// ICPPTemplateParameterMap.
// Used to indicate that the parameter pack is not bound to any arguments in the
// template parameter map. Computation of the pack size needs to be deferred until
// arguments for it become available.
static final int PACK_SIZE_DEFER = -1; static final int PACK_SIZE_DEFER = -1;
// Used to indicate that two different packs with different sizes were found.
static final int PACK_SIZE_FAIL = -2; static final int PACK_SIZE_FAIL = -2;
// Used to indicate that no template parameter packs were found.
static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE; static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE } static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
/** /**

View file

@ -360,8 +360,13 @@ public class EvalID extends CPPEvaluation {
@Override @Override
public int determinePackSize(ICPPTemplateParameterMap tpMap) { public int determinePackSize(ICPPTemplateParameterMap tpMap) {
int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND; int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND;
for (ICPPTemplateArgument arg : fTemplateArgs) { if (fNameOwner instanceof ICPPUnknownBinding) {
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap)); r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize((ICPPUnknownBinding) fNameOwner, tpMap));
}
if (fTemplateArgs != null) {
for (ICPPTemplateArgument arg : fTemplateArgs) {
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
}
} }
return r; return r;
} }