* c.opt (Wc++-compat): New.
* doc/invoke.texi (-Wc++-compat): Document.
* c-typeck.c (convert_for_assignment): Check for implicit
conversion void* -> T*.
testsuite/
* gcc.dg/Wcxx-compat-1.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100806
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-06-09 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ PR c/21759
+ * c.opt (Wc++-compat): New.
+ * doc/invoke.texi (-Wc++-compat): Document.
+ * c-typeck.c (convert_for_assignment): Check for implicit
+ conversion void* -> T*.
+
2005-06-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
* machmode.h (to_machine_mode): New.
|| targetm.vector_opaque_p (rhstype))
&& TREE_CODE (ttl) == VECTOR_TYPE
&& TREE_CODE (ttr) == VECTOR_TYPE;
+
+ /* C++ does not allow the implicit conversion void* -> T*. However,
+ for the purpose of reducing the number of false positives, we
+ tolerate the special case of
+
+ int *p = NULL;
+
+ where NULL is typically defined in C to be '(void *) 0'. */
+ if (OPT_Wc___compat && VOID_TYPE_P (ttr) && rhs != null_pointer_node
+ && !VOID_TYPE_P (ttl))
+ warning (OPT_Wc___compat, "request for implicit conversion from "
+ "%qT to %qT not permitted in C++", rhstype, type);
/* Any non-function converts to a [const][volatile] void *
and vice versa; otherwise, targets must be the same.
C ObjC Var(warn_bad_function_cast)
Warn about casting functions to incompatible types
+Wc++-compat
+C Var(warn_cxx_compat)
+Warn about C constructs that are not in the common subset of C and C++
+
+
Wcast-qual
C ObjC C++ ObjC++ Var(warn_cast_qual)
Warn about casts which discard qualifiers
@xref{Warning Options,,Options to Request or Suppress Warnings}.
@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
-w -Wextra -Wall -Waggregate-return -Wno-attributes @gol
--Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
+-Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
-Wconversion -Wno-deprecated-declarations @gol
-Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
-Werror -Werror-implicit-function-declaration @gol
Warn whenever a function call is cast to a non-matching type.
For example, warn if @code{int malloc()} is cast to @code{anything *}.
+@item -Wc++-compat
+Warn about ISO C constructs that are outside of the common subset of
+ISO C and ISO C++, e.g.@: request for implicit conversion from
+@code{void *} to a pointer to non-@code{void} type.
+
@item -Wcast-qual
@opindex Wcast-qual
Warn whenever a pointer is cast so as to remove a type qualifier from
+2005-06-09 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * gcc.dg/Wcxx-compat-1.c: New.
+
2005-06-09 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/21480
--- /dev/null
+/* PR c/21759 */
+/* { dg-options "-Wc++-compat" } */
+
+int
+main(void)
+{
+ void *p = 0;
+ int *q = p; /* { dg-warning "not permitted" } */
+ double* t = (void *)0;
+ return p != q;
+}