diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-11-21 18:27:34 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-11-21 18:27:34 +0000 |
| commit | 40bb0c83d403e6eb43f88ddfe0d3bb5f6ba075cf (patch) | |
| tree | f077fc8decb997eb252d122d04978b8419a597c6 | |
| parent | 735a4158d96dfbda71e0ecc275755fafe56a40f1 (diff) | |
| download | bcm5719-llvm-40bb0c83d403e6eb43f88ddfe0d3bb5f6ba075cf.tar.gz bcm5719-llvm-40bb0c83d403e6eb43f88ddfe0d3bb5f6ba075cf.zip | |
print a type in a diagnostic.
llvm-svn: 59829
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
| -rw-r--r-- | clang/test/Sema/exprs.c | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index bb681e69865..443e3114622 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -1250,7 +1250,7 @@ DIAG(err_typecheck_duplicate_vector_components_not_mlvalue, ERROR, DIAG(err_block_decl_ref_not_modifiable_lvalue, ERROR, "variable is not assignable (missing __block type specifier)") DIAG(err_typecheck_call_not_function, ERROR, - "called object is not a function or function pointer") + "called object type '%0' is not a function or function pointer") DIAG(err_typecheck_call_too_few_args, ERROR, "too few arguments to function") DIAG(err_typecheck_block_too_few_args, ERROR, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ace5bcd5b70..7c4c15e0dd6 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1347,7 +1347,7 @@ ActOnCallExpr(ExprTy *fn, SourceLocation LParenLoc, const PointerType *PT = Fn->getType()->getAsPointerType(); if (PT == 0) return Diag(LParenLoc, diag::err_typecheck_call_not_function) - << Fn->getSourceRange(); + << Fn->getType().getAsString() << Fn->getSourceRange(); FuncT = PT->getPointeeType()->getAsFunctionType(); } else { // This is a block call. FuncT = Fn->getType()->getAsBlockPointerType()->getPointeeType()-> @@ -1355,7 +1355,7 @@ ActOnCallExpr(ExprTy *fn, SourceLocation LParenLoc, } if (FuncT == 0) return Diag(LParenLoc, diag::err_typecheck_call_not_function) - << Fn->getSourceRange(); + << Fn->getType().getAsString() << Fn->getSourceRange(); // We know the result type of the call, set it. TheCall->setType(FuncT->getResultType().getNonReferenceType()); diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c index 8c8adc65b5f..66806dba658 100644 --- a/clang/test/Sema/exprs.c +++ b/clang/test/Sema/exprs.c @@ -29,3 +29,7 @@ void test5(int *X, float *P) { (float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} } +void test6() { + int X; + X(); // expected-error {{called object type 'int' is not a function or function pointer}} +} |

