re PR c/61162 (possibly bad error location with -Wc++-compat)
authorMarek Polacek <polacek@redhat.com>
Tue, 13 May 2014 17:41:12 +0000 (17:41 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 13 May 2014 17:41:12 +0000 (17:41 +0000)
PR c/61162
* c-typeck.c (convert_for_assignment): Pass location to
WARN_FOR_ASSIGNMENT instead of input_location.

* gcc.dg/pr61162.c: New test.

From-SVN: r210393

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr61162.c [new file with mode: 0644]

index 919b4ff5f5ff99612b12c3e860fca2e739404537..7b7d6650ae01ac18886448453bcf827291d19dff 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61162
+       * c-typeck.c (convert_for_assignment): Pass location to
+       WARN_FOR_ASSIGNMENT instead of input_location.
+
 2014-05-10  Marek Polacek  <polacek@redhat.com>
 
        * c-parser.c (c_parser_declaration_or_fndef): Pass init_loc to
index 4b1fe66cd6b5c8279cfe3dfa33d40b01727757e8..6f4bd4afb6cf2bf4edb49d6b476351173f363937 100644 (file)
@@ -5754,7 +5754,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
          && TREE_CODE (type) == ENUMERAL_TYPE
          && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
        {
-         WARN_FOR_ASSIGNMENT (input_location, OPT_Wc___compat,
+         WARN_FOR_ASSIGNMENT (location, OPT_Wc___compat,
                               G_("enum conversion when passing argument "
                                  "%d of %qE is invalid in C++"),
                               G_("enum conversion in assignment is "
index 98a6505c3ef66e76e7a509955dab385086da288d..54d483feea0c8832baf0307d38a1362b5dc6be5d 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61162
+       * gcc.dg/pr61162.c: New test.
+
 2014-05-13  Marek Polacek  <polacek@redhat.com>
 
        * c-c++-common/pr50459.c: Move cdtor tests to a separate testcase.
diff --git a/gcc/testsuite/gcc.dg/pr61162.c b/gcc/testsuite/gcc.dg/pr61162.c
new file mode 100644 (file)
index 0000000..00e64b9
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR c/61162 */
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+enum e { A };
+enum e
+fn1 (void)
+{
+  enum e e, q = 0; /* { dg-warning "17:enum conversion in initialization is invalid" } */
+  e = 0; /* { dg-warning "5:enum conversion in assignment is invalid" } */
+  1; return 0; /* { dg-warning "6:enum conversion in return is invalid" } */
+}