summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-11-03 21:56:03 +0000
committerReid Kleckner <reid@kleckner.net>2014-11-03 21:56:03 +0000
commit899baf3625db90e3434e8a91335a74f4c49972a1 (patch)
treedd7a3848d0f7f7750029a5f1fb15a191ecb93ce4 /clang/lib/Sema/SemaDecl.cpp
parent7e2b9882b147bf9c26faa7b04b56884ec444bd64 (diff)
downloadbcm5719-llvm-899baf3625db90e3434e8a91335a74f4c49972a1.tar.gz
bcm5719-llvm-899baf3625db90e3434e8a91335a74f4c49972a1.zip
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. llvm-svn: 221188
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b9f8f637e21..109c01c8892 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7383,10 +7383,21 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
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, Declarator &D, DeclContext *DC,
<< 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.
OpenPOWER on IntegriCloud