mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Bug 484619 - Make sure ProblemBindingChecker reports unresolved
user-defined literal operators Change-Id: Idbb157c33b3aae06a00a10f7e7836e96db9f9b63 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
8ceb33a1fc
commit
59de5c303f
3 changed files with 20 additions and 2 deletions
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -245,6 +246,9 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker {
|
|||
}
|
||||
} else if (parentNode instanceof ICPPASTDeclarator && name instanceof IASTImplicitName) {
|
||||
return true;
|
||||
} else if (parentNode instanceof ICPPASTLiteralExpression && name instanceof IASTImplicitName) {
|
||||
// Implicit name for user-defined literal operator.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -95,4 +95,18 @@ public class ProblemBindingCheckerTest extends CheckerTestCase {
|
|||
IMarker marker = checkErrorLine(3, ProblemBindingChecker.ERR_ID_FunctionResolutionProblem);
|
||||
assertFalse(marker.getAttribute(IMarker.MESSAGE, "").contains("MACRO")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
// auto d = 42_waldo;
|
||||
public void testNonexistentUDLOperator_484619() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLine(1, ProblemBindingChecker.ERR_ID_FunctionResolutionProblem);
|
||||
}
|
||||
|
||||
// struct R {};
|
||||
// R operator "" _waldo(const char*, unsigned long); // expects a string literal
|
||||
// auto d = 42_waldo; // passing an integer
|
||||
public void testUDLOperatorWithWrongType_484619() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLine(3, ProblemBindingChecker.ERR_ID_InvalidArguments);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3137,7 +3137,7 @@ public class CPPSemantics {
|
|||
|
||||
if (funcs.length == 0) {
|
||||
// S shall not be empty
|
||||
return new ProblemBinding(data.getLookupName(), exp, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||
return new ProblemBinding(data.getLookupName(), exp, IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (kind == IASTLiteralExpression.lk_integer_constant || kind == IASTLiteralExpression.lk_float_constant) {
|
||||
|
@ -3209,7 +3209,7 @@ public class CPPSemantics {
|
|||
}
|
||||
else if (ret == null) {
|
||||
// Couldn't find a valid operator
|
||||
return new ProblemBinding(data.getLookupName(), exp, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||
return new ProblemBinding(data.getLookupName(), exp, IProblemBinding.SEMANTIC_INVALID_OVERLOAD);
|
||||
}
|
||||
} else if (kind == IASTLiteralExpression.lk_string_literal) {
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue