]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Fri, 2 Sep 2005 09:25:13 +0000 (09:25 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 2 Sep 2005 09:25:13 +0000 (09:25 +0000)
2004-11-25  Mark Mitchell  <mark@codesourcery.com>
PR c++/18466
* decl.c (grokvardecl): Keep track of whether or not a there was
explicit qualification.
* name-lookup.c (set_decl_namespace): Complain about explicit
qualification of a name within its own namespace.

* g++.dg/parse/qualified3.C: New test.
* g++.old-deja/g++.other/friend7.C: Remove bogus qualification.

2004-11-29  Ben Elliston  <bje@au.ibm.com>
* g++.old-deja/g++.other/decl5.C: Remove remaining XFAILs.

From-SVN: r103768

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/decl5.C
gcc/testsuite/g++.old-deja/g++.other/friend7.C

index 211c9db75cc03aff9a02c47d341002827b703f00..231698e8a674e197fc6a4525c1e8f5a3e47172ef 100644 (file)
@@ -1,3 +1,14 @@
+2005-09-02  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-11-25  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18466
+       * decl.c (grokvardecl): Keep track of whether or not a there was
+       explicit qualification.
+       * name-lookup.c (set_decl_namespace): Complain about explicit
+       qualification of a name within its own namespace.
+
 2005-09-02  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 3f62ad5540d04134f17652a37276bb7cde8dd9c7..85aed90aee0612beb3ac611625dbc5702e04e47b 100644 (file)
@@ -5903,6 +5903,7 @@ grokvardecl (tree type,
              tree scope)
 {
   tree decl;
+  tree explicit_scope;
   RID_BIT_TYPE specbits;
 
   my_friendly_assert (!name || TREE_CODE (name) == IDENTIFIER_NODE, 
@@ -5910,7 +5911,9 @@ grokvardecl (tree type,
 
   specbits = *specbits_in;
 
-  /* Compute the scope in which to place the variable.  */
+  /* Compute the scope in which to place the variable, but remember
+     whether or not that scope was explicitly specified by the user.  */
+  explicit_scope = scope;
   if (!scope)
     {
       /* An explicit "extern" specifier indicates a namespace-scope
@@ -5939,8 +5942,8 @@ grokvardecl (tree type,
   else
     decl = build_decl (VAR_DECL, name, type);
 
-  if (scope && TREE_CODE (scope) == NAMESPACE_DECL)
-    set_decl_namespace (decl, scope, 0);
+  if (explicit_scope && TREE_CODE (explicit_scope) == NAMESPACE_DECL)
+    set_decl_namespace (decl, explicit_scope, 0);
   else
     DECL_CONTEXT (decl) = scope;
 
index dab2b57877506391eadf9394dc78a126a28c34dc..00a2f8f4e4590587ccc8d2e68903dcc0174ab2a5 100644 (file)
@@ -3021,7 +3021,13 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
          return;
     }
   else
-    return;
+    {
+      /* Writing "int N::i" to declare a variable within "N" is invalid.  */
+      if (at_namespace_scope_p ())
+       error ("explicit qualification in declaration of `%D'", decl);
+      return;
+    }
+
  complain:
   error ("`%D' should have been declared inside `%D'",
            decl, scope);
index 764e589c2ea0a4031f10c3ef0fbb9f0608a690dd..674838ccc1026723b49baa2cd6004dfd232caf1e 100644 (file)
@@ -1,3 +1,15 @@
+2005-09-02  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-11-25  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18466
+       * g++.dg/parse/qualified3.C: New test.
+       * g++.old-deja/g++.other/friend7.C: Remove bogus qualification.
+
+       2004-11-29  Ben Elliston  <bje@au.ibm.com>
+       * g++.old-deja/g++.other/decl5.C: Remove remaining XFAILs.
+
 2005-09-02  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 4aa1647548a74ae613febef680b94b3325e20427..f8c447c01d3b768ad5451d820b8ba4ef70082503 100644 (file)
@@ -52,8 +52,8 @@ namespace N {
 
 namespace NMS
 {
-  void NMS::fn();     // { dg-warning "" "" { xfail *-*-* } } extra qualification
-  int NMS::i;         // { dg-warning "" "" { xfail *-*-* } } extra qualification
+  void NMS::fn();     // { dg-warning "" "" } extra qualification
+  int NMS::i;         // { dg-warning "" "" } extra qualification
   struct NMS::D {     // { dg-warning "" } extra qualification
     int i;
   };
index 1055d99ceae74a49e62471e36879458863261211..aed56a187ddf4b503176573de3efd4830db61a2b 100644 (file)
@@ -15,7 +15,7 @@ class S {
 };
 } 
 
-void (::foo)(M::S *ptr) {
+void (foo)(M::S *ptr) {
   M::S::s.Fn();
   ptr->Fn();
 }