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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68447 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index e81fc49..1bdabad 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1464,8 +1464,6 @@
"'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'">;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 99afd32..602f7fc 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4725,16 +4725,7 @@
// 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());
diff --git a/test/Sema/varargs-x86-64.c b/test/Sema/varargs-x86-64.c
index 5afcda2..7c71c96 100644
--- a/test/Sema/varargs-x86-64.c
+++ b/test/Sema/varargs-x86-64.c
@@ -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'}}
}