]> granicus.if.org Git - clang/commitdiff
Make the presentation of the warnings on 'x + y ? 1 : 0' a bit more
authorChandler Carruth <chandlerc@gmail.com>
Thu, 16 Jun 2011 01:05:12 +0000 (01:05 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 16 Jun 2011 01:05:12 +0000 (01:05 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133121 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
test/Sema/parentheses.c
test/Sema/parentheses.cpp

index 00d0e6fab2ab9f1776c717c1f898b7bde694bebd..12f5f30b3522d4be976ba06cd6858653f5510ab3 100644 (file)
@@ -2757,12 +2757,12 @@ def note_precedence_bitwise_silence : Note<
   "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 "
index fa3c3c26b04218eb40892fe7bd65d0192525d181..95e0a930fe84ccb11e67afb2361671fb4ff07d05 100644 (file)
@@ -42,21 +42,21 @@ void bitwise_rel(unsigned i) {
 _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}}
 
-  (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 / !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
index a25f2a0ce7b876dceeabe261d216760554beaa58..c14a671292bf1fa929085e577e767774f64235cf 100644 (file)
@@ -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 @@ public:
 };
 
 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}}
 }