diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-09-08 17:15:33 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-09-10 18:04:11 +0200 |
commit | 29ff25e70671ce2046aab5cf89bf519ec6cf2bed (patch) | |
tree | 0b0c7ca07dfe2772afb2b5f3b73b785e297efd3b /gcc/d | |
parent | e63eb26d22dbbbbb67f7f240ea5a7234cd2498cb (diff) | |
download | gcc-29ff25e70671ce2046aab5cf89bf519ec6cf2bed.zip gcc-29ff25e70671ce2046aab5cf89bf519ec6cf2bed.tar.gz gcc-29ff25e70671ce2046aab5cf89bf519ec6cf2bed.tar.bz2 |
d: Warn when casting from a D class to a C++ class.
Before, the warning was only issued when casting in the other direction.
Now a warning is printed for both directions.
gcc/d/ChangeLog:
* d-convert.cc (convert_expr): Warn when casting from a D class to a
C++ class.
gcc/testsuite/ChangeLog:
* gdc.dg/Waddress.d: New test.
* gdc.dg/Wcastresult1.d: New test.
* gdc.dg/Wcastresult2.d: New test.
Diffstat (limited to 'gcc/d')
-rw-r--r-- | gcc/d/d-convert.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc index 5e3e855..40e84f0 100644 --- a/gcc/d/d-convert.cc +++ b/gcc/d/d-convert.cc @@ -430,10 +430,10 @@ convert_expr (tree exp, Type *etype, Type *totype) /* d_convert will make a no-op cast. */ break; } - else if (cdfrom->isCPPclass ()) + else if (cdfrom->isCPPclass () || cdto->isCPPclass ()) { /* Downcasting in C++ is a no-op. */ - if (cdto->isCPPclass ()) + if (cdfrom->isCPPclass () && cdto->isCPPclass ()) break; /* Casting from a C++ interface to a class/non-C++ interface |