[Python-checkins] cpython: Fix a clang warning in grammar.c

victor.stinner python-checkins at python.org
Fri Aug 19 09:16:46 EDT 2016


https://hg.python.org/cpython/rev/ea00c88f7f42
changeset:   102753:ea00c88f7f42
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Aug 19 15:11:56 2016 +0200
summary:
  Fix a clang warning in grammar.c

Clang is smarter than GCC and emits a warning for dead code after a function
declared with __attribute__((__noreturn__)) (Py_FatalError).

files:
  Parser/grammar.c |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/Parser/grammar.c b/Parser/grammar.c
--- a/Parser/grammar.c
+++ b/Parser/grammar.c
@@ -122,7 +122,13 @@
     }
     fprintf(stderr, "Label %d/'%s' not found\n", type, str);
     Py_FatalError("grammar.c:findlabel()");
+
+    /* Py_FatalError() is declared with __attribute__((__noreturn__)).
+       GCC emits a warning without "return 0;" (compiler bug!), but Clang is
+       smarter and emits a warning on the return... */
+#ifndef __clang__
     return 0; /* Make gcc -Wall happy */
+#endif
 }
 
 /* Forward */

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list