From 709322b8dfaae1b5dd9ef04c7ab0361d7d17c633 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Feb 2009 08:12:06 +0000 Subject: [PATCH] emit: t.c:4:9: error: invalid type 'short *' to __real operator __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)), ^ instead of: t.c:4:9: error: invalid type 'short *' to __real or __imag operator __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)), ^ fixing a fixme. It would be even fancier to get the spelling of the token, but I don't care *that* much :) llvm-svn: 64759 --- clang/include/clang/Basic/DiagnosticSemaKinds.def | 3 +-- clang/lib/Sema/Sema.h | 2 +- clang/lib/Sema/SemaExpr.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.def b/clang/include/clang/Basic/DiagnosticSemaKinds.def index 5e311e74d070..3f7ad9a5caac 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.def +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.def @@ -813,9 +813,8 @@ DIAG(err_typecheck_pointer_arith_void_type, ERROR, "arithmetic on pointer to void type") DIAG(err_typecheck_decl_incomplete_type, ERROR, "variable has incomplete type %0") -// FIXME: Use %select DIAG(err_realimag_invalid_type, ERROR, - "invalid type %0 to __real or __imag operator") + "invalid type %0 to %1 operator") DIAG(err_typecheck_sclass_fscope, ERROR, "illegal storage class on file-scoped variable") DIAG(err_typecheck_sclass_func, ERROR, diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 067c7a57df48..9b2b6e54d8ca 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1868,7 +1868,7 @@ public: bool isInc); QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc); QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc); - QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc); + QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal); /// type checking primary expressions. QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ad4f297388ca..0a61fe40c37c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1180,7 +1180,7 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, Range.getEnd())); } -QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc) { +QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isReal) { DefaultFunctionArrayConversion(V); // These operators return the element type of a complex type. @@ -1192,7 +1192,8 @@ QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc) { return V->getType(); // Reject anything else. - Diag(Loc, diag::err_realimag_invalid_type) << V->getType(); + Diag(Loc, diag::err_realimag_invalid_type) << V->getType() + << (isReal ? "__real" : "__imag"); return QualType(); } @@ -4058,7 +4059,7 @@ Action::OwningExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc, break; case UnaryOperator::Real: case UnaryOperator::Imag: - resultType = CheckRealImagOperand(Input, OpLoc); + resultType = CheckRealImagOperand(Input, OpLoc, Opc == UnaryOperator::Real); break; case UnaryOperator::Extension: resultType = Input->getType();