This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Improve diagnostic for invalid using declarations


For the testcase

  using N::i;

we get the error message

  bug.cc:1: error: 'N' has not been declared
  bug.cc:1: error: '<declaration error>::i' has not been declared

The second line is superfluous IMHO.
The following patch removes the second error message by bypassing
name-lookup in cp_parser_using_declaration on invalid scope.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline?
Ok for the 4.1 branch, since the "<declaration error>" message is a
regression from previous versions?

Regards,
Volker

:ADDPATCH C++:


2005-12-23  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	* parser.c (cp_parser_using_declaration): Skip name-lookup on
	invalid scope.

===================================================================
--- gcc/gcc/cp/parser.c	(revision 108938)
+++ gcc/gcc/cp/parser.c	(working copy)
@@ -10479,7 +10479,7 @@
 
   /* The function we call to handle a using-declaration is different
      depending on what scope we are in.  */
-  if (identifier == error_mark_node)
+  if (qscope == error_mark_node || identifier == error_mark_node)
     ;
   else if (TREE_CODE (identifier) != IDENTIFIER_NODE
 	   && TREE_CODE (identifier) != BIT_NOT_EXPR)
===================================================================

2005-12-23  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	* g++.dg/lookup/using12.C: Tighten error marker.

===================================================================
--- gcc/gcc/testsuite/g++.dg/lookup/using12.C      (revision 108938)
+++ gcc/gcc/testsuite/g++.dg/lookup/using12.C      (working copy)
@@ -1,4 +1,4 @@
 // PR c++/16707
 
 int i;
-using N::i; // { dg-error "declared|expected" }
+using N::i; // { dg-error "'N' has not been declared" }
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]