[Mesa-dev] [RFC] Fix for clang compiler issue as reported in Bug 91826

Francisco Jerez currojerez at riseup.net
Tue Sep 1 12:00:04 PDT 2015


Matt Turner <mattst88 at gmail.com> writes:

> On Tue, Sep 1, 2015 at 10:10 AM, Albert Freeman
> <albertwdfreeman at gmail.com> wrote:
>> Clang tryed to declare the non type member of struct module (enum type type) (in clover/core/module.hpp) instead of a variable of type enum (enum type).
>>
>> Signed-off-by: Albert Freeman <albertwdfreeman at gmail.com>
>> ---
>
> Thanks for your first patch :)
>
> The subject and commit message don't really match the Mesa styles. We
> prefix the subject with the area that the code affects -- in this case
> "clover: "
>
> How about
>
> clover: Avoid using typename with ... TBD
>
> clover/core/module.hpp declares "type" to be "enum type". Using the
> typename keyword, clang attempted to declare the variable with the
> same type as "module" instead of "module::argument::type". Just use
> enum to avoid this.
>
> Reviewed by Serge Martin <edb+mesa at sigluy.net>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91826
>
>
>
> But I'm curious if this code is exposing a bug in clang, relies on a
> language extension clang doesn't implement, or is simply wrong? Curro
> (Cc'd) will probably know.
>
Heh, I suspect the previous code was ill-formed and Clang correctly
rejected it.  I may be wrong but I don't think that typename is supposed
to alter the look-up rules to give you a type which was previously
hidden by a variable declaration of the same name (as e.g. enum or
struct do).

With Matt's suggestions this patch is:

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

>>  src/gallium/state_trackers/clover/llvm/invocation.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
>> index 7c23a27..d74b50d 100644
>> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
>> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
>> @@ -465,7 +465,7 @@ namespace {
>>              const bool is_write_only = access_qual == "write_only";
>>              const bool is_read_only = access_qual == "read_only";
>>
>> -            typename module::argument::type marg_type;
>> +            enum module::argument::type marg_type;
>>              if (is_image2d && is_read_only) {
>>                 marg_type = module::argument::image2d_rd;
>>              } else if (is_image2d && is_write_only) {
>> --
>> 2.5.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150901/058cc4de/attachment.sig>


More information about the mesa-dev mailing list