]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
typeck.c (build_reinterpret_cast_1): Pass proper argument to warn() in pedantic.
authorDaniel Gutson <daniel.gutson@tallertechnologies.com>
Mon, 28 Apr 2014 18:14:36 +0000 (18:14 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 28 Apr 2014 18:14:36 +0000 (14:14 -0400)
* typeck.c (build_reinterpret_cast_1): Pass proper argument to
warn() in pedantic.

From-SVN: r209870

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/g++.dg/diagnostic/pedantic.C [new file with mode: 0644]

index 7359cb7d8dc0061bef652f6f30e97c450c11f274..b21c15f462fcb0104ca99158e5a46eba43e0d067 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-28  Daniel Gutson  <daniel.gutson@tallertechnologies.com>
+
+       * typeck.c (build_reinterpret_cast_1): Pass proper argument to
+       warn() in pedantic.
+
 2014-02-28  Jason Merrill  <jason@redhat.com>
 
        PR c++/58845
index b8e862cb3c73df263d34b30e4608de91d88b754f..2fa47025b7debb6a2e81baf2eddeb47e887c50da 100644 (file)
@@ -6649,7 +6649,7 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
           where possible, and it is necessary in some cases.  DR 195
           addresses this issue, but as of 2004/10/26 is still in
           drafting.  */
-       warning (0, "ISO C++ forbids casting between pointer-to-function and pointer-to-object");
+       warning (OPT_Wpedantic, "ISO C++ forbids casting between pointer-to-function and pointer-to-object");
       return fold_if_not_in_template (build_nop (type, expr));
     }
   else if (TREE_CODE (type) == VECTOR_TYPE)
diff --git a/gcc/testsuite/g++.dg/diagnostic/pedantic.C b/gcc/testsuite/g++.dg/diagnostic/pedantic.C
new file mode 100644 (file)
index 0000000..450a0fa
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-pedantic" }
+typedef void F(void);
+
+void foo()
+{
+    void* p = 0;
+    F* f1 = reinterpret_cast<F*>(p);    // { dg-warning "ISO" }
+#pragma GCC diagnostic ignored "-pedantic"
+    F* f2 = reinterpret_cast<F*>(p);
+}