public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55742] New: __attribute__ in class function declaration cause "prototype does not match" errors.
@ 2012-12-19 16:46 dnovillo at gcc dot gnu.org
  2012-12-19 23:30 ` [Bug c++/55742] " tmsriram at google dot com
                   ` (45 more replies)
  0 siblings, 46 replies; 47+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2012-12-19 16:46 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: dnovillo@gcc.gnu.org
                CC: tmsriram@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.


^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2013-01-30 18:18 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 16:46 [Bug c++/55742] New: __attribute__ in class function declaration cause "prototype does not match" errors dnovillo at gcc dot gnu.org
2012-12-19 23:30 ` [Bug c++/55742] " tmsriram at google dot com
2012-12-20 18:00 ` dnovillo at gcc dot gnu.org
2012-12-20 18:21 ` tmsriram at google dot com
2012-12-20 18:24 ` dnovillo at google dot com
2012-12-20 19:37 ` tmsriram at google dot com
2012-12-20 19:52 ` xinliangli at gmail dot com
2013-01-10 22:10 ` tmsriram at google dot com
2013-01-14 14:33 ` [Bug c++/55742] [4.8 regression] " jason at gcc dot gnu.org
2013-01-14 14:35 ` rguenth at gcc dot gnu.org
2013-01-14 14:38 ` rguenth at gcc dot gnu.org
2013-01-14 15:14 ` jakub at gcc dot gnu.org
2013-01-14 17:17 ` xinliangli at gmail dot com
2013-01-14 17:21 ` xinliangli at gmail dot com
2013-01-14 17:46 ` tmsriram at google dot com
2013-01-14 17:50 ` xinliangli at gmail dot com
2013-01-14 18:07 ` tmsriram at google dot com
2013-01-14 18:26 ` jakub at gcc dot gnu.org
2013-01-14 18:33 ` jakub at gcc dot gnu.org
2013-01-14 20:18 ` xinliangli at gmail dot com
2013-01-14 20:24 ` jakub at gcc dot gnu.org
2013-01-14 20:30 ` xinliangli at gmail dot com
2013-01-15 18:45 ` jason at gcc dot gnu.org
2013-01-15 19:03 ` xinliangli at gmail dot com
2013-01-16  8:12 ` jakub at gcc dot gnu.org
2013-01-16 15:54 ` jason at gcc dot gnu.org
2013-01-16 16:03 ` jakub at gcc dot gnu.org
2013-01-16 16:06 ` richard.guenther at gmail dot com
2013-01-16 17:21 ` tmsriram at google dot com
2013-01-16 17:26 ` tmsriram at google dot com
2013-01-16 20:04 ` jason at gcc dot gnu.org
2013-01-17 22:45 ` xinliangli at gmail dot com
2013-01-18  9:49 ` richard.guenther at gmail dot com
2013-01-18 14:19 ` jakub at gcc dot gnu.org
2013-01-18 16:59 ` jason at gcc dot gnu.org
2013-01-18 17:28 ` xinliangli at gmail dot com
2013-01-18 17:52 ` jakub at gcc dot gnu.org
2013-01-18 18:03 ` tmsriram at google dot com
2013-01-18 18:08 ` tmsriram at google dot com
2013-01-18 19:53 ` tmsriram at google dot com
2013-01-19 10:14 ` jakub at gcc dot gnu.org
2013-01-19 10:28 ` jakub at gcc dot gnu.org
2013-01-19 17:18 ` tmsriram at google dot com
2013-01-21 11:41 ` jakub at gcc dot gnu.org
2013-01-23 16:39 ` jakub at gcc dot gnu.org
2013-01-30 18:05 ` jakub at gcc dot gnu.org
2013-01-30 18:18 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).