diff options
author | Gabriel Dos Reis <gdr@integrable-solutions.net> | 2005-06-09 22:21:48 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@integrable-solutions.net> | 2005-06-09 22:21:48 +0000 |
commit | 1e75bb41405b4ec216334bd2a1f2e2b1bb019dbe (patch) | |
tree | 5ba1ed694692d32697b04063c0e9fb9c31bfdbd2 /gcc/c-typeck.c | |
parent | 8e50ecfba928a78aed2c025217cf18bd52b09b45 (diff) |
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*.
testsuite/
* gcc.dg/Wcxx-compat-1.c: New.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@100806 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 9429b73172c..918afa0464f 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3779,6 +3779,18 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, || 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. |