[LLVMbugs] [Bug 20532] New: Provide a way to compile legacy code that uses argument-less return in non-void functions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 4 09:16:22 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20532

            Bug ID: 20532
           Summary: Provide a way to compile legacy code that uses
                    argument-less return in non-void functions
           Product: clang
           Version: 3.4
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fuzxxl at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Legacy code I try to compile (e.g. the Mosaic source code) contains code like
this:

    foo() {
        /* ... */
        return;
        /* ... */
    }

Which is, a return statement without an argument in a function of non-void
type. While gcc accepts such constructs, clang doesn't like them and promptly
refuses compilation:

    q.c:2:2: error: non-void function 'foo' should return a value
[-Wreturn-type]
            return;
            ^

Manually patching all places where such constructs appear is cumbersome. clang
should either provide a compiler flag that turns this kind of return-mismatch
into a warning, treating the returned value as undefined, and optionally accept
this kind of code by default if -std=gnu89 or -std=gnu99 is provided.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140804/43f1d1c8/attachment.html>


More information about the llvm-bugs mailing list