re PR c++/13377 (unexpected behavior of namespace usage directive)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Wed, 31 Aug 2005 10:32:54 +0000 (10:32 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Wed, 31 Aug 2005 10:32:54 +0000 (10:32 +0000)
PR c++/13377
* parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to
lookup_name_real on final parse.

* g++.dg/lookup/ambig4.C: New test.
* g++.dg/lookup/ambig5.C: New test.
* g++.dg/tc1/dr101.C: Adjust error markers.

From-SVN: r103667

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/ambig4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lookup/ambig5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tc1/dr101.C

index cc6a9696873ec3190502540885e988090c275e3e..aa8ce8917e1c046c9ce73c2a62e231f8615b39f3 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/13377
+       * parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to
+       lookup_name_real on final parse.
+
 2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23639
index bebdfcbb5fe73dc6a3e150adc4e990092d938b6a..f6b5381f5a3cfb85d6864e06fcb5da31bc1ee285 100644 (file)
@@ -14464,9 +14464,13 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
                       bool check_dependency,
                       bool *ambiguous_p)
 {
+  int flags = 0;
   tree decl;
   tree object_type = parser->context->object_type;
 
+  if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
+    flags |= LOOKUP_COMPLAIN;
+
   /* Assume that the lookup will be unambiguous.  */
   if (ambiguous_p)
     *ambiguous_p = false;
@@ -14599,8 +14603,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
       /* Look it up in the enclosing context, too.  */
       decl = lookup_name_real (name, tag_type != none_type,
                               /*nonclass=*/0,
-                              /*block_p=*/true, is_namespace,
-                              /*flags=*/0);
+                              /*block_p=*/true, is_namespace, flags);
       parser->object_scope = object_type;
       parser->qualifying_scope = NULL_TREE;
       if (object_decl)
@@ -14610,8 +14613,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
     {
       decl = lookup_name_real (name, tag_type != none_type,
                               /*nonclass=*/0,
-                              /*block_p=*/true, is_namespace,
-                              /*flags=*/0);
+                              /*block_p=*/true, is_namespace, flags);
       parser->qualifying_scope = NULL_TREE;
       parser->object_scope = NULL_TREE;
     }
index e457ae40d42b6643309c6c018ffba31bbfe22f65..5fbdb9e01fbee840a4569405cd8484cf968f1e13 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/13377
+       * g++.dg/lookup/ambig4.C: New test.
+       * g++.dg/lookup/ambig5.C: New test.
+       * g++.dg/tc1/dr101.C: Adjust error markers.
+
 2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23639
diff --git a/gcc/testsuite/g++.dg/lookup/ambig4.C b/gcc/testsuite/g++.dg/lookup/ambig4.C
new file mode 100644 (file)
index 0000000..ab1a145
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/13377
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+// { dg-do compile }
+
+namespace N
+{
+  int i;            // { dg-error "declared" }
+}
+
+int i;              // { dg-error "declared" }
+
+using namespace N;
+
+void foo() { i; }   // { dg-error "in this scope|ambiguous" }
diff --git a/gcc/testsuite/g++.dg/lookup/ambig5.C b/gcc/testsuite/g++.dg/lookup/ambig5.C
new file mode 100644 (file)
index 0000000..8f74efc
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/13377
+// Origin: Boris Kolpackov <boris@kolpackov.net>
+// { dg-do compile }
+
+namespace N
+{
+  namespace M {}    // { dg-error "declared" }
+}
+
+namespace M {}      // { dg-error "declared" }
+
+using namespace N;
+using namespace M;  // { dg-error "namespace-name|ambiguous" }
index ede2215601f0341bfce37870d7bd7505293cd0b5..8d9cab518b9bd133cbde42745083ef8c05d4a66c 100644 (file)
@@ -17,10 +17,10 @@ namespace Test1 {
 
 namespace Test2 {
 
-  typedef unsigned int X;
+  typedef unsigned int X;   // { dg-bogus "declared" "" { xfail *-*-* } }
   extern "C" int f2();
   namespace N {
-    typedef unsigned int X;
+    typedef unsigned int X; // { dg-bogus "declared" "" { xfail *-*-* } }
     extern "C" int f2();
   }
   using namespace N;