aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2009-08-16 11:05:33 +0000
committerChristopher Li <sparse@chrisli.org>2009-08-21 05:38:20 +0000
commit168b627a715b231bfe5223c2f3ba0046a8ba1f27 (patch)
tree5aa9c2d3697be7d0c83853a13af999d85f3d71c5
parent03430d088f64a3b1d4b5bbbc86da3c352010702e (diff)
downloadsparse-168b627a715b231bfe5223c2f3ba0046a8ba1f27.tar.gz
sparse: Add GCC pre-defined macros for user-spacev0.4.2-rc1
Sparse produces a bunch of warnings like this when compiling against glibc: /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:33:22: warning: undefined preprocessor identifier '__INT_MAX__' /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:5: warning: undefined preprocessor identifier '__SHRT_MAX__' /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:21: warning: undefined preprocessor identifier '__INT_MAX__' /usr/include/bits/xopen_lim.h:95:6: warning: undefined preprocessor identifier '__INT_MAX__' /usr/include/bits/xopen_lim.h:98:7: warning: undefined preprocessor identifier '__INT_MAX__' Fix that up by adding some add_pre_buffer() calls to create_builtin_define(). For future reference, GCC defines the builtins in the c_cpp_builtins() function in gcc/c-cppbuiltin.c. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Acked-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--lib.c8
-rw-r--r--lib.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 600939b5..622b5476 100644
--- a/lib.c
+++ b/lib.c
@@ -807,6 +807,14 @@ void create_builtin_stream(void)
add_pre_buffer("#define __OPTIMIZE__ 1\n");
if (optimize_size)
add_pre_buffer("#define __OPTIMIZE_SIZE__ 1\n");
+
+ /* GCC defines these for limits.h */
+ add_pre_buffer("#weak_define __SHRT_MAX__ " STRINGIFY(__SHRT_MAX__) "\n");
+ add_pre_buffer("#weak_define __SCHAR_MAX__ " STRINGIFY(__SCHAR_MAX__) "\n");
+ add_pre_buffer("#weak_define __INT_MAX__ " STRINGIFY(__INT_MAX__) "\n");
+ add_pre_buffer("#weak_define __LONG_MAX__ " STRINGIFY(__LONG_MAX__) "\n");
+ add_pre_buffer("#weak_define __LONG_LONG_MAX__ " STRINGIFY(__LONG_LONG_MAX__) "\n");
+ add_pre_buffer("#weak_define __WCHAR_MAX__ " STRINGIFY(__WCHAR_MAX__) "\n");
}
static struct symbol_list *sparse_tokenstream(struct token *token)
diff --git a/lib.h b/lib.h
index b22fa937..25abb80e 100644
--- a/lib.h
+++ b/lib.h
@@ -17,6 +17,9 @@
#include "compat.h"
#include "ptrlist.h"
+#define DO_STRINGIFY(x) #x
+#define STRINGIFY(x) DO_STRINGIFY(x)
+
extern int verbose, optimize, optimize_size, preprocessing;
extern int die_if_error;
extern int repeat_phase, merge_phi_sources;