[Bug c++/81064] [8 Regression] Inline namespace regression

2017-06-12 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81064

Nathan Sidwell  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #3 from Nathan Sidwell  ---
Thanks for the reduced testcase.  This is caused by:
2017-05-26  Nathan Sidwell  

Implement DR2061
* name-lookup.c (push_inline_namespaces): New.
(push_namespace): Look inside inline namespaces.

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2061

I think I've implemented it correctly, and that the testcase is ill-formed. 
Perhaps we could check whenever creating a new namepace that it doesn't cause
an ambiguity within the 'local' inline namespace tree.  (though, such an
ambiguity could occur on declaring any new name, not just a namespace).

2061. Inline namespace after simplifications
Section: 7.3.1  [namespace.def] Status: CD4 Submitter: Richard Smith   
 Date: 2014-12-18

[Adopted at the February, 2016 meeting.]

After the resolution of issue 1795, 7.3.1 [namespace.def] paragraph 3 now says:

In a named-namespace-definition, the identifier is the name of the
namespace. If the identifier, when looked up (3.4.1 [basic.lookup.unqual]),
refers to a namespace-name (but not a namespace-alias) introduced in the
declarative region in which the named-namespace-definition appears, the
namespace-definition extends the previously-declared namespace. Otherwise, the
identifier is introduced as a namespace-name into the declarative region in
which the named-namespace-definition appears. 

This appears to break code like the following:

  namespace A {
inline namespace b {
  namespace C {
template void f();
  }
}
  }

  namespace A {
namespace C {
  template<> void f() { }
}
  }

because (by definition of “declarative region”) C cannot be used as an
unqualified name to refer to A::b::C within A if its declarative region is
A::b.

Proposed resolution (September, 2015):

Change 7.3.1 [namespace.def] paragraph 3 as follows:

In a named-namespace-definition, the identifier is the name of the
namespace. If the identifier, when looked up (3.4.1 [basic.lookup.unqual]),
refers to a namespace-name (but not a namespace-alias) that was introduced in
the declarative region namespace in which the named-namespace-definition
appears or that was introduced in a member of the inline namespace set of that
namespace, the namespace-definition extends the previously-declared namespace.
Otherwise, the identifier is introduced as a namespace-name into the
declarative region in which the named-namespace-definition appears.

[Bug c++/81064] [8 Regression] Inline namespace regression

2017-06-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81064

--- Comment #2 from Jonathan Wakely  ---
EDG warns for that code:

"ns.cc", line 9: warning: a redeclaration of inline namespace "n1::in" must be
  declared inline
namespace in { }
^


But trunk still rejects it even with that change:

namespace n1 {
  inline namespace in { }
  inline namespace n2 {
inline namespace in { }
  }
}

namespace n1 {
  inline namespace in { }
}


ns.cc:9:20: error: conflicting declaration of namespace ‘n1::in’
   inline namespace in { }
^~
ns.cc:2:20: note: previous declaration of namespace ‘n1::in’ here
   inline namespace in { }
^~

[Bug c++/81064] [8 Regression] Inline namespace regression

2017-06-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81064

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-06-12
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
Confirmed:

namespace n1 {
  inline namespace in { }
  inline namespace n2 {
inline namespace in { }
  }
}

namespace n1 {
  namespace in { }
}

ns.cc:9:13: error: conflicting declaration of namespace ‘n1::in’
   namespace in { }
 ^~
ns.cc:2:20: note: previous declaration of namespace ‘n1::in’ here
   inline namespace in { }
^~


Aside: do we really want to translate "namespace" in diagnostics?

[Bug c++/81064] [8 Regression] Inline namespace regression

2017-06-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81064

Richard Biener  changed:

   What|Removed |Added

   Keywords||rejects-valid
   Target Milestone|--- |8.0
Summary|Inline namespace regression |[8 Regression] Inline
   ||namespace regression