Revert "Fix for PR6953: per gcc, regparm and noreturn affect the compatibility of", it is breaking the builds of quite a few projects (emacs, dovecot, gnutar, bison).

llvm-svn: 102501
This commit is contained in:
Daniel Dunbar 2010-04-28 16:20:58 +00:00
parent c83726e64e
commit edd5bae86c
2 changed files with 18 additions and 17 deletions

View File

@ -4311,16 +4311,21 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
allLTypes = false;
if (getCanonicalType(retType) != getCanonicalType(rbase->getResultType()))
allRTypes = false;
// Check misc function attributes
// FIXME: double check this
// FIXME: should we error if lbase->getRegParmAttr() != 0 &&
// rbase->getRegParmAttr() != 0 &&
// lbase->getRegParmAttr() != rbase->getRegParmAttr()?
FunctionType::ExtInfo lbaseInfo = lbase->getExtInfo();
FunctionType::ExtInfo rbaseInfo = rbase->getExtInfo();
// Per gcc, compatible functions must have compatible regparm and noreturn
// attributes.
unsigned RegParm = lbaseInfo.getRegParm();
bool NoReturn = lbaseInfo.getNoReturn();
if (NoReturn != rbaseInfo.getNoReturn() || RegParm != rbaseInfo.getRegParm())
return QualType();
unsigned RegParm = lbaseInfo.getRegParm() == 0 ? rbaseInfo.getRegParm() :
lbaseInfo.getRegParm();
bool NoReturn = lbaseInfo.getNoReturn() || rbaseInfo.getNoReturn();
if (NoReturn != lbaseInfo.getNoReturn() ||
RegParm != lbaseInfo.getRegParm())
allLTypes = false;
if (NoReturn != rbaseInfo.getNoReturn() ||
RegParm != rbaseInfo.getRegParm())
allRTypes = false;
CallingConv lcc = lbaseInfo.getCC();
CallingConv rcc = rbaseInfo.getCC();
// Compatible functions must have compatible calling conventions

View File

@ -1,11 +1,7 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
__attribute((regparm(2))) int a(void);
__attribute((regparm(1.0))) int b(void); // expected-error{{'regparm' attribute requires integer constant}}
__attribute((regparm(-1))) int c(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5))) int d(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5,3))) int e(void); // expected-error{{attribute requires 1 argument(s)}}
int f(void);
__attribute((regparm(0))) int f(void);
__attribute((regparm(1))) int g(void); // expected-note{{previous declaration is here}}
__attribute((regparm(2))) int g(void); // expected-error{{conflicting types for 'g'}}
__attribute((regparm(2))) int x(void);
__attribute((regparm(1.0))) int x(void); // expected-error{{'regparm' attribute requires integer constant}}
__attribute((regparm(-1))) int x(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5))) int x(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5,3))) int x(void); // expected-error{{attribute requires 1 argument(s)}}