r221188 - Move the no-prototype calling conv check after decl merging
Reid Kleckner
reid at kleckner.net
Mon Nov 3 13:56:03 PST 2014
Author: rnk
Date: Mon Nov 3 15:56:03 2014
New Revision: 221188
URL: http://llvm.org/viewvc/llvm-project?rev=221188&view=rev
Log:
Move the no-prototype calling conv check after decl merging
Now we don't warn on this code:
void __stdcall f(void);
void __stdcall f();
My previous commit regressed this functionality because I didn't update
the relevant test case which used a definition.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/decl-microsoft-call-conv.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=221188&r1=221187&r2=221188&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Nov 3 15:56:03 2014
@@ -7383,10 +7383,21 @@ Sema::ActOnFunctionDeclarator(Scope *S,
if (!NewFD->isInvalidDecl() && NewFD->isMSVCRTEntryPoint())
CheckMSVCRTEntryPoint(NewFD);
+ if (!NewFD->isInvalidDecl())
+ D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
+ isExplicitSpecialization));
+ else if (!Previous.empty())
+ // Make graceful recovery from an invalid redeclaration.
+ D.setRedeclaration(true);
+ assert((NewFD->isInvalidDecl() || !D.isRedeclaration() ||
+ Previous.getResultKind() != LookupResult::FoundOverloaded) &&
+ "previous declaration set still overloaded");
+
// 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()) {
+ // don't support variadic calls. Only do this in C and do it after merging
+ // possibly prototyped redeclarations.
+ const FunctionType *FT = NewFD->getType()->castAs<FunctionType>();
+ if (isa<FunctionNoProtoType>(FT) && !D.isFunctionDefinition()) {
CallingConv CC = FT->getExtInfo().getCC();
if (!supportsVariadicCall(CC)) {
// Windows system headers sometimes accidentally use stdcall without
@@ -7397,16 +7408,6 @@ Sema::ActOnFunctionDeclarator(Scope *S,
<< FunctionType::getNameForCallConv(CC);
}
}
-
- if (!NewFD->isInvalidDecl())
- D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
- isExplicitSpecialization));
- else if (!Previous.empty())
- // Make graceful recovery from an invalid redeclaration.
- D.setRedeclaration(true);
- assert((NewFD->isInvalidDecl() || !D.isRedeclaration() ||
- Previous.getResultKind() != LookupResult::FoundOverloaded) &&
- "previous declaration set still overloaded");
} else {
// C++11 [replacement.functions]p3:
// The program's definitions shall not be specified as inline.
Modified: cfe/trunk/test/Sema/decl-microsoft-call-conv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-microsoft-call-conv.c?rev=221188&r1=221187&r2=221188&view=diff
==============================================================================
--- cfe/trunk/test/Sema/decl-microsoft-call-conv.c (original)
+++ cfe/trunk/test/Sema/decl-microsoft-call-conv.c Mon Nov 3 15:56:03 2014
@@ -4,14 +4,19 @@
// This is fine, as CrcGenerateTable*() has a prototype.
void __fastcall CrcGenerateTableFastcall(void);
+void __fastcall CrcGenerateTableFastcall();
void __fastcall CrcGenerateTableFastcall() {}
void __stdcall CrcGenerateTableStdcall(void);
+void __stdcall CrcGenerateTableStdcall();
void __stdcall CrcGenerateTableStdcall() {}
void __thiscall CrcGenerateTableThiscall(void);
+void __thiscall CrcGenerateTableThiscall();
void __thiscall CrcGenerateTableThiscall() {}
void __pascal CrcGenerateTablePascal(void);
+void __pascal CrcGenerateTablePascal();
void __pascal CrcGenerateTablePascal() {}
void __vectorcall CrcGenerateTableVectorcall(void);
+void __vectorcall CrcGenerateTableVectorcall();
void __vectorcall CrcGenerateTableVectorcall() {}
void __fastcall CrcGenerateTableNoProtoFastcall(); // expected-error{{function with no prototype cannot use the fastcall calling convention}}
More information about the cfe-commits
mailing list