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
// 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)}}