diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 92e5751840cd1291939d5bbd3ad0f404755e21ad..c7ff194f0d7912ba764a69ef39a5e9014da93b72 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
 2004-08-17  Mark Mitchell  <mark@codesourcery.com>
 
+	PR c++/16215
+	* parser.c (cp_parser_name_lookup_error): If parser->object_scope
+	is set use it for diagnostic purposes.
+	(cp_parser_pseudo_destructor_name): Remove special-case error
+	message.
+
 	PR c++/15871
 	* semantics.c (expand_or_defer_fn): Honor -fkeep-inline-functions.
 
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index fa41ce6b00d083e2a4e441efed35124988790fd5..999c528f638d2867a61f6827949441ac3e10635e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2018,6 +2018,13 @@ cp_parser_name_lookup_error (cp_parser* parser,
 	       parser->scope, name);
       else if (parser->scope == global_namespace)
 	error ("`::%D' has not been declared", name);
+      else if (parser->object_scope 
+	       && !CLASS_TYPE_P (parser->object_scope))
+	error ("request for member `%D' in non-class type `%T'",
+	       name, parser->object_scope);
+      else if (parser->object_scope)
+	error ("`%T::%D' has not been declared", 
+	       parser->object_scope, name);
       else
 	error ("`%D' has not been declared", name);
     }
@@ -4488,6 +4495,9 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
 {
   bool nested_name_specifier_p;
 
+  /* Assume that things will not work out.  */
+  *type = error_mark_node;
+
   /* Look for the optional `::' operator.  */
   cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/true);
   /* Look for the optional nested-name-specifier.  */
@@ -4520,17 +4530,18 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
       /* Look for the type-name.  */
       *scope = TREE_TYPE (cp_parser_type_name (parser));
 
-      /* If we didn't get an aggregate type, or we don't have ::~,
-	 then something has gone wrong.  Since the only caller of this
-	 function is looking for something after `.' or `->' after a
-	 scalar type, most likely the program is trying to get a
-	 member of a non-aggregate type.  */
-      if (*scope == error_mark_node
-	  || cp_lexer_next_token_is_not (parser->lexer, CPP_SCOPE)
+      if (*scope == error_mark_node)
+	return;
+
+      /* If we don't have ::~, then something has gone wrong.  Since
+	 the only caller of this function is looking for something
+	 after `.' or `->' after a scalar type, most likely the
+	 program is trying to get a member of a non-aggregate
+	 type.  */
+      if (cp_lexer_next_token_is_not (parser->lexer, CPP_SCOPE)
 	  || cp_lexer_peek_nth_token (parser->lexer, 2)->type != CPP_COMPL)
 	{
 	  cp_parser_error (parser, "request for member of non-aggregate type");
-	  *type = error_mark_node;
 	  return;
 	}