Commit 171d2f50 by Nathan Sidwell Committed by Nathan Sidwell

Remove DR 295 implementation.

cp:
	Remove DR 295 implementation.
	* pt.c (check_cv_quals_for_unify): Disable function & method cases.
	* tree.c (cp_build_qualified_type_real): Likewise. Don't warn
	about ignoring volatile qualifiers.

	* search.c (lookup_member): Correct documentation.
testsuite:
	* g++.dg/template/qualttp20.C: Adjust expected errors.
	* g++.old-deja/g++.jason/report.C: Likewise.
	* g++.old-deja/g++.other/qual1.C: Likewise.

From-SVN: r57209
parent 0e9cab87
2002-09-16 Nathan Sidwell <nathan@codesourcery.com>
Remove DR 295 implementation.
* pt.c (check_cv_quals_for_unify): Disable function & method cases.
* tree.c (cp_build_qualified_type_real): Likewise. Don't warn
about ignoring volatile qualifiers.
* search.c (lookup_member): Correct documentation.
2002-09-16 Geoffrey Keating <geoffk@apple.com> 2002-09-16 Geoffrey Keating <geoffk@apple.com>
* cp-tree.h (union lang_tree_node): Add chain_next option. * cp-tree.h (union lang_tree_node): Add chain_next option.
......
...@@ -8570,9 +8570,7 @@ check_cv_quals_for_unify (strict, arg, parm) ...@@ -8570,9 +8570,7 @@ check_cv_quals_for_unify (strict, arg, parm)
{ {
/* If the cvr quals of parm will not unify with ARG, they'll be /* If the cvr quals of parm will not unify with ARG, they'll be
ignored in instantiation, so we have to do the same here. */ ignored in instantiation, so we have to do the same here. */
if (TREE_CODE (arg) == REFERENCE_TYPE if (TREE_CODE (arg) == REFERENCE_TYPE)
|| TREE_CODE (arg) == FUNCTION_TYPE
|| TREE_CODE (arg) == METHOD_TYPE)
parm_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); parm_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
if (!POINTER_TYPE_P (arg) && if (!POINTER_TYPE_P (arg) &&
TREE_CODE (arg) != TEMPLATE_TYPE_PARM) TREE_CODE (arg) != TEMPLATE_TYPE_PARM)
......
...@@ -1400,15 +1400,16 @@ build_baselink (tree binfo, tree access_binfo, tree functions, tree optype) ...@@ -1400,15 +1400,16 @@ build_baselink (tree binfo, tree access_binfo, tree functions, tree optype)
} }
/* Look for a member named NAME in an inheritance lattice dominated by /* Look for a member named NAME in an inheritance lattice dominated by
XBASETYPE. If PROTECT is 0 or two, we do not check access. If it is XBASETYPE. If PROTECT is 0 or two, we do not check access. If it
1, we enforce accessibility. If PROTECT is zero, then, for an is 1, we enforce accessibility. If PROTECT is zero, then, for an
ambiguous lookup, we return NULL. If PROTECT is 1, we issue an ambiguous lookup, we return NULL. If PROTECT is 1, we issue error
error message. If PROTECT is 2, we return a TREE_LIST whose messages about inaccessible or ambiguous lookup. If PROTECT is 2,
TREE_TYPE is error_mark_node and whose TREE_VALUEs are the list of we return a TREE_LIST whose TREE_TYPE is error_mark_node and whose
ambiguous candidates. TREE_VALUEs are the list of ambiguous candidates.
WANT_TYPE is 1 when we should only return TYPE_DECLs, if no WANT_TYPE is 1 when we should only return TYPE_DECLs.
TYPE_DECL can be found return NULL_TREE. */
If nothing can be found return NULL_TREE and do not issue an error. */
tree tree
lookup_member (xbasetype, name, protect, want_type) lookup_member (xbasetype, name, protect, want_type)
......
...@@ -577,6 +577,11 @@ cp_build_qualified_type_real (type, type_quals, complain) ...@@ -577,6 +577,11 @@ cp_build_qualified_type_real (type, type_quals, complain)
{ {
tree result; tree result;
int bad_quals = TYPE_UNQUALIFIED; int bad_quals = TYPE_UNQUALIFIED;
/* We keep bad function qualifiers separate, so that we can decide
whether to implement DR 295 or not. DR 295 break existing code,
unfortunately. Remove this variable to implement the defect
report. */
int bad_func_quals = TYPE_UNQUALIFIED;
if (type == error_mark_node) if (type == error_mark_node)
return type; return type;
...@@ -592,6 +597,8 @@ cp_build_qualified_type_real (type, type_quals, complain) ...@@ -592,6 +597,8 @@ cp_build_qualified_type_real (type, type_quals, complain)
|| TREE_CODE (type) == METHOD_TYPE)) || TREE_CODE (type) == METHOD_TYPE))
{ {
bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
if (TREE_CODE (type) != REFERENCE_TYPE)
bad_func_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
} }
...@@ -610,21 +617,23 @@ cp_build_qualified_type_real (type, type_quals, complain) ...@@ -610,21 +617,23 @@ cp_build_qualified_type_real (type, type_quals, complain)
/*OK*/; /*OK*/;
else if (!(complain & (tf_error | tf_ignore_bad_quals))) else if (!(complain & (tf_error | tf_ignore_bad_quals)))
return error_mark_node; return error_mark_node;
else if (bad_func_quals && !(complain & tf_error))
return error_mark_node;
else else
{ {
if (complain & tf_ignore_bad_quals) if (complain & tf_ignore_bad_quals)
/* We're not going to warn about constifying things that can't /* We're not going to warn about constifying things that can't
be constified. */ be constified. */
bad_quals &= ~TYPE_QUAL_CONST; bad_quals &= ~TYPE_QUAL_CONST;
bad_quals |= bad_func_quals;
if (bad_quals) if (bad_quals)
{ {
tree bad_type = build_qualified_type (ptr_type_node, bad_quals); tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
if (!(complain & tf_ignore_bad_quals)) if (!(complain & tf_ignore_bad_quals)
|| bad_func_quals)
error ("`%V' qualifiers cannot be applied to `%T'", error ("`%V' qualifiers cannot be applied to `%T'",
bad_type, type); bad_type, type);
else if (complain & tf_warning)
warning ("ignoring `%V' qualifiers on `%T'", bad_type, type);
} }
} }
......
...@@ -16,18 +16,20 @@ struct AS ...@@ -16,18 +16,20 @@ struct AS
template <typename T> struct B1 : T template <typename T> struct B1 : T
{ {
typedef typename T::L __restrict__ r;// { dg-error "`__restrict' qualifiers cannot" "" } typedef typename T::L __restrict__ r;// { dg-error "`__restrict' qualifiers cannot" "" }
typedef typename T::myT __restrict__ p;// { dg-warning "ignoring `__restrict'" "" } typedef typename T::myT __restrict__ p;// { dg-warning "ignoring `__restrict'" "" { xfail *-*-* } }
typedef typename T::myT volatile *myvolatile; // { dg-warning "ignoring `volatile'" "" } // The following are DR 295 dependent
typename T::myT volatile *a; // { dg-warning "ignoring `volatile'" "" } typedef typename T::myT volatile *myvolatile; // { dg-error "qualifiers" "" }
myvolatile b; // { dg-bogus "ignoring `volatile'" "" { xfail *-*-* } } typename T::myT volatile *a; // { dg-error "qualifiers" "" }
myvolatile b; // { dg-error "qualifiers" "" }
}; };
template <typename T> struct B2 : T template <typename T> struct B2 : T
{ {
typedef typename T::myT const *myconst; // The following are DR 295 dependent
typename T::myT const *a; typedef typename T::myT const *myconst; // { dg-error "qualifiers" "" }
myconst b; typename T::myT const *a; // { dg-error "qualifiers" "" }
myconst b; // { dg-error "qualifiers" "" }
}; };
B1<AS> b1; // { dg-error "instantiated" "" } B1<AS> b1; // { dg-error "instantiated" "" }
B2<AS> b2; B2<AS> b2; // { dg-error "instantiated" "" }
...@@ -46,8 +46,9 @@ class X{ ...@@ -46,8 +46,9 @@ class X{
}; };
typedef int const * bart (); typedef int const * bart ();
typedef bart const * const * bar2; // ok - constifying qualifiers //The following is DR295 dependant
typedef bart volatile * const * bar2v; // WARNING - qualifiers typedef bart const * const * bar2; // ERROR - constifying qualifiers
typedef bart volatile * const * bar2v; // ERROR - qualifiers
bar2 baz (X::Y y) bar2 baz (X::Y y)
{ // ERROR - in this context { // ERROR - in this context
......
...@@ -10,8 +10,9 @@ class ...@@ -10,8 +10,9 @@ class
{ {
public: public:
func_type *Function; func_type *Function;
const func_type* function(void) { return Function; } // ok constifying // The following is DR 295 dependent
volatile func_type* functionv(void); // WARNING - qualifier const func_type* function(void) { return Function; } // ERROR - constifying
volatile func_type* functionv(void); // ERROR - qualifier
} action; } action;
void work(const char *source) void work(const char *source)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment