}
// Semantic checking for this function declaration (in isolation).
+
+ // Diagnose the use of X86 fastcall on unprototyped functions.
+ QualType NewQType = Context.getCanonicalType(NewFD->getType());
+ const FunctionType *NewType = cast<FunctionType>(NewQType);
+ if (isa<FunctionNoProtoType>(NewType)) {
+ FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo();
+ if (NewTypeInfo.getCC() == CC_X86FastCall)
+ Diag(NewFD->getLocation(), diag::err_cconv_knr)
+ << FunctionType::getNameForCallConv(CC_X86FastCall);
+ // TODO: Also diagnose unprototyped stdcall functions?
+ }
+
if (getLangOpts().CPlusPlus) {
// C++-specific checks.
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(NewFD)) {
}
}
- // Diagnose the use of X86 fastcall on unprototyped functions.
- if (CC == CC_X86FastCall) {
- if (isa<FunctionNoProtoType>(fn)) {
- S.Diag(attr.getLoc(), diag::err_cconv_knr)
- << FunctionType::getNameForCallConv(CC);
- attr.setInvalid();
- return true;
- }
-
- // Also diagnose fastcall with regparm.
- if (fn->getHasRegParm()) {
- S.Diag(attr.getLoc(), diag::err_attributes_are_not_compatible)
- << "regparm"
- << FunctionType::getNameForCallConv(CC);
- attr.setInvalid();
- return true;
- }
+ // Also diagnose fastcall with regparm.
+ if (CC == CC_X86FastCall && fn->getHasRegParm()) {
+ S.Diag(attr.getLoc(), diag::err_attributes_are_not_compatible)
+ << "regparm" << FunctionType::getNameForCallConv(CC_X86FastCall);
+ attr.setInvalid();
+ return true;
}
// Modify the CC from the wrapped function type, wrap it all back, and then
--- /dev/null
+// RUN: %clang_cc1 -triple i686-pc-win32 -verify %s
+
+// It's important that this is a .c file.
+
+// This is fine, as CrcGenerateTable() has a prototype.
+void __fastcall CrcGenerateTable(void);
+void __fastcall CrcGenerateTable() {}
+
+void __fastcall CrcGenerateTableNoProto() {} // expected-error{{function with no prototype cannot use fastcall calling convention}}