llvm-gcc-4.2-2.9/gcc/cp/parser.c
/* Emit a diagnostic for an invalid type name.  SCOPE is the
   qualifying scope (or NULL, if none) for ID.  This function commits
   to the current active tentative parse, if any.  (Otherwise, the
   problematic construct might be encountered again later, resulting
   in duplicate error messages.)  */
Emit a diagnostic for an invalid type name.  SCOPE is the
qualifying scope (or NULL, if none) for ID.  This function commits
to the current active tentative parse, if any.  (Otherwise, the
problematic construct might be encountered again later, resulting
in duplicate error messages.)
Emit a diagnostic for an invalid type name . SCOPE is the qualifying scope ( or NULL if none ) for ID . This function commits to the current active tentative parse if any . ( Otherwise the problematic construct might be encountered again later resulting in duplicate error messages . )
static void
cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id)
{
  tree decl, old_scope;
  old_scope = parser->scope;
  parser->scope = scope;
  decl = cp_parser_lookup_name_simple (parser, id);
  parser->scope = old_scope;
  if (TREE_CODE (decl) == TEMPLATE_DECL)
    error ("invalid use of template-name %qE without an argument list", decl);
  else if (TREE_CODE (id) == BIT_NOT_EXPR)
    error ("invalid use of destructor %qD as a type", id);
  else if (TREE_CODE (decl) == TYPE_DECL)
    error ("invalid combination of multiple type-specifiers");
  else if (!parser->scope)
    {
      error ("%qE does not name a type", id);
      if (processing_template_decl && current_class_type
	  && TYPE_BINFO (current_class_type))
	{
	  tree b;
	  for (b = TREE_CHAIN (TYPE_BINFO (current_class_type));
	       b;
	       b = TREE_CHAIN (b))
	    {
	      tree base_type = BINFO_TYPE (b);
	      if (CLASS_TYPE_P (base_type)
		  && dependent_type_p (base_type))
		{
		  tree field;
		  base_type = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (base_type);
		  for (field = TYPE_FIELDS (base_type);
		       field;
		       field = TREE_CHAIN (field))
		    if (TREE_CODE (field) == TYPE_DECL
			&& DECL_NAME (field) == id)
		      {
			inform ("(perhaps %<typename %T::%E%> was intended)",
				BINFO_TYPE (b), id);
			break;
		      }
		  if (field)
		    break;
		}
	    }
	}
    }
  else if (parser->scope != error_mark_node)
    {
      if (TREE_CODE (parser->scope) == NAMESPACE_DECL)
	error ("%qE in namespace %qE does not name a type",
	       id, parser->scope);
      else if (TYPE_P (parser->scope))
	error ("%qE in class %qT does not name a type", id, parser->scope);
      else
	gcc_unreachable ();
    }
  cp_parser_commit_to_tentative_parse (parser);
}
static void cp_parser_diagnose_invalid_type_name ( cp_parser * parser , tree scope , tree id ) { tree decl , old_scope ; old_scope = parser -> scope ; parser -> scope = scope ; decl = cp_parser_lookup_name_simple ( parser , id ) ; parser -> scope = old_scope ; if ( TREE_CODE ( decl ) == TEMPLATE_DECL ) error ( " " , decl ) ; else if ( TREE_CODE ( id ) == BIT_NOT_EXPR ) error ( " " , id ) ; else if ( TREE_CODE ( decl ) == TYPE_DECL ) error ( " " ) ; else if ( ! parser -> scope ) { error ( " " , id ) ; if ( processing_template_decl && current_class_type && TYPE_BINFO ( current_class_type ) ) { tree b ; for ( b = TREE_CHAIN ( TYPE_BINFO ( current_class_type ) ) ; b ; b = TREE_CHAIN ( b ) ) { tree base_type = BINFO_TYPE ( b ) ; if ( CLASS_TYPE_P ( base_type ) && dependent_type_p ( base_type ) ) { tree field ; base_type = CLASSTYPE_PRIMARY_TEMPLATE_TYPE ( base_type ) ; for ( field = TYPE_FIELDS ( base_type ) ; field ; field = TREE_CHAIN ( field ) ) if ( TREE_CODE ( field ) == TYPE_DECL && DECL_NAME ( field ) == id ) { inform ( " " , BINFO_TYPE ( b ) , id ) ; break ; } if ( field ) break ; } } } } else if ( parser -> scope != error_mark_node ) { if ( TREE_CODE ( parser -> scope ) == NAMESPACE_DECL ) error ( " " , id , parser -> scope ) ; else if ( TYPE_P ( parser -> scope ) ) error ( " " , id , parser -> scope ) ; else gcc_unreachable ( ) ; } cp_parser_commit_to_tentative_parse ( parser ) ; }
Emit a diagnostic for an invalid type name.
Emit a diagnostic for an invalid type name .
/* Try to lookup the identifier.  */ /* If the lookup found a template-name, it means that the user forgot
  to specify an argument list. Emit a useful error message.  */ /* Something like 'unsigned A a;'  */ /* Issue an error message.  */ /* If we're in a template class, it's possible that the user was
	 referring to a type from a base class.  For example:

	   template <typename T> struct A { typedef T X; };
	   template <typename T> struct B : public A<T> { X x; };

	 The user should have said "typename A<T>::X".  */ /* Go from a particular instantiation of the
		     template (which will have an empty TYPE_FIELDs),
		     to the main version.  */ /* Here we diagnose qualified-ids where the scope is actually correct,
     but the identifier does not resolve to a valid type name.  */