Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

unused-macros reported for a marco used in pre-processor #37667

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR38693
Status NEW
Importance P enhancement
Reported by Eric Chamberland (eric.chamberland@giref.ulaval.ca)
Reported on 2018-08-24 11:40:00 -0700
Last modified on 2018-08-24 11:40:00 -0700
Version 6.0
Hardware PC Linux
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments t.c (390 bytes, text/x-csrc)
Blocks
Blocked by
See also
Created attachment 20764
The code for unsed-macros

Hi,

this example talks by itself:

------
/* In this example, the FUNC_NAME is used by the pre-processor, but not the code
 * but is reported as "unused" by the compiler -Wunused-macro
 */
#pragma clang diagnostic warning "-Wunused-macros"

extern void foo(const char[]);

/*#  define PetscRegisterFUNC_NAME() foo(FUNCT_NAME)*/

#define PetscRegisterFUNC_NAME()

#define FUNC_NAME "tata"
void tata() {
  PetscRegisterFUNC_NAME();
}
------
clang -c t.c
t.c:12:9: warning: macro is not used [-Wunused-macros]
#define FUNC_NAME "tata"

So the FUNC_NAME macro is used in the pre-processing stage, but not the
compiling stage.  Is it possible to tell to the -Wunused-macros to take pre-
processing into account?

Thanks,

Eric
Quuxplusone commented 6 years ago

Attached t.c (390 bytes, text/x-csrc): The code for unsed-macros