[Bug c++/84897] Better handling of unqualified "string"

2018-12-16 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84897

Eric Gallager  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=88501

--- Comment #6 from Eric Gallager  ---
semi-related: bug 88501
(ok not really THAT related, but it still made me think of it)

[Bug c++/84897] Better handling of unqualified "string"

2018-06-17 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84897

Eric Gallager  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #5 from Eric Gallager  ---
Changing status to ASSIGNED since there's an assignee.

[Bug c++/84897] Better handling of unqualified "string"

2018-03-16 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84897

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #4 from Eric Gallager  ---
(In reply to David Malcolm from comment #0)
> Reddit user "Boojum" suggested:
> 
> > As far as other paper cuts, here's one that catches me
> > surprisingly frequently:
> 
> #include 
> int main() {
> string x("foo");
> }
> 
> > Obviously, I "forgot" to either qualify string as std::string,
> > add using namespace std;, or add using std::string;.
> >
> > Here's what GCC 7.2 tells me (header paths elided):
> 
> namespace.cpp: In function ‘int main()’:
> namespace.cpp:3:5: error: ‘string’ was not declared in this scope
>  string x("foo");
>  ^~
> namespace.cpp:3:5: note: suggested alternatives:
> In file included from .../string:39:0,
>  from namespace.cpp:1:
> .../stringfwd.h:74:33: note:   ‘std::__cxx11::string’
>typedef basic_stringstring;
>  ^~
> .../stringfwd.h:74:33: note:   ‘std::__cxx11::string’
> 
> > On the other hand, here's what Clang 6 tells me:
> 
> namespace.cpp:3:5: error: unknown type name 'string'; did you mean
> 'std::string'?
> string x("foo");
> ^~
> std::string
> .../stringfwd.h:74:33: note: 'std::string' declared here
>   typedef basic_stringstring;
> ^
> 1 error generated.
> 
> > Much nicer. It tells me exactly which namespace I probably
> > meant to use and proposes a fix-it qualifying the identifier.
> 

Link to this comment is here:
https://www.reddit.com/r/programming/comments/84oizv/usability_improvements_in_gcc_8/dvrj48o/

[Bug c++/84897] Better handling of unqualified "string"

2018-03-16 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84897

--- Comment #3 from Andrew Pinski  ---
(In reply to Jonathan Wakely from comment #2)
> Yes, we want to special case the inline namespaces std::__cxx11 and std::_V2
> so that they only show their contents as std::xxx not std::_V2::xxx. Or
> maybe automatically elide any inline namespace under std, so that we show
> std::experimental::source_location not
> std::experimental::fundamentals_v2::source_location. The point of an inline
> namespace is that you don't need to use it to refer to the type, the type
> can be named as though it was declared in the enclosing namespace.

I don't think we want to special case anything.  I think we want to
automtically elide any (all) inline namespace even ones which are not under
std.

[Bug c++/84897] Better handling of unqualified "string"

2018-03-16 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84897

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-03-16
 Ever confirmed|0   |1

--- Comment #2 from Jonathan Wakely  ---
Yes, we want to special case the inline namespaces std::__cxx11 and std::_V2 so
that they only show their contents as std::xxx not std::_V2::xxx. Or maybe
automatically elide any inline namespace under std, so that we show
std::experimental::source_location not
std::experimental::fundamentals_v2::source_location. The point of an inline
namespace is that you don't need to use it to refer to the type, the type can
be named as though it was declared in the enclosing namespace.

Clang's libc++ std::string is really std::__v1::string but it hides the inline
namespace __v1 from you.

[Bug c++/84897] Better handling of unqualified "string"

2018-03-15 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84897

--- Comment #1 from Andrew Pinski  ---
Rather we should not report the inline namespace __cx11 .I suspect you can come
up with a shorter t estcase which does not use any includes.