[Bug c++/41020] [4.5 Regression] Can't declare an extern "C" friend.
davek at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Aug 10 17:16:00 GMT 2009
------- Comment #5 from davek at gcc dot gnu dot org 2009-08-10 17:16 -------
(In reply to comment #4)
> It's irrelevant to this bug and is just me being more pedantic than -pedantic,
> however ... even with -pedantic GCC has always accepted stray semi-colons at
> namespace scope, but it's not valid.
>
> At function scope a lone ';' is a valid expression-statement, but
> expression-statements are not allowed at namespace scope, only declarations
> are, and ';' is not a valid declaration.
Well you learn something new every day! Never realised that was a gnu
extension, but it sure is, comeau online choked on my testcase:
"ComeauTest.c", line 5: error: extra ";" ignored,
In C: A function definition does not end with a semicolon
In C++: A non-member function definition, extern "C" block,
or namespace does not end with a semicolon
};
^
Anyway. Consider the testcase amended. :-)
$ cat friend.cxx
extern "C"
{
int fork (void);
}
class frok
{
int this_errno;
friend int fork (void);
};
extern "C" int
fork (void)
{
frok grouped;
return grouped.this_errno;
}
$ g++-4 -c friend.cxx -o friend.o
friend.cxx:10:24: error: new declaration 'int fork()'
friend.cxx:4:7: error: ambiguates old declaration 'int fork()'
friend.cxx: In function 'int fork()':
friend.cxx:9:7: error: 'int frok::this_errno' is private
friend.cxx:17:18: error: within this context
$
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41020
More information about the Gcc-bugs
mailing list