[cfe-commits] r91073 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/return.c

Chris Lattner clattner at apple.com
Thu Dec 10 16:08:13 PST 2009


On Dec 10, 2009, at 2:57 PM, Mike Stump wrote:

> Author: mrs
> Date: Thu Dec 10 16:57:48 2009
> New Revision: 91073
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=91073&view=rev
> Log:
> Don't complain about falling off the end of a function with an asm
> block, if the function is supposed to return a value as we don't know
> exactly what the asm code does.

Why?  GCC warns about this.  A fix to silence the warning is to use __builtin_unreachable() after the asm.

-Chris

> 
> Modified:
>    cfe/trunk/lib/Sema/SemaDecl.cpp
>    cfe/trunk/test/Sema/return.c
> 
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=91073&r1=91072&r2=91073&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Dec 10 16:57:48 2009
> @@ -1253,6 +1253,11 @@
>       HasFakeEdge = true;
>       continue;
>     }
> +    if (isa<AsmStmt>(S)) {
> +      HasFakeEdge = true;
> +      HasLiveReturn = true;
> +      continue;
> +    }
>     bool NoReturnEdge = false;
>     if (CallExpr *C = dyn_cast<CallExpr>(S)) {
>       Expr *CEE = C->getCallee()->IgnoreParenCasts();
> 
> Modified: cfe/trunk/test/Sema/return.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/return.c?rev=91073&r1=91072&r2=91073&view=diff
> 
> ==============================================================================
> --- cfe/trunk/test/Sema/return.c (original)
> +++ cfe/trunk/test/Sema/return.c Thu Dec 10 16:57:48 2009
> @@ -222,3 +222,7 @@
> void test33() {
>   if (j) while (1) { }
> }
> +
> +int test34() {
> +  asm("nop");
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list