mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
Bug 368309: Value for sizeof expression
This commit is contained in:
parent
b68ecdc716
commit
8aef9f4f9d
2 changed files with 20 additions and 7 deletions
|
@ -5713,4 +5713,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testPartialClassTemplateSpecUsingDefaultArgument_367997() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// struct two { char x[2]; };
|
||||
// two check(...);
|
||||
// char check(int);
|
||||
// template <int> struct foo {};
|
||||
// template <> struct foo<1> { typedef int type; };
|
||||
// typedef foo<sizeof(check(0))>::type t; // ERROR HERE
|
||||
public void testValueForSizeofExpression_368309() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -580,13 +580,16 @@ public class Value implements IValue {
|
|||
final int unaryOp= ue.getOperator();
|
||||
|
||||
if (unaryOp == IASTUnaryExpression.op_sizeof) {
|
||||
IType type = ue.getExpressionType();
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) ue.getTranslationUnit();
|
||||
SizeofCalculator calculator = ast.getSizeofCalculator();
|
||||
SizeAndAlignment info = calculator.sizeAndAlignment(type);
|
||||
if (info == null)
|
||||
throw UNKNOWN_EX;
|
||||
return info.size;
|
||||
final IASTExpression operand = ue.getOperand();
|
||||
if (operand != null) {
|
||||
IType type = operand.getExpressionType();
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) ue.getTranslationUnit();
|
||||
SizeofCalculator calculator = ast.getSizeofCalculator();
|
||||
SizeAndAlignment info = calculator.sizeAndAlignment(type);
|
||||
if (info != null)
|
||||
return info.size;
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
}
|
||||
|
||||
if (unaryOp == IASTUnaryExpression.op_amper || unaryOp == IASTUnaryExpression.op_star ||
|
||||
|
|
Loading…
Add table
Reference in a new issue