if (!NewFD->isInvalidDecl() && NewFD->isMSVCRTEntryPoint())
CheckMSVCRTEntryPoint(NewFD);
+ // Diagnose no-prototype function declarations with calling conventions that
+ // don't support variadic calls.
+ const FunctionType *FT = R->castAs<FunctionType>();
+ if (FT->isFunctionNoProtoType() && !D.isFunctionDefinition()) {
+ CallingConv CC = FT->getExtInfo().getCC();
+ if (!supportsVariadicCall(CC)) {
+ // Windows system headers sometimes accidentally use stdcall without
+ // (void) parameters, so we relax this to a warning.
+ int DiagID =
+ CC == CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
+ Diag(NewFD->getLocation(), DiagID)
+ << FunctionType::getNameForCallConv(CC);
+ }
+ }
+
if (!NewFD->isInvalidDecl())
D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
isExplicitSpecialization));
// Semantic checking for this function declaration (in isolation).
- // Diagnose calling conventions that don't support variadic calls.
- QualType NewQType = Context.getCanonicalType(NewFD->getType());
- const FunctionType *NewType = cast<FunctionType>(NewQType);
- if (isa<FunctionNoProtoType>(NewType)) {
- FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo();
- if (!supportsVariadicCall(NewTypeInfo.getCC())) {
- // Windows system headers sometimes accidentally use stdcall without
- // (void) parameters, so use a default-error warning in this case :-/
- int DiagID = NewTypeInfo.getCC() == CC_X86StdCall
- ? diag::warn_cconv_knr : diag::err_cconv_knr;
- Diag(NewFD->getLocation(), DiagID)
- << FunctionType::getNameForCallConv(NewTypeInfo.getCC());
- }
- }
-
if (getLangOpts().CPlusPlus) {
// C++-specific checks.
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(NewFD)) {
void __vectorcall CrcGenerateTableVectorcall(void);
void __vectorcall CrcGenerateTableVectorcall() {}
-void __fastcall CrcGenerateTableNoProtoFastcall() {} // expected-error{{function with no prototype cannot use the fastcall calling convention}}
-void __stdcall CrcGenerateTableNoProtoStdcall() {} // expected-warning{{function with no prototype cannot use the stdcall calling convention}}
-void __thiscall CrcGenerateTableNoProtoThiscall() {} // expected-error{{function with no prototype cannot use the thiscall calling convention}}
-void __pascal CrcGenerateTableNoProtoPascal() {} // expected-error{{function with no prototype cannot use the pascal calling convention}}
-void __vectorcall CrcGenerateTableNoProtoVectorcall() {} // expected-error{{function with no prototype cannot use the vectorcall calling convention}}
+void __fastcall CrcGenerateTableNoProtoFastcall(); // expected-error{{function with no prototype cannot use the fastcall calling convention}}
+void __stdcall CrcGenerateTableNoProtoStdcall(); // expected-warning{{function with no prototype cannot use the stdcall calling convention}}
+void __thiscall CrcGenerateTableNoProtoThiscall(); // expected-error{{function with no prototype cannot use the thiscall calling convention}}
+void __pascal CrcGenerateTableNoProtoPascal(); // expected-error{{function with no prototype cannot use the pascal calling convention}}
+void __vectorcall CrcGenerateTableNoProtoVectorcall(); // expected-error{{function with no prototype cannot use the vectorcall calling convention}}
+
+void __fastcall CrcGenerateTableNoProtoDefFastcall() {}
+void __stdcall CrcGenerateTableNoProtoDefStdcall() {}
+void __thiscall CrcGenerateTableNoProtoDefThiscall() {}
+void __pascal CrcGenerateTableNoProtoDefPascal() {}
+void __vectorcall CrcGenerateTableNoProtoDefVectorcall() {}
// Regular calling convention is fine.
void CrcGenerateTableNoProto() {}