On 03/31/2017 09:06 AM, David Malcolm wrote:
As noted in the PR, c.opt's description of -Wendif-labels erroneously
refers to #elif, rather than #else.
warn_endif_labels is used by:
libcpp/directives.c: do_else
libcpp/directives.c: do_endif
in which they use it to guard calls to check_eol_endif_labels.
It's not used by do_elif.
Presumably it should to have GCC warn on the extra tokens after
the constant expression in the #elif directive just as warns about
those after the #else:
#if 1
#elif 1 foo bar
#else if 1 foobar
#endif baz
a.c:3:7: warning: extra tokens at end of #else directive [-Wendif-labels]
#else if 1 foobar
^~
a.c:4:8: warning: extra tokens at end of #endif directive
[-Wendif-labels]
#endif baz
^~~
a.c:4:0: warning: ISO C forbids an empty translation unit [-Wpedantic]
#endif baz
Martin
doc/cppwarnopts.texi gets this right:
Do not warn whenever an @code{#else} or an @code{#endif} are followed by text.
This sometimes happens in older programs with code of the form
This patch fixes the description in c.opt.
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
Committed to trunk as obvious (r246616).
gcc/c-family/ChangeLog:
PR documentation/78732
* c.opt (Wendif-labels): Fix description to refer to
#else rather than #elif.
---
gcc/c-family/c.opt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 78fea61..13b930d 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -486,7 +486,7 @@ Warn about an empty body in an if or else statement.
Wendif-labels
C ObjC C++ ObjC++ CPP(warn_endif_labels) CppReason(CPP_W_ENDIF_LABELS)
Var(cpp_warn_endif_labels) Init(1) Warning LangEnabledBy(C ObjC C++
ObjC++,Wpedantic)
-Warn about stray tokens after #elif and #endif.
+Warn about stray tokens after #else and #endif.
Wenum-compare
C ObjC C++ ObjC++ Var(warn_enum_compare) Init(-1) Warning LangEnabledBy(C
ObjC,Wall || Wc++-compat)