diff options
author | Jason Merrill <jason@redhat.com> | 2010-05-19 17:02:03 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-05-19 17:02:03 -0400 |
commit | 93e1ddcf9c8f4b8b64d0e53bd4a4f306eb70bdd4 (patch) | |
tree | 73962fa75beb82263d63e1c7b90f861c66bc93df /gcc/cp | |
parent | 2872152c39fbc1c91da3fc07e8701fadb6b87f98 (diff) | |
download | gcc-93e1ddcf9c8f4b8b64d0e53bd4a4f306eb70bdd4.zip gcc-93e1ddcf9c8f4b8b64d0e53bd4a4f306eb70bdd4.tar.gz gcc-93e1ddcf9c8f4b8b64d0e53bd4a4f306eb70bdd4.tar.bz2 |
decl.c (grokdeclarator): Don't check quals on fn type.
* decl.c (grokdeclarator): Don't check quals on fn type.
* typeck.c (cp_apply_type_quals_to_decl): Likewise.
* tree.c (cp_build_qualified_type_real): Simplify qualifier checking.
From-SVN: r159597
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 15 | ||||
-rw-r--r-- | gcc/cp/pt.c | 6 | ||||
-rw-r--r-- | gcc/cp/tree.c | 26 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 19 |
5 files changed, 19 insertions, 51 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 255ecd3..26eaafc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-05-19 Jason Merrill <jason@redhat.com> + * decl.c (grokdeclarator): Don't check quals on fn type. + * typeck.c (cp_apply_type_quals_to_decl): Likewise. + * tree.c (cp_build_qualified_type_real): Simplify qualifier checking. + PR c++/44193 * typeck.c (type_memfn_quals): New fn. (apply_memfn_quals): New fn. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e57a753..d3cc02b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8224,21 +8224,6 @@ grokdeclarator (const cp_declarator *declarator, error ("qualifiers are not allowed on declaration of %<operator %T%>", ctor_return_type); - if (TREE_CODE (type) == FUNCTION_TYPE - && type_quals != TYPE_UNQUALIFIED) - { - /* This was an error in C++98 (cv-qualifiers cannot be added to - a function type), but DR 295 makes the code well-formed by - dropping the extra qualifiers. */ - if (pedantic && cxx_dialect == cxx98) - { - tree bad_type = build_qualified_type (type, type_quals); - pedwarn (input_location, OPT_pedantic, - "ignoring %qV qualifiers added to function type %qT", - bad_type, type); - } - type_quals = TYPE_UNQUALIFIED; - } type_quals |= cp_type_quals (type); type = cp_build_qualified_type_real (type, type_quals, ((typedef_decl && !DECL_ARTIFICIAL (typedef_decl) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 949734d..e7e43c0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14099,9 +14099,9 @@ check_cv_quals_for_unify (int strict, tree arg, tree parm) { /* Although a CVR qualifier is ignored when being applied to a substituted template parameter ([8.3.2]/1 for example), that - does not apply during deduction [14.8.2.4]/1, (even though - that is not explicitly mentioned, [14.8.2.4]/9 indicates - this). Except when we're allowing additional CV qualifiers + does not allow us to unify "const T" with "int&" because both + types are not of the form "cv-list T" [14.8.2.5 temp.deduct.type]. + It is ok when we're allowing additional CV qualifiers at the outer level [14.8.2.1]/3,1st bullet. */ if ((TREE_CODE (arg) == REFERENCE_TYPE || TREE_CODE (arg) == FUNCTION_TYPE diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 04bfae0..e34a69c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -865,13 +865,15 @@ cp_build_qualified_type_real (tree type, } /* A reference or method type shall not be cv-qualified. - [dcl.ref], [dcl.fct] */ + [dcl.ref], [dcl.fct]. This used to be an error, but as of DR 295 + (in CD1) we always ignore extra cv-quals on functions. */ if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE) && (TREE_CODE (type) == REFERENCE_TYPE || TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)) { - bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); + if (TREE_CODE (type) == REFERENCE_TYPE) + bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); } @@ -890,24 +892,16 @@ cp_build_qualified_type_real (tree type, type_quals &= ~TYPE_QUAL_RESTRICT; } - if (bad_quals == TYPE_UNQUALIFIED) + if (bad_quals == TYPE_UNQUALIFIED + || (complain & tf_ignore_bad_quals)) /*OK*/; - else if (!(complain & (tf_error | tf_ignore_bad_quals))) + else if (!(complain & tf_error)) return error_mark_node; else { - if (complain & tf_ignore_bad_quals) - /* We're not going to warn about constifying things that can't - be constified. */ - bad_quals &= ~TYPE_QUAL_CONST; - if (bad_quals) - { - tree bad_type = build_qualified_type (ptr_type_node, bad_quals); - - if (!(complain & tf_ignore_bad_quals)) - error ("%qV qualifiers cannot be applied to %qT", - bad_type, type); - } + tree bad_type = build_qualified_type (ptr_type_node, bad_quals); + error ("%qV qualifiers cannot be applied to %qT", + bad_type, type); } /* Retrieve (or create) the appropriately qualified variant. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a291a9c..44d7ab1 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7952,23 +7952,8 @@ cp_apply_type_quals_to_decl (int type_quals, tree decl) if (TREE_CODE (decl) == TYPE_DECL) return; - if (TREE_CODE (type) == FUNCTION_TYPE - && type_quals != TYPE_UNQUALIFIED) - { - /* This was an error in C++98 (cv-qualifiers cannot be added to - a function type), but DR 295 makes the code well-formed by - dropping the extra qualifiers. */ - if (pedantic) - { - tree bad_type = build_qualified_type (type, type_quals); - pedwarn (input_location, OPT_pedantic, - "ignoring %qV qualifiers added to function type %qT", - bad_type, type); - } - - TREE_TYPE (decl) = TYPE_MAIN_VARIANT (type); - return; - } + gcc_assert (!(TREE_CODE (type) == FUNCTION_TYPE + && type_quals != TYPE_UNQUALIFIED)); /* Avoid setting TREE_READONLY incorrectly. */ if (/* If the object has a constructor, the constructor may modify |