[llvm-bugs] [Bug 28422] New: enum return value on friend function spacified as from global namespace ignores whitespace
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jul 5 02:39:27 PDT 2016
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: unassignedclangbugs at nondot.org
Reporter: gw.fossdev at gmail.com
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160705/365569fe/attachment.html>
More information about the llvm-bugs
mailing list