struct answer;
struct file_name_map_list;
-/* The first two groups, apart from '=', can appear in preprocessor
- expressions. This allows a lookup table to be implemented in
- _cpp_parse_expr.
+/* The first three groups, apart from '=', can appear in preprocessor
+ expressions (+= and -= are used to indicate unary + and - resp.).
+ This allows a lookup table to be implemented in _cpp_parse_expr.
The first group, to CPP_LAST_EQ, can be immediately followed by an
'='. The lexer needs operators ending in '=', like ">>=", to be in
#define CPP_LAST_EQ CPP_MAX
#define CPP_FIRST_DIGRAPH CPP_HASH
#define CPP_LAST_PUNCTUATOR CPP_DOT_STAR
+#define CPP_LAST_CPP_OP CPP_LESS_EQ
#define TTYPE_TABLE \
OP(CPP_EQ = 0, "=") \
OP(CPP_COMMA, ",") /* grouping */ \
OP(CPP_OPEN_PAREN, "(") \
OP(CPP_CLOSE_PAREN, ")") \
+ TK(CPP_EOF, SPELL_NONE) \
OP(CPP_EQ_EQ, "==") /* compare */ \
OP(CPP_NOT_EQ, "!=") \
OP(CPP_GREATER_EQ, ">=") \
OP(CPP_LESS_EQ, "<=") \
\
+ /* These two are unary + / - in preprocessor expressions. */ \
OP(CPP_PLUS_EQ, "+=") /* math */ \
OP(CPP_MINUS_EQ, "-=") \
+\
OP(CPP_MULT_EQ, "*=") \
OP(CPP_DIV_EQ, "/=") \
OP(CPP_MOD_EQ, "%=") \
TK(CPP_COMMENT, SPELL_NUMBER) /* Only if output comments. */ \
/* SPELL_NUMBER happens to DTRT. */ \
TK(CPP_MACRO_ARG, SPELL_NONE) /* Macro argument. */ \
- TK(CPP_PADDING, SPELL_NONE) /* Whitespace for cpp0. */ \
- TK(CPP_EOF, SPELL_NONE) /* End of line or file. */
+ TK(CPP_PADDING, SPELL_NONE) /* Whitespace for cpp0. */
#define OP(e, s) e,
#define TK(e, s) e,
/* C language kind, used when calling cpp_reader_init. */
enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_STDC89, CLK_STDC94, CLK_STDC99,
- CLK_GNUCXX, CLK_CXX98, CLK_OBJC, CLK_OBJCXX, CLK_ASM};
+ CLK_GNUCXX, CLK_CXX98, CLK_ASM};
/* Payload of a NUMBER, STRING, CHAR or COMMENT token. */
struct cpp_string
} val;
};
-/* A standalone character. We may want to make it unsigned for the
- same reason we use unsigned char - to avoid signedness issues. */
-typedef int cppchar_t;
+/* A type wide enough to hold any multibyte source character.
+ cpplib's character constant interpreter requires an unsigned type.
+ Also, a typedef for the signed equivalent. */
+#ifndef MAX_WCHAR_TYPE_SIZE
+# define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
+#endif
+#if CHAR_BIT * SIZEOF_INT >= MAX_WCHAR_TYPE_SIZE
+# define CPPCHAR_SIGNED_T int
+#else
+# if CHAR_BIT * SIZEOF_LONG >= MAX_WCHAR_TYPE_SIZE || !HAVE_LONG_LONG
+# define CPPCHAR_SIGNED_T long
+# else
+# define CPPCHAR_SIGNED_T long long
+# endif
+#endif
+typedef unsigned CPPCHAR_SIGNED_T cppchar_t;
+typedef CPPCHAR_SIGNED_T cppchar_signed_t;
/* Values for opts.dump_macros.
dump_only means inhibit output of the preprocessed text
const char *include_prefix;
unsigned int include_prefix_len;
- /* -fleading_underscore sets this to "_". */
- const char *user_label_prefix;
-
/* The language we're preprocessing. */
enum c_lang lang;
/* Non-0 means -v, so print the full set of include dirs. */
unsigned char verbose;
- /* Nonzero means chars are signed. */
- unsigned char signed_char;
-
/* Nonzero means use extra default include directories for C++. */
unsigned char cplusplus;
/* Nonzero means handle cplusplus style comments */
unsigned char cplusplus_comments;
- /* Nonzero means handle #import, for objective C. */
+ /* Nonzero means define __OBJC__, treat @ as a special token, and
+ use the OBJC[PLUS]_INCLUDE_PATH environment variable. */
unsigned char objc;
/* Nonzero means don't copy comments into the output file. */
/* Nonzero means warn if #import is used. */
unsigned char warn_import;
+ /* Nonzero means warn about multicharacter charconsts. */
+ unsigned char warn_multichar;
+
/* Nonzero means warn about various incompatibilities with
traditional C. */
unsigned char warn_traditional;
+ /* Nonzero means warn about long long numeric constants. */
+ unsigned char warn_long_long;
+
/* Nonzero means warn about text after an #endif (or #else). */
unsigned char warn_endif_labels;
+ /* Nonzero means warn about implicit sign changes owing to integer
+ promotions. */
+ unsigned char warn_num_sign_change;
+
/* Nonzero means turn warnings into errors. */
unsigned char warnings_are_errors;
/* Nonzero means warn if undefined identifiers are evaluated in an #if. */
unsigned char warn_undef;
+ /* Nonzero means warn of unused macros from the main file. */
+ unsigned char warn_unused_macros;
+
/* Nonzero for the 1999 C Standard, including corrigenda and amendments. */
unsigned char c99;
options. Stand-alone CPP should then bail out after option
parsing; drivers might want to continue printing help. */
unsigned char help_only;
+
+ /* True for traditional preprocessing. */
+ unsigned char traditional;
+
+ /* True if only preprocessing and not compiling. */
+ unsigned char preprocess_only;
+
+ /* Target-specific features set by the front end or client. */
+
+ /* Precision for target CPP arithmetic, target characters, target
+ ints and target wide characters, respectively. */
+ size_t precision, char_precision, int_precision, wchar_precision;
+
+ /* True means chars (wide chars) are unsigned. */
+ bool unsigned_char, unsigned_wchar;
+
+ /* Nonzero means __STDC__ should have the value 0 in system headers. */
+ unsigned char stdc_0_in_system_headers;
};
/* Call backs. */
void (*undef) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
void (*ident) PARAMS ((cpp_reader *, unsigned int, const cpp_string *));
void (*def_pragma) PARAMS ((cpp_reader *, unsigned int));
+ /* Called when the client has a chance to properly register
+ built-ins with cpp_define() and cpp_assert(). */
+ void (*register_builtins) PARAMS ((cpp_reader *));
};
-#define CPP_FATAL_LIMIT 1000
-/* True if we have seen a "fatal" error. */
-#define CPP_FATAL_ERRORS(PFILE) (cpp_errors (PFILE) >= CPP_FATAL_LIMIT)
-
/* Name under which this program was invoked. */
extern const char *progname;
structure reliable. Options processing is not completed until you
call cpp_finish_options. */
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
-extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **, int));
+extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_post_options PARAMS ((cpp_reader *));
/* This function reads the file, but does not start preprocessing. It
extern void _cpp_backup_tokens PARAMS ((cpp_reader *, unsigned int));
/* Evaluate a CPP_CHAR or CPP_WCHAR token. */
-extern HOST_WIDE_INT
+extern cppchar_t
cpp_interpret_charconst PARAMS ((cpp_reader *, const cpp_token *,
- int, unsigned int *));
+ unsigned int *, int *));
+/* Used to register builtins during the register_builtins callback.
+ The text is the same as the command line argument. */
extern void cpp_define PARAMS ((cpp_reader *, const char *));
extern void cpp_assert PARAMS ((cpp_reader *, const char *));
extern void cpp_undef PARAMS ((cpp_reader *, const char *));
int, int));
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
+/* A preprocessing number. Code assumes that any unused high bits of
+ the double integer are set to zero. */
+typedef unsigned HOST_WIDE_INT cpp_num_part;
+typedef struct cpp_num cpp_num;
+struct cpp_num
+{
+ cpp_num_part high;
+ cpp_num_part low;
+ bool unsignedp; /* True if value should be treated as unsigned. */
+ bool overflow; /* True if the most recent calculation overflowed. */
+};
+
+/* cpplib provides two interfaces for interpretation of preprocessing
+ numbers.
+
+ cpp_classify_number categorizes numeric constants according to
+ their field (integer, floating point, or invalid), radix (decimal,
+ octal, hexadecimal), and type suffixes. */
+
+#define CPP_N_CATEGORY 0x000F
+#define CPP_N_INVALID 0x0000
+#define CPP_N_INTEGER 0x0001
+#define CPP_N_FLOATING 0x0002
+
+#define CPP_N_WIDTH 0x00F0
+#define CPP_N_SMALL 0x0010 /* int, float. */
+#define CPP_N_MEDIUM 0x0020 /* long, double. */
+#define CPP_N_LARGE 0x0040 /* long long, long double. */
+
+#define CPP_N_RADIX 0x0F00
+#define CPP_N_DECIMAL 0x0100
+#define CPP_N_HEX 0x0200
+#define CPP_N_OCTAL 0x0400
+
+#define CPP_N_UNSIGNED 0x1000 /* Properties. */
+#define CPP_N_IMAGINARY 0x2000
+
+/* Classify a CPP_NUMBER token. The return value is a combination of
+ the flags from the above sets. */
+extern unsigned cpp_classify_number PARAMS ((cpp_reader *, const cpp_token *));
+
+/* Evaluate a token classified as category CPP_N_INTEGER. */
+extern cpp_num cpp_interpret_integer PARAMS ((cpp_reader *, const cpp_token *,
+ unsigned int type));
+
+/* Sign extend a number, with PRECISION significant bits and all
+ others assumed clear, to fill out a cpp_num structure. */
+cpp_num cpp_num_sign_extend PARAMS ((cpp_num, size_t));
+
/* Diagnostic levels. To get a dianostic without associating a
position in the translation unit with it, use cpp_error_with_line
with a line number of zero. */
#define DL_PEDWARN 0x02
/* An error. */
#define DL_ERROR 0x03
-/* A fatal error. We do not exit, to support use of cpplib as a
- library, but may only return CPP_EOF tokens thereon. It is the
- caller's responsibility to check CPP_FATAL_ERRORS. */
-#define DL_FATAL 0x04
/* An internal consistency check failed. Prints "internal error: ",
- otherwise the same as DL_FATAL. */
-#define DL_ICE 0x05
+ otherwise the same as DL_ERROR. */
+#define DL_ICE 0x04
/* Extracts a diagnostic level from an int. */
#define DL_EXTRACT(l) (l & 0xf)
/* Non-zero if a diagnostic level is one of the warnings. */
extern void cpp_output_line PARAMS ((cpp_reader *, FILE *));
extern void cpp_output_token PARAMS ((const cpp_token *, FILE *));
extern const char *cpp_type2name PARAMS ((enum cpp_ttype));
-extern unsigned int cpp_parse_escape PARAMS ((cpp_reader *,
- const unsigned char **,
- const unsigned char *,
- unsigned HOST_WIDE_INT));
+/* Returns the value of an escape sequence, truncated to the correct
+ target precision. PSTR points to the input pointer, which is just
+ after the backslash. LIMIT is how much text we have. WIDE is true
+ if the escape sequence is part of a wide character constant or
+ string literal. Handles all relevant diagnostics. */
+extern cppchar_t cpp_parse_escape PARAMS ((cpp_reader *,
+ const unsigned char ** pstr,
+ const unsigned char *limit,
+ int wide));
/* In cpphash.c */