From: Richard Trieu Date: Wed, 2 May 2012 22:48:45 +0000 (+0000) Subject: Add commas to for loop warning to separate variable names. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82129e25c8d26d933771bc37aa0e0ed2edd131b4;p=clang Add commas to for loop warning to separate variable names. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156033 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 5db6dff6dd..9d6cc726c2 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -16,7 +16,7 @@ let CategoryName = "Semantic Issue" in { // For loop analysis def warn_variables_not_in_loop_body : Warning< - "variable%select{s| %1|s %1 and %2|s %1 %2 and %3|s %1 %2 %3 and %4}0 " + "variable%select{s| %1|s %1 and %2|s %1, %2, and %3|s %1, %2, %3, and %4}0 " "used in loop condition not modified in loop body">, InGroup>, DefaultIgnore; diff --git a/test/SemaCXX/warn-loop-analysis.cpp b/test/SemaCXX/warn-loop-analysis.cpp index 802ce52c4e..a55ca6c6ea 100644 --- a/test/SemaCXX/warn-loop-analysis.cpp +++ b/test/SemaCXX/warn-loop-analysis.cpp @@ -83,7 +83,7 @@ void test2() { for (; i != 3i; ) { ++i; } // Testing ConditionalOperator - for (; i ? j : k; ) {} // expected-warning {{variables 'i' 'j' and 'k' used in loop condition not modified in loop body}} + for (; i ? j : k; ) {} // expected-warning {{variables 'i', 'j', and 'k' used in loop condition not modified in loop body}} for (; i ? j : k; ) { ++i; } for (; i ? j : k; ) { ++j; } for (; i ? j : k; ) { ++k; } @@ -124,12 +124,12 @@ void test4() { int a, b, c, d, e, f; for (; a;); // expected-warning {{variable 'a' used in loop condition not modified in loop body}} for (; a + b;); // expected-warning {{variables 'a' and 'b' used in loop condition not modified in loop body}} - for (; a + b + c;); // expected-warning {{variables 'a' 'b' and 'c' used in loop condition not modified in loop body}} - for (; a + b + c + d;); // expected-warning {{variables 'a' 'b' 'c' and 'd' used in loop condition not modified in loop body}} + for (; a + b + c;); // expected-warning {{variables 'a', 'b', and 'c' used in loop condition not modified in loop body}} + for (; a + b + c + d;); // expected-warning {{variables 'a', 'b', 'c', and 'd' used in loop condition not modified in loop body}} for (; a + b + c + d + e;); // expected-warning {{variables used in loop condition not modified in loop body}} for (; a + b + c + d + e + f;); // expected-warning {{variables used in loop condition not modified in loop body}} - for (; a + c + d + b;); // expected-warning {{variables 'a' 'c' 'd' and 'b' used in loop condition not modified in loop body}} - for (; d + c + b + a;); // expected-warning {{variables 'd' 'c' 'b' and 'a' used in loop condition not modified in loop body}} + for (; a + c + d + b;); // expected-warning {{variables 'a', 'c', 'd', and 'b' used in loop condition not modified in loop body}} + for (; d + c + b + a;); // expected-warning {{variables 'd', 'c', 'b', and 'a' used in loop condition not modified in loop body}} } // Ensure that the warning doesn't fail when lots of variables are used