diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Parse/AttributeList.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 20 |
3 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8a880516f66..0759abdd33f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -286,6 +286,9 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D, if (D->getAttr<StdCallAttr>()) F->setCallingConv(llvm::CallingConv::X86_StdCall); + + if (D->getAttr<RegparmAttr>()) + ErrorUnsupported(D, "regparm attribute"); } /// SetFunctionAttributesForDefinition - Set function attributes @@ -308,6 +311,9 @@ void CodeGenModule::SetFunctionAttributesForDefinition(const Decl *D, if (D->getAttr<NoinlineAttr>()) F->addFnAttr(llvm::Attribute::NoInline); + + if (D->getAttr<RegparmAttr>()) + ErrorUnsupported(D, "regparm attribute"); } void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD, diff --git a/clang/lib/Parse/AttributeList.cpp b/clang/lib/Parse/AttributeList.cpp index 9cee6abebbd..cd192c92ef0 100644 --- a/clang/lib/Parse/AttributeList.cpp +++ b/clang/lib/Parse/AttributeList.cpp @@ -80,6 +80,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { if (!memcmp(Str, "nonnull", 7)) return AT_nonnull; if (!memcmp(Str, "nothrow", 7)) return AT_nothrow; if (!memcmp(Str, "objc_gc", 7)) return AT_objc_gc; + if (!memcmp(Str, "regparm", 7)) return AT_regparm; if (!memcmp(Str, "section", 7)) return AT_section; if (!memcmp(Str, "stdcall", 7)) return AT_stdcall; break; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 53c86ebaaec..c8d98cf0dcb 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1444,6 +1444,22 @@ static void HandleNoinlineAttr(Decl *d, const AttributeList &Attr, Sema &S) { d->addAttr(::new (S.Context) NoinlineAttr()); } +static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) { + // check the attribute arguments. + if (Attr.getNumArgs() != 1) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; + return; + } + + if (!isFunctionOrMethod(d)) { + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << "regparm" << 0 /*function*/; + return; + } + + d->addAttr(::new (S.Context) RegparmAttr()); +} + //===----------------------------------------------------------------------===// // Top Level Sema Entry Points //===----------------------------------------------------------------------===// @@ -1504,6 +1520,10 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { case AttributeList::AT_cleanup: HandleCleanupAttr (D, Attr, S); break; case AttributeList::AT_nodebug: HandleNodebugAttr (D, Attr, S); break; case AttributeList::AT_noinline: HandleNoinlineAttr (D, Attr, S); break; + case AttributeList::AT_regparm: + HandleRegparmAttr (D, Attr, S); + S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName(); + break; case AttributeList::IgnoredAttribute: // Just ignore break; |