forked from OSchip/llvm-project
Don't diagnose missing noreturns for uninstantiated templates. Fixes PR6247.
llvm-svn: 95487
This commit is contained in:
parent
61f6db54e1
commit
96c15b1816
|
@ -2494,10 +2494,11 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body,
|
|||
bool ReturnsVoid = false;
|
||||
bool HasNoReturn = false;
|
||||
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
|
||||
// If the result type of the function is a dependent type, we don't know
|
||||
// whether it will be void or not, so don't
|
||||
if (FD->getResultType()->isDependentType())
|
||||
// For function templates, class templates and member function templates
|
||||
// we'll do the analysis at instantiation time.
|
||||
if (FD->isDependentContext())
|
||||
return;
|
||||
|
||||
if (FD->getResultType()->isVoidType())
|
||||
ReturnsVoid = true;
|
||||
if (FD->hasAttr<NoReturnAttr>() ||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn
|
||||
void f() __attribute__((noreturn));
|
||||
|
||||
template<typename T> void g(T) { // expected-warning {{function could be attribute 'noreturn'}}
|
||||
f();
|
||||
}
|
||||
|
||||
template void g<int>(int); // expected-note {{in instantiation of function template specialization 'g<int>' requested here}}
|
||||
|
||||
template<typename T> struct A {
|
||||
void g() { // expected-warning {{function could be attribute 'noreturn'}}
|
||||
f();
|
||||
}
|
||||
};
|
||||
|
||||
template struct A<int>; // expected-note {{in instantiation of member function 'A<int>::g' requested here}}
|
||||
|
||||
struct B {
|
||||
template<typename T> void g(T) { // expected-warning {{function could be attribute 'noreturn'}}
|
||||
f();
|
||||
}
|
||||
};
|
||||
|
||||
template void B::g<int>(int); // expected-note {{in instantiation of function template specialization 'B::g<int>' requested here}}
|
Loading…
Reference in New Issue