diff options
author | Jason Merrill <jason@redhat.com> | 2009-11-12 13:25:51 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-11-12 13:25:51 -0500 |
commit | 36c37128fec15951f4ca43ad748568aaa550e2d3 (patch) | |
tree | dc0bb919cc000e4ca415472a4da5243b7d3f412e | |
parent | f33e4dd77aa34fab8c329da1572289304802c2a1 (diff) | |
download | gcc-36c37128fec15951f4ca43ad748568aaa550e2d3.zip gcc-36c37128fec15951f4ca43ad748568aaa550e2d3.tar.gz gcc-36c37128fec15951f4ca43ad748568aaa550e2d3.tar.bz2 |
typeck.c (cv_qualified_p): New fn.
* typeck.c (cv_qualified_p): New fn.
(decay_conversion): Use it.
* cp-tree.h: Declare it.
* tree.c (rvalue): Use it and cv_unqualified.
* init.c (build_aggr_init): Likewise.
From-SVN: r154125
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/init.c | 10 | ||||
-rw-r--r-- | gcc/cp/tree.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 11 |
5 files changed, 26 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e6d696b..861835b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 2009-11-12 Jason Merrill <jason@redhat.com> + * typeck.c (cv_qualified_p): New fn. + (decay_conversion): Use it. + * cp-tree.h: Declare it. + * tree.c (rvalue): Use it and cv_unqualified. + * init.c (build_aggr_init): Likewise. + +2009-11-12 Jason Merrill <jason@redhat.com> + PR c++/42013 * call.c (build_conditional_expr): Don't fold a TREE_SIDE_EFFECTS COND_EXPR in unevaluated context. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ca52bdf..f66a009 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5149,6 +5149,7 @@ extern tree move (tree); extern tree cp_build_qualified_type_real (tree, int, tsubst_flags_t); #define cp_build_qualified_type(TYPE, QUALS) \ cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error) +extern bool cv_qualified_p (const_tree); extern tree cv_unqualified (tree); extern special_function_kind special_function_p (const_tree); extern int count_trees (tree); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ef18a6c..db29204 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1248,13 +1248,13 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) /* Must arrange to initialize each element of EXP from elements of INIT. */ itype = init ? TREE_TYPE (init) : NULL_TREE; - if (cp_type_quals (type) != TYPE_UNQUALIFIED) - TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type); - if (itype && cp_type_quals (itype) != TYPE_UNQUALIFIED) - itype = TREE_TYPE (init) = TYPE_MAIN_VARIANT (itype); + if (cv_qualified_p (type)) + TREE_TYPE (exp) = cv_unqualified (type); + if (itype && cv_qualified_p (itype)) + TREE_TYPE (init) = cv_unqualified (itype); stmt_expr = build_vec_init (exp, NULL_TREE, init, /*explicit_value_init_p=*/false, - itype && same_type_p (itype, + itype && same_type_p (TREE_TYPE (init), TREE_TYPE (exp)), complain); TREE_READONLY (exp) = was_const; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5aea55e..9dae184 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -555,8 +555,8 @@ rvalue (tree expr) Non-class rvalues always have cv-unqualified types. */ type = TREE_TYPE (expr); - if (!CLASS_TYPE_P (type) && cp_type_quals (type)) - type = cp_build_qualified_type (type, TYPE_UNQUALIFIED); + if (!CLASS_TYPE_P (type) && cv_qualified_p (type)) + type = cv_unqualified (type); /* We need to do this for rvalue refs as well to get the right answer from decltype; see c++/36628. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 7cafc8a..de21c43 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1690,7 +1690,7 @@ decay_conversion (tree exp) Non-class rvalues always have cv-unqualified types. */ type = TREE_TYPE (exp); - if (!CLASS_TYPE_P (type) && cp_type_quals (type)) + if (!CLASS_TYPE_P (type) && cv_qualified_p (type)) exp = build_nop (cv_unqualified (type), exp); return exp; @@ -7411,6 +7411,15 @@ cp_type_readonly (const_tree type) return TYPE_READONLY (type); } +/* Returns nonzero if TYPE is const or volatile. */ + +bool +cv_qualified_p (const_tree type) +{ + int quals = cp_type_quals (type); + return (quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE)) != 0; +} + /* Returns nonzero if the TYPE contains a mutable member. */ bool |