mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 561631 - Fix isFinal check for template specialization
Change-Id: Iac5b0d753c32f936e5d0e7ecdde66aeb0f7c6af8
This commit is contained in:
parent
a1ea26f817
commit
77790012cc
2 changed files with 49 additions and 0 deletions
|
@ -13502,6 +13502,51 @@ public class AST2CPPTests extends AST2CPPTestBase {
|
||||||
assertTrue(((CPPClassInstance) var3Spec.getType()).isNoDiscard());
|
assertTrue(((CPPClassInstance) var3Spec.getType()).isNoDiscard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//template <typename T>
|
||||||
|
//struct Foo {};
|
||||||
|
//template <typename T>
|
||||||
|
//struct Foo<T*> final {};
|
||||||
|
//template <>
|
||||||
|
//struct Foo<int> final {};
|
||||||
|
//
|
||||||
|
//Foo<double> var1;
|
||||||
|
//Foo<int*> var2;
|
||||||
|
//Foo<int> var3;
|
||||||
|
public void testFinalTemplateSpecialization_Bug561631() throws Exception {
|
||||||
|
String code = getAboveComment();
|
||||||
|
parseAndCheckBindings(code);
|
||||||
|
|
||||||
|
BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
|
||||||
|
|
||||||
|
CPPClassTemplate structFoo = bh.assertNonProblem("Foo {", 3);
|
||||||
|
assertFalse(structFoo.isFinal());
|
||||||
|
IASTNode fooDefinitionName = structFoo.getDefinition();
|
||||||
|
IASTNode fooDefinition = fooDefinitionName.getParent();
|
||||||
|
assertInstance(fooDefinition, ICPPASTCompositeTypeSpecifier.class);
|
||||||
|
assertFalse((((ICPPASTCompositeTypeSpecifier) fooDefinition)).isFinal());
|
||||||
|
|
||||||
|
CPPClassTemplatePartialSpecialization structSpec = bh.assertNonProblem("Foo<T*>", 7);
|
||||||
|
assertTrue(structSpec.isFinal());
|
||||||
|
IASTNode specDefinitionName = structSpec.getDefinition();
|
||||||
|
IASTNode specDefinition = specDefinitionName.getParent();
|
||||||
|
assertInstance(specDefinition, ICPPASTCompositeTypeSpecifier.class);
|
||||||
|
assertTrue((((ICPPASTCompositeTypeSpecifier) specDefinition)).isFinal());
|
||||||
|
|
||||||
|
CPPClassInstance structFullSpec = bh.assertNonProblem("Foo<int>", 8);
|
||||||
|
assertTrue(structSpec.isFinal());
|
||||||
|
IASTNode specFullDefinitionName = structFullSpec.getDefinition();
|
||||||
|
IASTNode specFullDefinition = specFullDefinitionName.getParent();
|
||||||
|
assertInstance(specFullDefinition, ICPPASTCompositeTypeSpecifier.class);
|
||||||
|
assertTrue((((ICPPASTCompositeTypeSpecifier) specFullDefinition)).isFinal());
|
||||||
|
|
||||||
|
CPPVariable var1Base = bh.assertNonProblem("var1", 4);
|
||||||
|
CPPVariable var2Spec = bh.assertNonProblem("var2", 4);
|
||||||
|
CPPVariable var3Spec = bh.assertNonProblem("var3", 4);
|
||||||
|
assertFalse(((CPPClassInstance) var1Base.getType()).isFinal());
|
||||||
|
assertTrue(((CPPClassInstance) var2Spec.getType()).isFinal());
|
||||||
|
assertTrue(((CPPClassInstance) var3Spec.getType()).isFinal());
|
||||||
|
}
|
||||||
|
|
||||||
// enum [[nodiscard]] hue { red, blue, green };
|
// enum [[nodiscard]] hue { red, blue, green };
|
||||||
// enum fruit { apple, banana };
|
// enum fruit { apple, banana };
|
||||||
// enum hue col;
|
// enum hue col;
|
||||||
|
|
|
@ -508,6 +508,10 @@ public class CPPClassSpecialization extends CPPSpecialization
|
||||||
if (typeSpecifier != null) {
|
if (typeSpecifier != null) {
|
||||||
return typeSpecifier.isFinal();
|
return typeSpecifier.isFinal();
|
||||||
}
|
}
|
||||||
|
ICPPClassType clazz = getSpecializedBinding();
|
||||||
|
if (clazz != null) {
|
||||||
|
return clazz.isFinal();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue