forked from OSchip/llvm-project
Bug #:
Submitted by: Reviewed by: - Many tweaks to various diagnostics. - Fixed some location/range issues. - Bug fix to Sema::ParseDeclStmt() - error return code is "true", not 0. llvm-svn: 39526
This commit is contained in:
parent
4447083418
commit
56faab2d4f
|
@ -382,13 +382,13 @@ ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
|
|||
unsigned NumArgsToCheck = NumArgsInCall;
|
||||
|
||||
if (NumArgsInCall < NumArgsInProto)
|
||||
Diag(LParenLoc, diag::err_typecheck_call_too_few_args,
|
||||
Diag(RParenLoc, diag::err_typecheck_call_too_few_args,
|
||||
funcExpr->getSourceRange());
|
||||
else if (NumArgsInCall > NumArgsInProto) {
|
||||
if (!proto->isVariadic()) {
|
||||
Diag(LParenLoc, diag::err_typecheck_call_too_many_args,
|
||||
funcExpr->getSourceRange(),
|
||||
((Expr **)Args)[NumArgsInProto]->getSourceRange());
|
||||
Diag(((Expr **)Args)[NumArgsInProto+1]->getLocStart(),
|
||||
diag::err_typecheck_call_too_many_args, funcExpr->getSourceRange(),
|
||||
((Expr **)Args)[NumArgsInProto+1]->getSourceRange());
|
||||
}
|
||||
NumArgsToCheck = NumArgsInProto;
|
||||
}
|
||||
|
@ -414,14 +414,14 @@ ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
|
|||
case PointerFromInt:
|
||||
// check for null pointer constant (C99 6.3.2.3p3)
|
||||
if (!argExpr->isNullPointerConstant()) {
|
||||
Diag(l, diag::ext_typecheck_passing_pointer_from_int,
|
||||
lhsType.getAsString(),
|
||||
Diag(l, diag::ext_typecheck_passing_pointer_int,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
funcExpr->getSourceRange(), argExpr->getSourceRange());
|
||||
}
|
||||
break;
|
||||
case IntFromPointer:
|
||||
Diag(l, diag::ext_typecheck_passing_int_from_pointer,
|
||||
rhsType.getAsString(),
|
||||
Diag(l, diag::ext_typecheck_passing_pointer_int,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
funcExpr->getSourceRange(), argExpr->getSourceRange());
|
||||
break;
|
||||
case IncompatiblePointer:
|
||||
|
@ -889,11 +889,13 @@ inline QualType Sema::CheckAssignmentOperands( // C99 6.5.16.1
|
|||
case PointerFromInt:
|
||||
// check for null pointer constant (C99 6.3.2.3p3)
|
||||
if (compoundType.isNull() && !rex->isNullPointerConstant())
|
||||
Diag(loc, diag::ext_typecheck_assign_pointer_from_int,
|
||||
Diag(loc, diag::ext_typecheck_assign_pointer_int,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
lex->getSourceRange(), rex->getSourceRange());
|
||||
break;
|
||||
case IntFromPointer:
|
||||
Diag(loc, diag::ext_typecheck_assign_int_from_pointer,
|
||||
case IntFromPointer:
|
||||
Diag(loc, diag::ext_typecheck_assign_pointer_int,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
lex->getSourceRange(), rex->getSourceRange());
|
||||
break;
|
||||
case IncompatiblePointer:
|
||||
|
|
|
@ -26,7 +26,10 @@ Sema::StmtResult Sema::ParseNullStmt(SourceLocation SemiLoc) {
|
|||
}
|
||||
|
||||
Sema::StmtResult Sema::ParseDeclStmt(DeclTy *decl) {
|
||||
return decl ? new DeclStmt(static_cast<Decl *>(decl)) : 0;
|
||||
if (decl)
|
||||
return new DeclStmt(static_cast<Decl *>(decl));
|
||||
else
|
||||
return true; // error
|
||||
}
|
||||
|
||||
Action::StmtResult
|
||||
|
@ -248,16 +251,24 @@ Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *RetValExp) {
|
|||
case PointerFromInt:
|
||||
// check for null pointer constant (C99 6.3.2.3p3)
|
||||
if (!((Expr *)RetValExp)->isNullPointerConstant())
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_pointer_from_int);
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_pointer_int,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
((Expr *)RetValExp)->getSourceRange());
|
||||
break;
|
||||
case IntFromPointer:
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_int_from_pointer);
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_pointer_int,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
((Expr *)RetValExp)->getSourceRange());
|
||||
break;
|
||||
case IncompatiblePointer:
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_incompatible_pointer);
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_incompatible_pointer,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
((Expr *)RetValExp)->getSourceRange());
|
||||
break;
|
||||
case CompatiblePointerDiscardsQualifiers:
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_discards_qualifiers);
|
||||
Diag(ReturnLoc, diag::ext_typecheck_return_discards_qualifiers,
|
||||
lhsType.getAsString(), rhsType.getAsString(),
|
||||
((Expr *)RetValExp)->getSourceRange());
|
||||
break;
|
||||
}
|
||||
return new ReturnStmt((Expr*)RetValExp);
|
||||
|
|
|
@ -563,15 +563,13 @@ DIAG(ext_typecheck_comparison_of_pointer_integer, EXTENSION,
|
|||
DIAG(err_typecheck_assign_const, ERROR,
|
||||
"read-only variable is not assignable")
|
||||
DIAG(err_typecheck_assign_incompatible, ERROR,
|
||||
"incompatible types in assignment ('%0' and '%1')")
|
||||
DIAG(ext_typecheck_assign_int_from_pointer, EXTENSION,
|
||||
"assignment makes integer from pointer without a cast")
|
||||
DIAG(ext_typecheck_assign_pointer_from_int, EXTENSION,
|
||||
"assignment makes pointer from integer without a cast")
|
||||
"incompatible types assigning '%1' to '%0'")
|
||||
DIAG(ext_typecheck_assign_pointer_int, EXTENSION,
|
||||
"incompatible types assigning '%1' to '%0'")
|
||||
DIAG(ext_typecheck_assign_incompatible_pointer, EXTENSION,
|
||||
"assignment from incompatible pointer type ('%0' and '%1')")
|
||||
"incompatible pointer types assigning '%1' to '%0'")
|
||||
DIAG(ext_typecheck_assign_discards_qualifiers, EXTENSION,
|
||||
"assignment discards qualifiers from pointer target type ('%0' and '%1')")
|
||||
"assigning '%1' to '%0' discards qualifiers")
|
||||
DIAG(err_typecheck_array_not_modifiable_lvalue, ERROR,
|
||||
"array type '%0' is not assignable")
|
||||
DIAG(err_typecheck_non_object_not_modifiable_lvalue, ERROR,
|
||||
|
@ -585,15 +583,13 @@ DIAG(err_typecheck_call_too_few_args, ERROR,
|
|||
DIAG(err_typecheck_call_too_many_args, ERROR,
|
||||
"too many arguments to function")
|
||||
DIAG(err_typecheck_passing_incompatible, ERROR,
|
||||
"passing incompatible type '%0' to function expecting '%1'")
|
||||
"incompatible types passing '%0' to function expecting '%1'")
|
||||
DIAG(ext_typecheck_passing_incompatible_pointer, EXTENSION,
|
||||
"passing incompatible pointer '%0' to function expecting '%1'")
|
||||
DIAG(ext_typecheck_passing_int_from_pointer, EXTENSION,
|
||||
"passing pointer '%0' to function expecting integer (without a cast)")
|
||||
DIAG(ext_typecheck_passing_pointer_from_int, EXTENSION,
|
||||
"passing integer to function expecting '%0' (without a cast)")
|
||||
"incompatible pointer types passing '%0' to function expecting '%1'")
|
||||
DIAG(ext_typecheck_passing_pointer_int, EXTENSION,
|
||||
"incompatible types passing '%1' to function expecting '%0'")
|
||||
DIAG(ext_typecheck_passing_discards_qualifiers, EXTENSION,
|
||||
"function call discards qualifiers (passing '%0' to '%1')")
|
||||
"passing '%0' to '%1' discards qualifiers")
|
||||
DIAG(err_typecheck_cond_expect_scalar, ERROR,
|
||||
"used type '%0' where arithmetic or pointer type is required")
|
||||
DIAG(err_typecheck_cond_incompatible_operands, ERROR,
|
||||
|
@ -607,15 +603,13 @@ DIAG(err_continue_not_in_loop, ERROR,
|
|||
DIAG(err_break_not_in_loop_or_switch, ERROR,
|
||||
"'break' statement not in loop or switch statement")
|
||||
DIAG(err_typecheck_return_incompatible, ERROR,
|
||||
"incompatible types in return ('%0' and '%1')")
|
||||
DIAG(ext_typecheck_return_int_from_pointer, EXTENSION,
|
||||
"return makes integer from pointer without a cast")
|
||||
DIAG(ext_typecheck_return_pointer_from_int, EXTENSION,
|
||||
"return makes pointer from integer without a cast")
|
||||
"incompatible type returning '%1', expected '%0'")
|
||||
DIAG(ext_typecheck_return_pointer_int, EXTENSION,
|
||||
"incompatible type returning '%1', expected '%0'")
|
||||
DIAG(ext_typecheck_return_incompatible_pointer, EXTENSION,
|
||||
"return from incompatible pointer type")
|
||||
"incompatible pointer type returning '%1', expected '%0'")
|
||||
DIAG(ext_typecheck_return_discards_qualifiers, EXTENSION,
|
||||
"return discards qualifiers from pointer target type")
|
||||
"returning '%1' from function expecting '%0' discards qualifiers")
|
||||
DIAG(err_typecheck_statement_requires_scalar, ERROR,
|
||||
"statement requires expression of scalar type ('%0' invalid)")
|
||||
|
||||
|
|
Loading…
Reference in New Issue