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

Richard Smith richard at metafoo.co.uk
Sun Oct 28 00:23:13 PDT 2012


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.




More information about the llvm-commits mailing list