[llvm-commits] [PATCH] Add declaration of hash_value in APFloat / APInt (required for xlC on AIX)

Kai kai at redstar.de
Sun Oct 28 04:42:59 PDT 2012


On 28.10.2012 08:23, Richard Smith wrote:
> On Sat, Oct 27, 2012 at 10:19 PM, David Blaikie <dblaikie at gmail.com> wrote:
>> On Sat, Oct 27, 2012 at 12:29 PM, Kai <kai at redstar.de> wrote:
>>> Hi!
>>>
>>> I am trying to compile LLVM with the IBM xlC compiler on AIX 7.1 The first
>>> issue I encounter is that the function hash_value() is declared as a friend
>>> of APFloat and APInt, but no matching declaration is provided. This results
>>> in the error message:
>>>
>>> "../llvm-git/lib/Support/APFloat.cpp", line 2731.11: 1540-0432 (S) The
>>> qualified declarator "llvm::hash_value" must refer to an existing
>>> declaration.
>>>
>>> The draft standard says in section 7.3.1.2 "Namespace member definitions":
>>>
>>> "... If a friend declaration in a non-local class first declares a class or
>>> function95 the friend class or function is a member of the innermost
>>> enclosing namespace. The name of the friend is not found by unqualified
>>> lookup (3.4.1) or by qualified lookup (3.4.3) until a matching declaration
>>> is provided in that namespace scope (either before or after the class
>>> definition granting friendship). ..."
>>>
>>> I conclude that the declaration is required for conformance with the C++
>>> standard. The attached patch resolves the problem.
>>>
>>> Please review and commit if it looks good.
>>
>> Would you mind filing a Clang bug if this isn't being currently
>> diagnosed by Clang?
>
> This is an xlc bug, not a Clang bug. We discussed this exact case at
> Portland, in the context of core issue 1477. The relevant rules are...
>
> 8.3/1: When the declarator-id is qualified, the declaration shall refer
> to a previously declared member of the class or namespace to which the
> qualifier refers [...]
>
> ... and a friend declared in a class is a previously-declared member
> of the surrounding namespace (even though it hasn't been declared *in*
> that namespace):
>
> 7.3.1.2/3: If a friend declaration in a non-local class first declares
> a class or function the friend class or function is a member of the
> innermost enclosing namespace.

Ok, I do not want to restart a already held discussion. The simple fact 
is that xlC produces an error without the declaration. Should I put a 
comment before the declaration explaining the need for it?

>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>





More information about the llvm-commits mailing list