diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaStmtAsm.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 47a7672ae19..989999f18d9 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -405,6 +405,19 @@ ExprResult Sema::LookupInlineAsmIdentifier(CXXScopeSpec &SS, Result = CheckPlaceholderExpr(Result.get()); if (!Result.isUsable()) return Result; + // Referring to parameters is not allowed in naked functions. + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Result.get())) { + if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(DRE->getDecl())) { + if (FunctionDecl *Func = dyn_cast<FunctionDecl>(Parm->getDeclContext())) { + if (Func->hasAttr<NakedAttr>()) { + Diag(Id.getLocStart(), diag::err_asm_naked_parm_ref); + Diag(Func->getAttr<NakedAttr>()->getLocation(), diag::note_attribute); + return ExprError(); + } + } + } + } + QualType T = Result.get()->getType(); // For now, reject dependent types. |