https://llvm.org/bugs/show_bug.cgi?id=28422
Bug ID: 28422 Summary: enum return value on friend function spacified as from global namespace ignores whitespace Product: clang Version: 3.7 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: gw.foss...@gmail.com CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 16687 --> https://llvm.org/bugs/attachment.cgi?id=16687&action=edit test case Dear all, I've came across a wired problem when declaring a function as friend when it is specified to be in the global namespace and has an enum as return value (see attached test case). When I compile the example with -std=c++11 I get the error whitespace_eating.cc:8:20: error: C++ requires a type specifier for all declarations friend enu ::wow(); compiling with std=c++03 gives whitespace_eating.cc:8:14: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions] friend enu ::wow(); ^ whitespace_eating.cc:8:20: error: C++ requires a type specifier for all declarations friend enu ::wow(); Given these error messages I can only assume that the parser discards the whitespace between "enu" and "::wow". Removing the global namespace specifier "::" before "wow" also results in compilation errors because now the friend declaration of wow() is assumed to reside in the "fun" namespace (as it should be) - i.e. this is no workaround. I've seen the same problem with version 3.9.0-svn274438-1 and 3.7.1 (tags/RELEASE_371/final). I've also reported a similar bug against g++-6 in the Debian bug tracker [1], but g++ accepts the construct in c++03 mode. I've also tested this with "enu" being a struct with similar results, i.e. the white space between the return type and :: is ignored. If "enu" is replaced by "int" then the code compiles fine. Any insight is highly appreciated. Many thanks, Gert [1] https://bugs.debian.org/829604 PS: the original code that made me encounter the problem is some third party project that uses bison to create some of the code and also the enums. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs