summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2010-04-27 21:07:06 +0000
committerEli Friedman <eli.friedman@gmail.com>2010-04-27 21:07:06 +0000
commit7955e52f5cc737c67770dd34b0b01e0db46a6bd0 (patch)
tree556ceb52a33b4e260c82ff4ceb3047936e0db5a2 /clang/lib
parent1a0bbe25e32ef03119c743eb1da50d280640041f (diff)
downloadbcm5719-llvm-7955e52f5cc737c67770dd34b0b01e0db46a6bd0.tar.gz
bcm5719-llvm-7955e52f5cc737c67770dd34b0b01e0db46a6bd0.zip
Fix for PR6953: per gcc, regparm and noreturn affect the compatibility of
function types. This could potentially have unexpected side-effects, so look here if there are new regressions. llvm-svn: 102464
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4d7ea40079c..868054fe0ec 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4311,21 +4311,16 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
allLTypes = false;
if (getCanonicalType(retType) != getCanonicalType(rbase->getResultType()))
allRTypes = false;
- // FIXME: double check this
- // FIXME: should we error if lbase->getRegParmAttr() != 0 &&
- // rbase->getRegParmAttr() != 0 &&
- // lbase->getRegParmAttr() != rbase->getRegParmAttr()?
+
+ // Check misc function attributes
FunctionType::ExtInfo lbaseInfo = lbase->getExtInfo();
FunctionType::ExtInfo rbaseInfo = rbase->getExtInfo();
- 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;
+ // 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();
CallingConv lcc = lbaseInfo.getCC();
CallingConv rcc = rbaseInfo.getCC();
// Compatible functions must have compatible calling conventions
OpenPOWER on IntegriCloud