1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Bug 402257 - Incorrect overload resolution with SFINAE and nested types

Change-Id: Id97160bcccaa0daaa7eaeab965cc74fe816adef5
Reviewed-on: https://git.eclipse.org/r/10811
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-03-03 19:59:26 -05:00 committed by Sergey Prigogin
parent 5eb0fb0451
commit f9f94676a2
2 changed files with 30 additions and 3 deletions

View file

@ -6945,7 +6945,32 @@ public class AST2TemplateTests extends AST2TestBase {
public void testSFINAEInDefaultArgument() throws Exception { public void testSFINAEInDefaultArgument() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// typedef char (&no_tag)[1];
// typedef char (&yes_tag)[2];
//
// template <typename T>
// struct type_wrapper {};
//
// template <typename T>
// struct has_type {
// template <typename U>
// static yes_tag test(type_wrapper<U> const volatile*, type_wrapper<typename U::type>* = 0);
//
// static no_tag test(...);
//
// static const bool value = sizeof(test(static_cast<type_wrapper<T>*>(0))) == sizeof(yes_tag);
// };
//
// const bool B = has_type<int>::value;
public void testSFINAEInNestedTypeInTemplateArgument_402257() throws Exception {
BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
ICPPVariable B = helper.assertNonProblem("B", ICPPVariable.class);
Long val = B.getInitialValue().numericalValue();
assertNotNull(val);
assertEquals(0 /* false */, val.longValue());
}
// template <typename> // template <typename>
// struct M { // struct M {
// template <typename... Args> // template <typename... Args>

View file

@ -2618,16 +2618,18 @@ public class CPPTemplates {
private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci, private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci,
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) {
ICPPClassTemplate classTemplate = dci.getClassTemplate();
ICPPTemplateArgument[] arguments = dci.getTemplateArguments(); ICPPTemplateArgument[] arguments = dci.getTemplateArguments();
ICPPTemplateArgument[] newArgs; ICPPTemplateArgument[] newArgs;
try { try {
newArgs = instantiateArguments(arguments, tpMap, packOffset, within, point, false); newArgs = instantiateArguments(arguments, tpMap, packOffset, within, point, true);
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
if (newArgs == null)
return createProblem(classTemplate, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point);
boolean changed= arguments != newArgs; boolean changed= arguments != newArgs;
ICPPClassTemplate classTemplate = dci.getClassTemplate();
IType classTemplateSpecialization= instantiateType(classTemplate, tpMap, packOffset, within, point); IType classTemplateSpecialization= instantiateType(classTemplate, tpMap, packOffset, within, point);
if (classTemplateSpecialization != classTemplate && classTemplateSpecialization instanceof ICPPClassTemplate) { if (classTemplateSpecialization != classTemplate && classTemplateSpecialization instanceof ICPPClassTemplate) {
classTemplate= (ICPPClassTemplate) classTemplateSpecialization; classTemplate= (ICPPClassTemplate) classTemplateSpecialization;