mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 419301 - Operator overloading confuses CDT (with boost)
Change-Id: I9f136577e8e64227d024ba6544017439f1ed2260 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/19833 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:
parent
dd7dde956f
commit
ebc858ec44
3 changed files with 69 additions and 11 deletions
|
@ -2403,4 +2403,55 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
IType T = getBindingFromASTName("T", 1);
|
IType T = getBindingFromASTName("T", 1);
|
||||||
assertEquals("int", ASTTypeUtil.getType(T));
|
assertEquals("int", ASTTypeUtil.getType(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <class T, class U>
|
||||||
|
// struct multipliable2
|
||||||
|
// {
|
||||||
|
// friend T operator *(const U& lhs, const T& rhs);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <class T>
|
||||||
|
// struct multipliable1
|
||||||
|
// {
|
||||||
|
// friend T operator *(const T& lhs, const T& rhs);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
|
// struct overloaded : multipliable1<overloaded> {};
|
||||||
|
//
|
||||||
|
// int foo(overloaded);
|
||||||
|
//
|
||||||
|
// int main()
|
||||||
|
// {
|
||||||
|
// overloaded c, d;
|
||||||
|
// foo(c * d);
|
||||||
|
// }
|
||||||
|
public void testFriendFunctionOfClassSpecialization_419301a() throws Exception {
|
||||||
|
checkBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// template <class T, class U>
|
||||||
|
// struct multipliable2
|
||||||
|
// {
|
||||||
|
// friend T operator *(const U& lhs, const T& rhs);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <class T>
|
||||||
|
// struct multipliable1
|
||||||
|
// {
|
||||||
|
// friend T operator *(const T& lhs, const T& rhs) {}
|
||||||
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
|
// struct overloaded : multipliable1 <overloaded> {};
|
||||||
|
//
|
||||||
|
// int foo(overloaded);
|
||||||
|
//
|
||||||
|
// int main() {
|
||||||
|
// overloaded c, d;
|
||||||
|
// foo(c * d);
|
||||||
|
// }
|
||||||
|
public void testFriendFunctionOfClassSpecialization_419301b() throws Exception {
|
||||||
|
checkBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,7 +367,9 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinding[] getFriends(IASTNode point) {
|
public IBinding[] getFriends(IASTNode point) {
|
||||||
// Not yet supported.
|
ICPPClassScope scope= getCompositeScope();
|
||||||
|
if (scope instanceof ICPPClassSpecializationScope)
|
||||||
|
return ((ICPPClassSpecializationScope) scope).getFriends(point);
|
||||||
return IBinding.EMPTY_BINDING_ARRAY;
|
return IBinding.EMPTY_BINDING_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
@ -1041,17 +1043,20 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (parentNode instanceof ICPPASTFunctionDeclarator) {
|
} else if (parentNode instanceof ICPPASTFunctionDeclarator) {
|
||||||
|
IASTDeclSpecifier declSpec = null;
|
||||||
if (parentNode.getParent() instanceof IASTSimpleDeclaration) {
|
if (parentNode.getParent() instanceof IASTSimpleDeclaration) {
|
||||||
IASTSimpleDeclaration grandparentNode = (IASTSimpleDeclaration) parentNode.getParent();
|
declSpec = ((IASTSimpleDeclaration) parentNode.getParent()).getDeclSpecifier();
|
||||||
if (grandparentNode.getDeclSpecifier() instanceof ICPPASTDeclSpecifier) {
|
} else if (parentNode.getParent() instanceof IASTFunctionDefinition) {
|
||||||
if (((ICPPASTDeclSpecifier) grandparentNode.getDeclSpecifier()).isFriend()) {
|
declSpec = ((IASTFunctionDefinition) parentNode.getParent()).getDeclSpecifier();
|
||||||
pdomName.setIsFriendSpecifier();
|
}
|
||||||
PDOMName enclClassName = (PDOMName) pdomName.getEnclosingDefinition();
|
if (declSpec instanceof ICPPASTDeclSpecifier) {
|
||||||
if (enclClassName != null) {
|
if (((ICPPASTDeclSpecifier) declSpec).isFriend()) {
|
||||||
PDOMBinding enclClassBinding = enclClassName.getBinding();
|
pdomName.setIsFriendSpecifier();
|
||||||
if (enclClassBinding instanceof PDOMCPPClassType) {
|
PDOMName enclClassName = (PDOMName) pdomName.getEnclosingDefinition();
|
||||||
((PDOMCPPClassType) enclClassBinding).addFriend(new PDOMCPPFriend(this, pdomName));
|
if (enclClassName != null) {
|
||||||
}
|
PDOMBinding enclClassBinding = enclClassName.getBinding();
|
||||||
|
if (enclClassBinding instanceof PDOMCPPClassType) {
|
||||||
|
((PDOMCPPClassType) enclClassBinding).addFriend(new PDOMCPPFriend(this, pdomName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue