diff options
author | Mark Mitchell <mark@codesourcery.com> | 2007-04-09 19:45:53 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2007-04-09 19:45:53 +0000 |
commit | a607b96e80f5790c88b80a8ac0b0c0dd88fe413b (patch) | |
tree | 2e58e8f6b8559201c4de3c552c43bd48eba5d9f9 /gcc/cp/class.c | |
parent | 80ae8e8ad2efea97a01aad6cb4656e7fb5b0fd55 (diff) | |
download | gcc-a607b96e80f5790c88b80a8ac0b0c0dd88fe413b.zip gcc-a607b96e80f5790c88b80a8ac0b0c0dd88fe413b.tar.gz gcc-a607b96e80f5790c88b80a8ac0b0c0dd88fe413b.tar.bz2 |
re PR c++/31449 ([4.1] static_cast can remove const-ness)
PR c++/31449
* class.c (build_base_path): Ensure that the converted pointer has
the same cv-qualification as the input.
PR c++/31449
* g++.dg/init/const5.C: New test.
From-SVN: r123679
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0bb441e..e01fbe1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -303,7 +303,18 @@ build_base_path (enum tree_code code, field, because other parts of the compiler know that such expressions are always non-NULL. */ if (!virtual_access && integer_zerop (offset)) - return build_nop (build_pointer_type (target_type), expr); + { + tree class_type; + /* TARGET_TYPE has been extracted from BINFO, and, is + therefore always cv-unqualified. Extract the + cv-qualifiers from EXPR so that the expression returned + matches the input. */ + class_type = TREE_TYPE (TREE_TYPE (expr)); + target_type + = cp_build_qualified_type (target_type, + cp_type_quals (class_type)); + return build_nop (build_pointer_type (target_type), expr); + } null_test = error_mark_node; } |