mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 332884: Partial specializations of class template specializations.
This commit is contained in:
parent
aa9690322b
commit
7372454012
4 changed files with 49 additions and 33 deletions
|
@ -1795,4 +1795,42 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertTrue(reference instanceof ICPPSpecialization);
|
||||
}
|
||||
|
||||
// template <typename T = int> class enclosing {
|
||||
// template <typename P1, typename P2, bool P1_matches, bool P2_matches>
|
||||
// struct sort_out_types_impl;
|
||||
// template <typename P1, typename P2> struct sort_out_types_impl<P1, P2, true, false> {
|
||||
// typedef P1 matching_type;
|
||||
// };
|
||||
// template <typename P1, typename P2> struct sort_out_types_impl<P1, P2, false, true> {
|
||||
// typedef P2 matching_type;
|
||||
// };
|
||||
// };
|
||||
|
||||
// template <typename P1, typename P2, template <typename> class Predicate>
|
||||
// struct sort_out_types {
|
||||
// static const bool P1_matches = Predicate<P1>::value;
|
||||
// static const bool P2_matches = Predicate<P2>::value;
|
||||
// typedef typename enclosing<>::sort_out_types_impl<P1, P2, P1_matches, P2_matches>::matching_type matching_type;
|
||||
// };
|
||||
// template <typename T> struct type_predicate {
|
||||
// static const bool value = false;
|
||||
// };
|
||||
// template <> struct type_predicate<int> {
|
||||
// static const bool value = true;
|
||||
// };
|
||||
// template <typename P1, typename P2> struct A {
|
||||
// typedef typename sort_out_types<P1, P2, type_predicate>::matching_type arg_type;
|
||||
// void f(arg_type);
|
||||
// };
|
||||
// int main() {
|
||||
// A<float, int> a;
|
||||
// a.f(0);
|
||||
// return 0;
|
||||
// }
|
||||
public void testPartialSpecializationsOfClassTemplateSpecializations_332884() throws Exception {
|
||||
final IBinding reference = getBindingFromASTName("f(0)", 1);
|
||||
assertTrue(reference instanceof ICPPSpecialization);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -202,10 +202,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 111.1 - defaulted and deleted functions, bug 305978
|
||||
* 112.0 - inline namespaces, bug 305980
|
||||
* 113.0 - Changed marshaling of values, bug 327878
|
||||
* 114.0 - Partial specializations for class template specializations, bug 332884.
|
||||
*/
|
||||
private static final int MIN_SUPPORTED_VERSION= version(113, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(113, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(113, 0);
|
||||
private static final int MIN_SUPPORTED_VERSION= version(114, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(114, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(114, 0);
|
||||
|
||||
private static int version(int major, int minor) {
|
||||
return (major << 16) + minor;
|
||||
|
|
|
@ -47,7 +47,6 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
|
|||
super(linkage, parent, partial, specialized);
|
||||
|
||||
getDB().putRecPtr(record + PRIMARY_TEMPLATE, primary.getRecord());
|
||||
primary.addPartial(this);
|
||||
|
||||
linkage.new ConfigurePartialSpecialization(this, partial);
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
|
@ -45,9 +42,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
|
||||
implements ICPPClassTemplate, ICPPInstanceCache {
|
||||
|
||||
private static final int FIRST_PARTIAL = PDOMCPPClassSpecialization.RECORD_SIZE;
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE+4;
|
||||
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE;
|
||||
|
||||
public PDOMCPPClassTemplateSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
|
||||
throws CoreException {
|
||||
|
@ -161,32 +157,14 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
|
|||
}
|
||||
}
|
||||
|
||||
private PDOMCPPClassTemplatePartialSpecializationSpecialization getFirstPartial() throws CoreException {
|
||||
long value = getDB().getRecPtr(record + FIRST_PARTIAL);
|
||||
return value != 0 ? new PDOMCPPClassTemplatePartialSpecializationSpecialization(getLinkage(), value) : null;
|
||||
}
|
||||
|
||||
public void addPartial(PDOMCPPClassTemplatePartialSpecializationSpecialization pspecspec) throws CoreException {
|
||||
PDOMCPPClassTemplatePartialSpecializationSpecialization first = getFirstPartial();
|
||||
pspecspec.setNextPartial(first);
|
||||
getDB().putRecPtr(record + FIRST_PARTIAL, pspecspec.getRecord());
|
||||
}
|
||||
|
||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
|
||||
try {
|
||||
ArrayList<PDOMCPPClassTemplatePartialSpecializationSpecialization> partials =
|
||||
new ArrayList<PDOMCPPClassTemplatePartialSpecializationSpecialization>();
|
||||
for (PDOMCPPClassTemplatePartialSpecializationSpecialization partial = getFirstPartial();
|
||||
partial != null;
|
||||
partial = partial.getNextPartial()) {
|
||||
partials.add(partial);
|
||||
}
|
||||
|
||||
return partials.toArray(new PDOMCPPClassTemplatePartialSpecializationSpecialization[partials.size()]);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new PDOMCPPClassTemplatePartialSpecializationSpecialization[0];
|
||||
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
|
||||
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
|
||||
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
|
||||
for (int i = 0; i < orig.length; i++) {
|
||||
spec[i]= (ICPPClassTemplatePartialSpecialization) specializeMember(orig[i]);
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
|
||||
|
|
Loading…
Add table
Reference in a new issue