Skip to content

-Wreturn-type should not emit warnings when non-termination can be derived indirectly #11914

@EdSchouten

Description

@EdSchouten
Bugzilla Link 11542
Version 3.0
OS FreeBSD
CC @efriedma-quic,@tkremenek

Extended Description

I suspect this bug is similar to bug 9599, but not identical, so I'm filing this anyway.

The following code generates a -Wreturn-type warning:

__attribute__((__noreturn__)) void bar(void);

static void
foo(void)
{

        bar();
}

int
f(void)
{

        foo();
}

foo.c:15:1: warning: control reaches end of non-void function [-Wreturn-type]

If I change the call to foo() to bar(), it obviously work, but in this case the compiler should be to derive to a certain extent that foo() isn't going to return anyway. This information should be available anyway, as for this specific C file, foo() is even inlined into bar() completely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerduplicateResolved as duplicatefalse-positiveWarning fires when it should not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions