summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGCall.cpp4
-rw-r--r--clang/test/CodeGen/function-attributes.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index f3021dce43c..bad76409cb1 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/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/clang/test/CodeGen/function-attributes.c b/clang/test/CodeGen/function-attributes.c
index 373eb63b700..a12111ec94a 100644
--- a/clang/test/CodeGen/function-attributes.c
+++ b/clang/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
OpenPOWER on IntegriCloud