[cfe-dev] clang crashes on (non-template) friend declaration.

John McCall rjmccall at apple.com
Sat Jan 30 13:05:16 PST 2010


On Jan 30, 2010, at 1:14 AM, Enea Zaffanella wrote:

> John McCall wrote:
> [...]
>> Sounds like a new bug.  Please go ahead and file this, and I'll get
>> to it soon, probably within the next week or so.  Thanks!
>> John.
> 
> We have found other errors related to non-template friend declarations.
> 
> ====================
> struct F {};
> 
> struct S {
>  friend F::F();
>  friend F::~F();
> };
> ====================
> 
> $ llvm/Debug/bin/clang++ -fsyntax-only bug.cc
> bug.cc:4:15: error: expected member name or ';' after declaration specifiers
>  friend F::F();
>  ~~~~~~~~~~~ ^
> bug.cc:5:13: error: definition of implicitly declared destructor
>  friend F::~F();
>            ^
> bug.cc:1:8: note: previous implicit declaration is here
> struct F {};
>       ^
> 3 diagnostics generated.
> 
> =====================
> 
> In the first case, it looks as if the constructor name is misinterpreted to be part of the name qualifiers (maybe due to class name injection?).
> The buggy error diagnostic is still there if the constructor is declared explicitly or if a different constructor is used.
> 
> In the second case, the friend declaration is misinterpreted as if it was defining the implicit constructor. The same buggy error diagnostic is obtained if the implicit copy assignment operator is declared friend.
> 
> Should we add this example to the bug report just created?

These are unrelated problems and probably merit their own PR.  Thanks!

John.



More information about the cfe-dev mailing list