[LLVMbugs] [Bug 17053] New: -Wheader-guard fires for non-header files

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Sep 1 14:44:26 PDT 2013


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

            Bug ID: 17053
           Summary: -Wheader-guard fires for non-header files
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider this code:

$ cat test.h
#ifndef TEST_H_
#define TEST_H_

#ifdef CONFIGURE_TEST_INCLUDE
typedef int MyInt;
#endif  // CONFIGURE_TEST_INCLUDE

#endif  // TEST_H_

$ cat test.c
#ifndef EXCLUDE_C_FILES

#define CONFIGURE_TEST_INCLUDE
#include "test.h"

int main(){}

#endif  // EXCLUDE_C_FILES



Here, the .h file has a correct header guard and does some stuff optionally
based on a define. The .c file is guarded by some preprocessor macro, so that
the file can be disabled at build time.

-Wheader-guard complains about the .c file:

$ ~/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/clang -c
test.c
test.c:1:9: warning: 'EXCLUDE_C_FILES' is used as a header guard here, followed
by #define of a different macro [-Wheader-guard]
#ifndef EXCLUDE_C_FILES
        ^~~~~~~~~~~~~~~
test.c:3:9: note: 'CONFIGURE_TEST_INCLUDE' is defined here; did you mean
'EXCLUDE_C_FILES'?
#define CONFIGURE_TEST_INCLUDE
        ^~~~~~~~~~~~~~~~~~~~~~
        EXCLUDE_C_FILES
1 warning generated.


...but the .c file is fine as is. -Wheader-guard shouldn't warn about wrong
header guards in the main translation unit.

-- 
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/20130901/dbdd24e7/attachment.html>


More information about the llvm-bugs mailing list