mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Allow binary operator templates
This commit is contained in:
parent
385b915257
commit
3fdea6e31a
2 changed files with 20 additions and 3 deletions
|
@ -4221,6 +4221,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
|
|||
helper.assertVariableValue("greater10", 1);
|
||||
}
|
||||
|
||||
// template<typename T1, typename T2>
|
||||
// constexpr int operator |(T1 t1, T2 t2) {
|
||||
// return t1 + t2;
|
||||
// }
|
||||
//
|
||||
// enum X {
|
||||
// V1 = 17,
|
||||
// V2 = 25,
|
||||
// };
|
||||
//
|
||||
// constexpr auto value = V1 | V2;
|
||||
public void testBinaryOperatorOverloadTemplate() throws Exception {
|
||||
BindingAssertionHelper helper = getAssertionHelper(CPP);
|
||||
helper.assertVariableValue("value", 42);
|
||||
}
|
||||
|
||||
// typedef int I;
|
||||
// typedef int I;
|
||||
// typedef I I;
|
||||
|
|
|
@ -4099,9 +4099,10 @@ public class CPPSemantics {
|
|||
ICPPFunctionType ft = func.getType();
|
||||
IType[] pts = ft.getParameterTypes();
|
||||
if ((enum1 != null && pts.length > 0
|
||||
&& enum1.isSameType(getUltimateTypeUptoPointers(pts[0])))
|
||||
|| (enum2 != null && pts.length > 1
|
||||
&& enum2.isSameType(getUltimateTypeUptoPointers(pts[1])))) {
|
||||
&& (CPPTemplates.isDependentType(pts[0])
|
||||
|| enum1.isSameType(getUltimateTypeUptoPointers(pts[0]))))
|
||||
|| (enum2 != null && pts.length > 1 && (CPPTemplates.isDependentType(pts[1])
|
||||
|| enum2.isSameType(getUltimateTypeUptoPointers(pts[1]))))) {
|
||||
items[j++] = object;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue