From: Douglas Gregor Date: Tue, 15 Dec 2009 16:44:32 +0000 (+0000) Subject: Fix some diagnostic-related FIXMEs, from Nicola Gigante X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cc07df89ab9afa9079baeec1243ee90c3f84d9d;p=clang Fix some diagnostic-related FIXMEs, from Nicola Gigante git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91433 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index a890323e6c..71fcb9326e 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -530,10 +530,9 @@ def err_invalid_initialization : Error< "invalid initialization of reference of type %0 from expression of type %1">; def err_lvalue_to_rvalue_ambig_ref : Error<"rvalue reference cannot bind to lvalue " "due to multiple conversion functions">; -// FIXME: passing in an English string as %1! def err_not_reference_to_const_init : Error< "non-const lvalue reference to type %0 cannot be initialized " - "with a %1 of type %2">; + "with a %select{value|temporary}1 of type %2">; def err_lvalue_reference_bind_to_temporary : Error< "non-const lvalue reference to type %0 cannot bind to a temporary of type " "%1">; @@ -551,9 +550,8 @@ def err_init_list_bad_dest_type : Error< "%select{|non-aggregate }0type %1 cannot be initialized with an initializer " "list">; -// FIXME: passing in an English string as %1! def err_reference_init_drops_quals : Error< - "initialization of reference to type %0 with a %1 of type %2 drops " + "initialization of reference to type %0 with a %select{value|temporary}1 of type %2 drops " "qualifiers">; def err_reference_bind_to_bitfield : Error< "%select{non-const|volatile}0 reference cannot bind to bit-field %1">; @@ -1497,11 +1495,8 @@ def ext_sizeof_function_type : Extension< "invalid application of 'sizeof' to a function type">, InGroup; def ext_sizeof_void_type : Extension< "invalid application of '%0' to a void type">, InGroup; -// FIXME: merge with %select -def err_sizeof_incomplete_type : Error< - "invalid application of 'sizeof' to an incomplete type %0">; -def err_alignof_incomplete_type : Error< - "invalid application of '__alignof' to an incomplete type %0">; +def err_sizeof_alignof_incomplete_type : Error< + "invalid application of '%select{sizeof|__alignof}0' to an incomplete type %1">; def err_sizeof_alignof_bitfield : Error< "invalid application of '%select{sizeof|__alignof}0' to bit-field">; def err_offsetof_incomplete_type : Error< @@ -1586,9 +1581,8 @@ def err_out_of_line_declaration : Error< def note_member_def_close_match : Note<"member declaration nearly matches">; def err_typecheck_ivar_variable_size : Error< "instance variables must have a constant size">; -// FIXME: Improve with %select def err_typecheck_illegal_increment_decrement : Error< - "cannot modify value of type %0">; + "cannot %select{decrement|increment}1 value of type %0">; def err_typecheck_arithmetic_incomplete_type : Error< "arithmetic on pointer to incomplete type %0">; def err_typecheck_pointer_arith_function_type : Error< diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 228a716ca4..831d58dad5 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4462,7 +4462,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType, if (!isRValRef && T1.getCVRQualifiers() != Qualifiers::Const) { if (!ICS) Diag(DeclLoc, diag::err_not_reference_to_const_init) - << T1 << (InitLvalue != Expr::LV_Valid? "temporary" : "value") + << T1 << int(InitLvalue != Expr::LV_Valid) << T2 << Init->getSourceRange(); return true; } @@ -4528,7 +4528,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType, // initialization fails. if (!ICS) Diag(DeclLoc, diag::err_reference_init_drops_quals) - << T1 << (InitLvalue != Expr::LV_Valid? "temporary" : "value") + << T1 << int(InitLvalue != Expr::LV_Valid) << T2 << Init->getSourceRange(); return true; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 358f4456bb..66af76d736 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1698,9 +1698,8 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType, } if (RequireCompleteType(OpLoc, exprType, - isSizeof ? diag::err_sizeof_incomplete_type : - PDiag(diag::err_alignof_incomplete_type) - << ExprRange)) + PDiag(diag::err_sizeof_alignof_incomplete_type) + << int(!isSizeof) << ExprRange)) return true; // Reject sizeof(interface) and sizeof(interface) in 64-bit mode. @@ -5734,7 +5733,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc, << ResType << Op->getSourceRange(); } else { Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement) - << ResType << Op->getSourceRange(); + << ResType << int(isInc) << Op->getSourceRange(); return QualType(); } // At this point, we know we have a real, complex or pointer type. diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp index 896e30efb8..00e9c8f347 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p1.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp @@ -14,7 +14,7 @@ template struct X0; // expected-note{{instantiation}} // Explicitly instantiate a function template specialization template void f0(T t) { - ++t; // expected-error{{cannot modify}} + ++t; // expected-error{{cannot increment}} } template void f0(int);