diff options
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/function-attributes.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index f3021dce43..bad76409cb 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -1654,10 +1654,10 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, FuncAttrs |= llvm::Attribute::NoUnwind; if (TargetDecl->getAttr<NoReturnAttr>()) FuncAttrs |= llvm::Attribute::NoReturn; - if (TargetDecl->getAttr<PureAttr>()) - FuncAttrs |= llvm::Attribute::ReadOnly; if (TargetDecl->getAttr<ConstAttr>()) FuncAttrs |= llvm::Attribute::ReadNone; + else if (TargetDecl->getAttr<PureAttr>()) + FuncAttrs |= llvm::Attribute::ReadOnly; } QualType RetTy = FI.getReturnType(); diff --git a/test/CodeGen/function-attributes.c b/test/CodeGen/function-attributes.c index 373eb63b70..a12111ec94 100644 --- a/test/CodeGen/function-attributes.c +++ b/test/CodeGen/function-attributes.c @@ -43,4 +43,8 @@ int f12(int arg) { return arg ? 0 : f10_t(); } +// RUN: grep 'define void @f13() nounwind readnone' %t && +void f13(void) __attribute__((pure)) __attribute__((const)); +void f13(void){} + // RUN: true |