Daniel convinced me that accepting "const va_list" arguments to va_arg is

a really really bad idea.  Now that we emit an error about the unpromoted
type, users should be able to understand what is going on.

llvm-svn: 68447
This commit is contained in:
Chris Lattner 2009-04-06 17:07:34 +00:00
parent 15e3a5c4b8
commit a8d2dbd181
3 changed files with 2 additions and 13 deletions

View File

@ -1464,8 +1464,6 @@ def err_va_start_used_in_non_variadic_function : Error<
"'va_start' used in function with fixed args">;
def warn_second_parameter_of_va_start_not_last_named_argument : Warning<
"second parameter of 'va_start' not last named argument">;
def warn_va_arg_with_qualified_va_list : Warning<
"va_arg applied to va_list type %0 with unexpected qualifiers">;
def err_first_argument_to_va_arg_not_of_type_va_list : Error<
"first argument to 'va_arg' is of type %0 and not 'va_list'">;

View File

@ -4725,16 +4725,7 @@ Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
// Make sure the input expression also decays appropriately.
UsualUnaryConversions(E);
AssignConvertType ConvResult =
CheckAssignmentConstraints(VaListType, E->getType());
switch (ConvResult) {
case Compatible: break; // Everything good.
case CompatiblePointerDiscardsQualifiers:
Diag(E->getLocStart(), diag::warn_va_arg_with_qualified_va_list)
<< OrigExpr->getType() << E->getSourceRange();
break;
default:
if (CheckAssignmentConstraints(VaListType, E->getType()) != Compatible) {
return ExprError(Diag(E->getLocStart(),
diag::err_first_argument_to_va_arg_not_of_type_va_list)
<< OrigExpr->getType() << E->getSourceRange());

View File

@ -3,6 +3,6 @@
// rdar://6726818
void f1() {
const __builtin_va_list args2;
(void)__builtin_va_arg(args2, int); // expected-warning {{va_arg applied to va_list type '__builtin_va_list const' with unexpected qualifiers}}
(void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type '__builtin_va_list const' and not 'va_list'}}
}