]> git.pld-linux.org Git - packages/crossppc-gcc.git/commitdiff
- better diagnostic. auto/th/gcc-4_1_0-0_20050701T1908UTC_2 auto/th/gcc-4_1_0-0_20050707T1814UTC_1 auto/th/gcc-4_1_0-0_20050711T1659UTC_1 auto/th/gcc-4_1_0-0_20050713T1743UTC_1 auto/th/gcc-4_1_0-0_20050713T2200UTC_1 auto/th/gcc-4_1_0-0_20050716T0555UTC_1 auto/th/gcc-4_1_0-0_20050717T1716UTC_1 auto/th/gcc-4_1_0-0_20050722T2023UTC_1 auto/th/gcc-4_1_0-0_20050724T0642UTC_0_1 auto/th/gcc-4_1_0-0_20050724T0642UTC_0_2 auto/th/gcc-4_1_0-0_20050724T0642UTC_0_3 auto/th/gcc-4_1_0-0_20050724T0642UTC_1 auto/th/gcc-4_1_0-0_20050726T1627UTC_1 auto/th/gcc-4_1_0-0_20050731T0821UTC_1 auto/th/gcc-4_1_0-0_20050804T2325UTC_1 auto/th/gcc-4_1_0-0_20050815T0803UTC_1 auto/th/gcc-4_1_0-0_20050815T0803UTC_2 auto/th/gcc-4_1_0-0_20050815T0803UTC_3 auto/th/gcc-4_1_0-0_20050818T2314UTC_1 auto/th/gcc-4_1_0-0_20050823T1409UTC_1 auto/th/gcc-4_1_0-0_20050823T1409UTC_2 auto/th/gcc-4_1_0-0_20050904T1004UTC_1 auto/th/gcc-4_1_0-0_20050915T1259UTC_1 auto/th/gcc-4_1_0-0_20050921T0223UTC_1 auto/th/gcc-4_1_0-0_20050922T2047UTC_1 auto/th/gcc-4_1_0-0_20050922T2047UTC_2 auto/th/gcc-4_1_0-0_20050922T2047UTC_3 auto/th/gcc-4_1_0-0_20051001T1855UTC_1 auto/th/gcc-4_1_0-0_20051003T0833UTC_1 auto/th/gcc-4_1_0-0_20051005T0949UTC_1
authorPaweł Sikora <pluto@pld-linux.org>
Fri, 24 Jun 2005 11:33:24 +0000 (11:33 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    gcc-pr7776.patch -> 1.1

gcc-pr7776.patch [new file with mode: 0644]

diff --git a/gcc-pr7776.patch b/gcc-pr7776.patch
new file mode 100644 (file)
index 0000000..0a73938
--- /dev/null
@@ -0,0 +1,88 @@
+Date: Tue, 14 Jun 2005 00:20:06 -0600 (MDT)
+From: Roger Sayle <roger at eyesopen dot com>
+Subject: [PATCH] PR 7776: Warn about if ("abc" < "xyz") ... (take 2) 
+
+The following patch is a revised version of my proposed solution to
+PR middle-end/7776, which addresses Daniel Jacobowitz's concerns about
+the potential utility of testing string literals for equality/inequality
+with NULL.
+
+See http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00369.html (and the
+following thread) for details and motivation.
+
+The following patch has been tested on i686-pc-linux-gnu with a full
+"make bootstrap", all default languages, and regression tested with a
+top-level "make -k check" with no new failures.
+
+Ok for mainline?
+
+2005-06-13  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/7776
+       * common.opt (Wstring-literal-comparison): New command line option.
+       * c-opts.c (c_common_handle_option): Set it with -Wall.
+       * c-typeck.c (parser_build_binary_op): Issue warning if either
+       operand of a comparison operator is a string literal, except for
+       testing equality or inequality against NULL.
+
+       * gcc.dg/Wstring-literal-comparison-1.c: New test case.
+       * gcc.dg/Wstring-literal-comparison-2.c: Likewise.
+       * gcc.dg/Wstring-literal-comparison-3.c: Likewise.
+       * gcc.dg/Wstring-literal-comparison-4.c: Likewise.
+
+
+*** a/gcc/common.opt   4 Jun 2005 17:07:55 -0000       1.73
+--- b/gcc/common.opt   13 Jun 2005 16:59:28 -0000
+*************** Wstrict-aliasing=
+*** 117,122 ****
+--- 117,126 ----
+  Common Joined UInteger
+  Warn about code which might break strict aliasing rules
+
++ Wstring-literal-comparison
++ Common Var(warn_string_literal_comparison)
++ Warn about comparisons to constant string literals
++
+  Wswitch
+  Common Var(warn_switch)
+  Warn about enumerated switches, with no default, missing a case
+*** a/gcc/c-opts.c     25 May 2005 03:58:55 -0000      1.146
+--- b/gcc/c-opts.c     13 Jun 2005 16:59:29 -0000
+*************** c_common_handle_option (size_t scode, co
+*** 370,375 ****
+--- 370,376 ----
+       warn_sign_compare = value;
+        warn_switch = value;
+        warn_strict_aliasing = value;
++       warn_string_literal_comparison = value;
+
+        /* Only warn about unknown pragmas that are not in system
+        headers.  */
+*** a/gcc/c-typeck.c   11 Jun 2005 19:47:01 -0000      1.453
+--- b/gcc/c-typeck.c   13 Jun 2005 16:59:31 -0000
+*************** parser_build_binary_op (enum tree_code c
+*** 2412,2417 ****
+--- 2412,2434 ----
+
+      }
+
++   /* Warn about comparisons against string literals, with the exception
++      of testing for equality or inequality of a string literal with NULL.  */
++   if (code == EQ_EXPR || code == NE_EXPR)
++     {
++       if ((TREE_CODE (arg1.value) == STRING_CST
++         && !integer_zerop (arg2.value))
++        || (TREE_CODE (arg2.value) == STRING_CST
++            && !integer_zerop (arg1.value)))
++      warning (OPT_Wstring_literal_comparison,
++               "comparison with string literal");
++     }
++   else if (TREE_CODE_CLASS (code) == tcc_comparison
++         && (TREE_CODE (arg1.value) == STRING_CST
++             || TREE_CODE (arg2.value) == STRING_CST))
++     warning (OPT_Wstring_literal_comparison,
++           "comparison with string literal");
++
+    unsigned_conversion_warning (result.value, arg1.value);
+    unsigned_conversion_warning (result.value, arg2.value);
+    overflow_warning (result.value);
This page took 0.054122 seconds and 4 git commands to generate.