http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55742



             Bug #: 55742

           Summary: __attribute__ in class function declaration cause

                    "prototype does not match" errors.

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: dnovi...@gcc.gnu.org

                CC: tmsri...@google.com

              Host: x86_64-unknown-linux-gnu

            Target: x86_64-unknown-linux-gnu

             Build: x86_64-unknown-linux-gnu





The following code used to compile with GCC 4.7.  It fails on trunk with:



$ bld/xgcc -Bbld/ -c a.cc

a.cc:10:6: error: prototype for 'void A::E(uint64*, uint64*, const void*,

int64) const' does not match any in class 'A'

 void A::E(uint64 *l, uint64 *h, const void *b, int64 g) const

      ^

a.cc:6:18: error: candidate is: virtual void A::E(uint64*, uint64*, const

void*, int64) const

     virtual void E(uint64 *l, uint64 *h, const void *b, int64 g) const





typedef unsigned long long uint64;

typedef long long int64;



class A {

  public:

    virtual void E(uint64 *l, uint64 *h, const void *b, int64 g) const

        __attribute__ ((__target__ ("sse4")));

};



void A::E(uint64 *l, uint64 *h, const void *b, int64 g) const

{

    *l = *h + g;

    if (b) return;

}



This seems to be a bug in the multiversioning logic.  We fail to match the

function to its declaration in decl2.c:check_classfn because

ix86_function_versions returns true.



676

677               /* While finding a match, same types and params are not

enough

678                  if the function is versioned.  Also check version

("target")

679                  attributes.  */

680               if (same_type_p (TREE_TYPE (TREE_TYPE (function)),

681                                TREE_TYPE (TREE_TYPE (fndecl)))

682                   && compparms (p1, p2)

683                   && !targetm.target_option.function_versions (function,

fndecl)

684                   && (!is_template

685                       || comp_template_parms (template_parms,

686                                               DECL_TEMPLATE_PARMS

(fndecl)))

687                   && (DECL_TEMPLATE_SPECIALIZATION (function)

688                       == DECL_TEMPLATE_SPECIALIZATION (fndecl))

689                   && (!DECL_TEMPLATE_SPECIALIZATION (function)

690                       || (DECL_TI_TEMPLATE (function)

691                           == DECL_TI_TEMPLATE (fndecl))))

692                 break;



While this agrees with the logic of the multiversion test, it is not the

appropriate context to be checking for multiversions, I think.



Here we are comparing a function *declaration* with a function *definition*. 

The function definition can never have attributes (only declarations do).  So I

*think* the right fix here is to not call the multiversion hook.



Sri, could you take a look?  This bug is causing build failures with our

internal code base.





Thanks.

Reply via email to