"second parameter of 'va_start' not last named argument">;
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'">;
+def warn_second_parameter_to_va_arg_not_pod : Warning<
+ "second argument to 'va_arg' is of non-POD type %0">,
+ InGroup<DiagGroup<"non-pod-varargs">>, DefaultError;
def warn_return_missing_expr : Warning<
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
}
// FIXME: Check that type is complete/non-abstract
- // FIXME: Warn if a non-POD type is passed in.
+
+ if (!TInfo->getType()->isDependentType() && !TInfo->getType()->isPODType())
+ return ExprError(Diag(TInfo->getTypeLoc().getBeginLoc(),
+ diag::warn_second_parameter_to_va_arg_not_pod)
+ << TInfo->getType() << TInfo->getTypeLoc().getSourceRange());
QualType T = TInfo->getType().getNonLValueExprType(Context);
return Owned(new (Context) VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T));
template struct VaArg1<__builtin_va_list, int>;
template struct VaArg1<int, int>; // expected-note{{instantiation}}
+
+struct VaArg2 {
+ virtual void f(int n, ...) {
+ __builtin_va_list va;
+ __builtin_va_start(va, n);
+ (void)__builtin_va_arg(va, VaArg2); // expected-error {{second argument to 'va_arg' is of non-POD type 'VaArg2'}}
+ __builtin_va_end(va);
+ }
+};