]> granicus.if.org Git - clang/commitdiff
Document -Wabsolute-value with example
authorSylvestre Ledru <sylvestre@debian.org>
Thu, 14 Aug 2014 16:10:10 +0000 (16:10 +0000)
committerSylvestre Ledru <sylvestre@debian.org>
Thu, 14 Aug 2014 16:10:10 +0000 (16:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_35@215652 91177308-0d34-0410-b5e6-96231b3b80d8

docs/ReleaseNotes.rst

index 995f906534c0a4c9718187aa1d56b6fc7770354c..f12d71ceec7e09de70f864cf6aa181b793911902 100644 (file)
@@ -70,6 +70,30 @@ about them. The improvements since the 3.4 release include:
 - New warning `-Wabsolute-value`: Clang warns about incorrect or useless usage
   of the absolute functions (`abs`, `fabsf`, etc).
 
+  .. code-block:: c
+
+    #include <stdlib.h>
+    void foo() {
+     unsigned int i=0;
+     abs(i);
+    }
+
+  returns
+  `warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]`
+
+  or
+
+  .. code-block:: c
+
+    #include <stdlib.h>
+    void plop() {
+      long long i=0;
+      abs(i);
+    }
+
+  returns
+  `warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] use function 'llabs' instead`
+
 - New warning `-Wtautological-pointer-compare`:
 
   .. code-block:: c++