LLVM: -Wno-ignored-qualifiers are equivalent?

In GCC, when the -Wall -Wextra flags are enabled, you have the option to disable warnings, such as: -Wno-ignored-qualifiers :

 warning: 'const' type qualifier on return type has no effect 

Is there a way to achieve the same behavior with LLVM / Clang? I looked through it, but found only some corrections-related pages on how this error message feature was added. Nothing on how to disable it.

I use LLVM and Clang version 3.0 (build from SVN sources).

Note. I'm going to post this on SuperUser, but there is not a single question about Clang as well as the LLVM tag, so I was discouraged. If this question should be anyway, feel free to move it around.

[Edit] It seems that the option is recognized when starting my Makefile from the terminal. When he ran out of Eclipse (Helios), he is not recognized.

[Solution] Discovered. Apparently, the problem was Eclipse (under Ubuntu) is running as root. Why this is so, I have no idea, but the effect is that the $ PATH variable contains what root would be, and not what the user running Eclipse would have. Thus, Eclipse used an older version of Clang (2.80) installed on the system. Added the correct PATH variable in the project properties -> C / C ++ Build -> Environment.

+4
source share
1 answer

What version of Clang are you using? -Wno-ignored-qualifiers works for me:

 % clang -Wall -Wextra -c foo.c foo.c:1:1: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] const int foo(); ^~~~~ 1 warning generated. % clang -Wall -Wextra -Wno-ignored-qualifiers -c foo.c % 

In general, you can see .td files, which do a pretty nice job of collecting all the diagnostic data. (There is a TODO in Clang docs for automatically generating documentation using tblgen, but that hasn't been done yet.)

In this case, for example, you see in DiagnosticSemaKinds.td :

 def warn_qual_return_type : Warning< "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">, InGroup<IgnoredQualifiers>, DefaultIgnore; 

which shows you which diagnostic group it is in ( IgnoredQualifiers ). You can then look at DiagnosticGroups.td to find out what invokes IgnoredQualifiers on the command line:

 def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">; 

So, -Wno-ignored-qualifiers . Clang tries to be GCC compatible where possible, so using the GCC name for something usually might work.

+2
source

All Articles