+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:
tree scope)
{
tree decl;
+ tree explicit_scope;
RID_BIT_TYPE specbits;
my_friendly_assert (!name || TREE_CODE (name) == IDENTIFIER_NODE,
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
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;
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);
+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:
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;
};
};
}
-void (::foo)(M::S *ptr) {
+void (foo)(M::S *ptr) {
M::S::s.Fn();
ptr->Fn();
}