mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 309155: Cast to void.
This commit is contained in:
parent
8b262a1f4d
commit
f262dbf212
3 changed files with 20 additions and 9 deletions
|
@ -8545,5 +8545,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
b= bh.assertNonProblem("f(c32)", 1);
|
||||
assertSame(f2, b);
|
||||
}
|
||||
|
||||
|
||||
// int test() {
|
||||
// void (11);
|
||||
// return 42;
|
||||
// }
|
||||
public void testCastToVoid_309155() throws Exception {
|
||||
String code= getAboveComment();
|
||||
parseAndCheckBindings(code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1188,6 +1188,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.t_float:
|
||||
case IToken.t_double:
|
||||
case IToken.t_decltype:
|
||||
case IToken.t_void:
|
||||
case IGCCToken.t_typeof:
|
||||
firstExpression = simpleTypeConstructorExpression(simpleTypeSpecifier());
|
||||
break;
|
||||
|
|
|
@ -2893,17 +2893,16 @@ public class CPPSemantics {
|
|||
if (op == null)
|
||||
return null;
|
||||
|
||||
IType op1type = SemanticUtil.getUltimateTypeUptoPointers(exp.getOperand1().getExpressionType());
|
||||
IASTExpression[] args = new IASTExpression[] { exp.getOperand1(), exp.getOperand2() } ;
|
||||
final IASTExpression op1 = exp.getOperand1();
|
||||
final IASTExpression op2 = exp.getOperand2();
|
||||
IType op1type = getNestedType(op1.getExpressionType(), TDEF | REF | CVTYPE);
|
||||
IType op2type = getNestedType(op2.getExpressionType(), TDEF | REF | CVTYPE);
|
||||
if (!isUserDefined(op1type) && !isUserDefined(op2type))
|
||||
return null;
|
||||
|
||||
IASTExpression[] args = new IASTExpression[] { op1, op2 };
|
||||
NonMemberMode lookupNonMember = NonMemberMode.none;
|
||||
if (exp.getOperator() != IASTBinaryExpression.op_assign) {
|
||||
IType op2type = SemanticUtil.getUltimateTypeUptoPointers(exp.getOperand2().getExpressionType());
|
||||
if (op2type instanceof IProblemBinding)
|
||||
return null;
|
||||
if (!isUserDefined(op1type) && !isUserDefined(op2type))
|
||||
return null;
|
||||
|
||||
lookupNonMember= NonMemberMode.limited;
|
||||
}
|
||||
|
||||
|
@ -3089,6 +3088,9 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
private static boolean isUserDefined(IType type) {
|
||||
if (type instanceof IProblemBinding)
|
||||
return false;
|
||||
|
||||
return type instanceof ICPPClassType || type instanceof IEnumeration;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue