[cfe-commits] r133121 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td test/Sema/parentheses.c test/Sema/parentheses.cpp

Chandler Carruth chandlerc at gmail.com
Wed Jun 15 18:05:12 PDT 2011


Author: chandlerc
Date: Wed Jun 15 20:05:12 2011
New Revision: 133121

URL: http://llvm.org/viewvc/llvm-project?rev=133121&view=rev
Log:
Make the presentation of the warnings on 'x + y ? 1 : 0' a bit more
pretty. In particular this makes it much easier for me to read messages
such as:

  x.cc:42: ?: has lower ...

Where I'm inclined to associate the third ':' with a missing column
number, but in fact column numbers have been turned off. Similar
punctuation collisions happened elsewhere as well.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/Sema/parentheses.c
    cfe/trunk/test/Sema/parentheses.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=133121&r1=133120&r2=133121&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 15 20:05:12 2011
@@ -2757,12 +2757,12 @@
   "place parentheses around the %0 expression to silence this warning">;
 
 def warn_precedence_conditional : Warning<
-  "?: has lower precedence than %0; %0 will be evaluated first">,
+  "operator '?:' has lower precedence than '%0'; '%0' will be evaluated first">,
   InGroup<Parentheses>;
 def note_precedence_conditional_first : Note<
-  "place parentheses around the ?: expression to evaluate it first">;
+  "place parentheses around the '?:' expression to evaluate it first">;
 def note_precedence_conditional_silence : Note<
-  "place parentheses around the %0 expression to silence this warning">;
+  "place parentheses around the '%0' expression to silence this warning">;
 
 def warn_logical_instead_of_bitwise : Warning<
   "use of logical %0 with constant operand; switch to bitwise %1 or "

Modified: cfe/trunk/test/Sema/parentheses.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/parentheses.c?rev=133121&r1=133120&r2=133121&view=diff
==============================================================================
--- cfe/trunk/test/Sema/parentheses.c (original)
+++ cfe/trunk/test/Sema/parentheses.c Wed Jun 15 20:05:12 2011
@@ -42,21 +42,21 @@
 _Bool someConditionFunc();
 
 void conditional_op(int x, int y, _Bool b) {
-  (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{?: has lower precedence than +}} \
-                                           // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                                           // expected-note {{place parentheses around the + expression to silence this warning}}
-
-  (void)(x - b ? 1 : 2); // expected-warning {{?: has lower precedence than -}} \
-                         // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                         // expected-note {{place parentheses around the - expression to silence this warning}}
-
-  (void)(x * (x == y) ? 1 : 2); // expected-warning {{?: has lower precedence than *}} \
-                                // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                                // expected-note {{place parentheses around the * expression to silence this warning}}
-
-  (void)(x / !x ? 1 : 2); // expected-warning {{?: has lower precedence than /}} \
-                          // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                          // expected-note {{place parentheses around the / expression to silence this warning}}
+  (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
+                                           // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                                           // expected-note {{place parentheses around the '+' expression to silence this warning}}
+
+  (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
+                         // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                         // expected-note {{place parentheses around the '-' expression to silence this warning}}
+
+  (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
+                                // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                                // expected-note {{place parentheses around the '*' expression to silence this warning}}
+
+  (void)(x / !x ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '/'}} \
+                          // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                          // expected-note {{place parentheses around the '/' expression to silence this warning}}
 
 
   (void)(x % 2 ? 1 : 2); // no warning

Modified: cfe/trunk/test/Sema/parentheses.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/parentheses.cpp?rev=133121&r1=133120&r2=133121&view=diff
==============================================================================
--- cfe/trunk/test/Sema/parentheses.cpp (original)
+++ cfe/trunk/test/Sema/parentheses.cpp Wed Jun 15 20:05:12 2011
@@ -4,17 +4,17 @@
 bool someConditionFunc();
 
 void conditional_op(int x, int y, bool b) {
-  (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{?: has lower precedence than +}} \
-                                           // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                                           // expected-note {{place parentheses around the + expression to silence this warning}}
+  (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
+                                           // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                                           // expected-note {{place parentheses around the '+' expression to silence this warning}}
 
-  (void)(x - b ? 1 : 2); // expected-warning {{?: has lower precedence than -}} \
-                         // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                         // expected-note {{place parentheses around the - expression to silence this warning}}
+  (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
+                         // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                         // expected-note {{place parentheses around the '-' expression to silence this warning}}
 
-  (void)(x * (x == y) ? 1 : 2); // expected-warning {{?: has lower precedence than *}} \
-                                // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                                // expected-note {{place parentheses around the * expression to silence this warning}}
+  (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
+                                // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                                // expected-note {{place parentheses around the '*' expression to silence this warning}}
 }
 
 class Stream {
@@ -25,7 +25,7 @@
 };
 
 void f(Stream& s, bool b) {
-  (void)(s << b ? "foo" : "bar"); // expected-warning {{?: has lower precedence than <<}} \
-                                  // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
-                                  // expected-note {{place parentheses around the << expression to silence this warning}}
+  (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
+                                  // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+                                  // expected-note {{place parentheses around the '<<' expression to silence this warning}}
 }





More information about the cfe-commits mailing list