From: Mike Stump Date: Mon, 27 Jul 2009 21:45:16 +0000 (+0000) Subject: Add knowledge about _longjmp being noreturn. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=773db1d4b5974a1849d0214900f5006f98adea5b;p=clang Add knowledge about _longjmp being noreturn. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77254 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d168a907a0..27c109f9f0 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3705,8 +3705,8 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (!FD->getAttr()) FD->addAttr(::new (Context) FormatAttr("printf", 2, Name->isStr("vasprintf") ? 0 : 3)); - } else if (Name->isStr("longjmp") && - !FD->hasAttr()) + } else if ((Name->isStr("longjmp") || Name->isStr("_longjmp")) + && !FD->hasAttr()) FD->addAttr(::new (Context) NoReturnAttr()); } diff --git a/test/Sema/return.c b/test/Sema/return.c index f439ad7994..c04337924a 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -200,5 +200,8 @@ int test29() { #include jmp_buf test30_j; int test30() { - longjmp(test30_j, 1); + if (j) + longjmp(test30_j, 1); + else + _longjmp(test30_j, 1); }