Skip to content

Commit b436206

Browse files
authored
[clang] Fix inaccurate wording of warn_second_arg_of_va_start_not_last_named_param (#131238)
Rename and update the wording of `warn_second_arg_of_va_start_not_last_named_param` to best indicate that it's actually the last non-variadic parameter instead. Fixes #131171
1 parent 05df923 commit b436206

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10613,8 +10613,8 @@ def err_va_start_used_in_wrong_abi_function : Error<
1061310613
"'va_start' used in %select{System V|Win64}0 ABI function">;
1061410614
def err_ms_va_start_used_in_sysv_function : Error<
1061510615
"'__builtin_ms_va_start' used in System V ABI function">;
10616-
def warn_second_arg_of_va_start_not_last_named_param : Warning<
10617-
"second argument to 'va_start' is not the last named parameter">,
10616+
def warn_second_arg_of_va_start_not_last_non_variadic_param : Warning<
10617+
"second argument to 'va_start' is not the last non-variadic parameter">,
1061810618
InGroup<Varargs>;
1061910619
def warn_c17_compat_ellipsis_only_parameter : Warning<
1062010620
"'...' as the only parameter of a function is incompatible with C standards "

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4893,7 +4893,7 @@ bool Sema::BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
48934893

48944894
if (!SecondArgIsLastNamedArgument)
48954895
Diag(TheCall->getArg(1)->getBeginLoc(),
4896-
diag::warn_second_arg_of_va_start_not_last_named_param);
4896+
diag::warn_second_arg_of_va_start_not_last_non_variadic_param);
48974897
else if (IsCRegister || Type->isReferenceType() ||
48984898
Type->isSpecificBuiltinType(BuiltinType::Float) || [=] {
48994899
// Promotable integers are UB, but enumerations need a bit of

clang/test/C/C23/n2975.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void diag(int a, int b, ...) {
4646
va_start(list, a);
4747
// However, the builtin itself is under no such constraints regarding
4848
// expanding or evaluating the second argument, so it can still diagnose.
49-
__builtin_va_start(list, a); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
49+
__builtin_va_start(list, a); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
5050
va_end(list);
5151
}
5252

clang/test/Sema/varargs-x86-64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void __attribute__((ms_abi)) g1(int a) {
2020
void __attribute__((ms_abi)) g2(int a, int b, ...) {
2121
__builtin_ms_va_list ap;
2222

23-
__builtin_ms_va_start(ap, 10); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
24-
__builtin_ms_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
23+
__builtin_ms_va_start(ap, 10); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
24+
__builtin_ms_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
2525
__builtin_ms_va_start(ap, b);
2626
}
2727

clang/test/Sema/varargs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ void f2(int a, int b, ...)
1414
{
1515
__builtin_va_list ap;
1616

17-
__builtin_va_start(ap, 10); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
18-
__builtin_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
17+
__builtin_va_start(ap, 10); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
18+
__builtin_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
1919
__builtin_va_start(ap, b);
2020
}
2121

clang/test/SemaCXX/vararg-non-pod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void t6(Foo somearg, ... ) {
167167
// it should behave the same
168168
void t6b(Foo somearg, ... ) {
169169
__builtin_va_list list;
170-
__builtin_stdarg_start(list, somearg); // second argument to 'va_start' is not the last named parameter [-Wvarargs]
170+
__builtin_stdarg_start(list, somearg); // second argument to 'va_start' is not the last non-variadic parameter [-Wvarargs]
171171
}
172172

173173
void t7(int n, ...) {

clang/test/SemaCXX/varargs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void g(register int i, ...) { // expected-warning 0-1{{deprecated}}
1515
// Don't crash when there is no last parameter.
1616
void no_params(...) {
1717
int a;
18-
__builtin_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
18+
__builtin_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
1919
}
2020

2121
// Reject this. The __builtin_va_start would execute in Foo's non-variadic

0 commit comments

Comments
 (0)