From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [RFC/PATCH] git-compat-util.h: Don't define NORETURN under __clang__
Date: Tue, 3 Aug 2010 13:08:03 +0000 [thread overview]
Message-ID: <1280840883-24540-1-git-send-email-avarab@gmail.com> (raw)
clang version 1.0 on Debian testing x86_64 defines __GNUC__, but barfs
on `void __attribute__((__noreturn__))'. E.g.:
usage.c:56:1: error: function declared 'noreturn' should not return [-Winvalid-noreturn]
}
^
1 diagnostic generated.
make: *** [usage.o] Error 1
There it's dying on `void __attribute__((__noreturn__)) usagef(const
char *err, ...)' in usage.c, which doesn't return.
Change the header to define NORETURN to nothing under clang. This was
the default behavior for non-GNU and non-MSC compilers already. Having
NORETURN_PTR defined to the GNU C value has no effect on clang
however.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
I have no experience with Clang so this may not be sane, but on my
system clang compiles with it and passes all tests. It still spews a
lot of warnings though:
GITGUI_VERSION = 0.12.0.64.g89d61
* new build flags or prefix
config.c:297:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
connect.c:151:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
date.c:678:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
diff.c:429:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
These are valid, as control may not return the advertised type if we
call die() inside them.
log-tree.c:297:21: warning: field width should have type 'int', but argument has type 'unsigned int' [-Wformat]
"Subject: [%s %0*d/%d] ",
^
1 diagnostic generated.
notes.c:632:25: warning: field precision should have type 'int', but argument has type 'unsigned int' [-Wformat]
strbuf_addf(buf, "%o %.*s%c", mode, path_len, path, '\0');
^ ~~~~~~~~
1 diagnostic generated.
Should these (and some below) just cast to (int) ?
object.c:44:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
parse-options.c:155:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
read-cache.c:1361:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
remote.c:658:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
revision.c:253:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
setup.c:79:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
sideband.c:97:25: warning: field precision should have type 'int', but argument has type 'unsigned int' [-Wformat]
fprintf(stderr, "%.*s", brk + sf, b);
^ ~~~~~~~~
1 diagnostic generated.
transport.c:1133:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
imap-send.c:548:27: warning: more data arguments than '%' conversions [-Wformat-extra-args]
cmd->tag, cmd->cmd, cmd->cb.dlen);
^
1 diagnostic generated.
Writing perl.mak for Git
GIT_VERSION = 1.7.2.1.7.gb44c1
builtin/blame.c:1984:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/bundle.c:67:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/commit.c:832:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/fetch-pack.c:209:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/grep.c:704:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/help.c:58:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/pack-redundant.c:584:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/push.c:252:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
builtin/reflog.c:782:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 diagnostic generated.
git-compat-util.h | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 02a73ee..c651cb7 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -183,7 +183,10 @@ extern char *gitbasename(char *);
#define is_dir_sep(c) ((c) == '/')
#endif
-#ifdef __GNUC__
+#ifdef __clang__
+#define NORETURN
+#define NORETURN_PTR __attribute__((__noreturn__))
+#elif __GNUC__
#define NORETURN __attribute__((__noreturn__))
#define NORETURN_PTR __attribute__((__noreturn__))
#elif defined(_MSC_VER)
--
1.7.1
next reply other threads:[~2010-08-03 13:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 13:08 Ævar Arnfjörð Bjarmason [this message]
2010-08-03 13:18 ` [RFC/PATCH] git-compat-util.h: Don't define NORETURN under __clang__ Michael J Gruber
2010-08-03 13:35 ` Matthieu Moy
2010-08-03 14:23 ` Matthieu Moy
2010-08-03 21:10 ` Ævar Arnfjörð Bjarmason
2010-08-03 13:35 ` Benjamin Kramer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280840883-24540-1-git-send-email-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).