def err_non_asm_stmt_in_naked_function : Error<
"non-ASM statement in naked function is not supported">;
+def err_asm_naked_parm_ref : Error<
+ "parameter references not allowed in naked functions">;
// OpenCL warnings and errors.
def err_invalid_astype_of_different_size : Error<
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.
void test_operand_size() {
__asm { call word t4 } // expected-error {{Expected 'PTR' or 'ptr' token!}}
}
+
+__declspec(naked) int t5(int x) { // expected-note {{attribute is here}}
+ asm { movl eax, x } // expected-error {{parameter references not allowed in naked functions}}
+ asm { retl }
+}
+
+int y;
+__declspec(naked) int t6(int x) {
+ asm { mov eax, y } // No error.
+ asm { ret }
+}