cpplib.h (NODE_CONDITIONAL): New.

libcpp/
	* include/cpplib.h (NODE_CONDITIONAL): New.
	(struct cpp_callbacks): New macro_to_expand field.
	(struct cpp_hashnode): Adjust size of flags and type fields.
	(cpp_peek_token): Prototype.
	* lex.c (cpp_peek_token): New function.
	(_cpp_temp_token): Protect pre-existing lookaheads.
	* macro.c (cpp_get_token): Expand any conditional macros.
	(_cpp_backup_tokens_direct): New.
	(_cpp_backup_tokens): Call _cpp_backup_tokens_direct.
	(warn_of_redefinition): Silently allow redefined conditional
	macros.
	(_cpp_create_definition): Remove the conditional flag when a user
	defines one of the conditional macros.
	* internal.h (_cpp_backup_tokens_direct): New prototype.

gcc/
	* c-common.h (C_CPP_HASHNODE): New macro.
	* coretypes.h (struct cpp_token): Forward declare.
	* doc/extend.texi (PowerPC AltiVec Built-in Functions): Document
	the context-sensitive keyword method.
	* config/rs6000/rs6000-c.c (__vector_keyword, vector_keyword,
	__pixel_keyword, pixel_keyword, __bool_keyword, bool_keyword,
	expand_bool_pixel): New.
	(altivec_categorize_keyword): New function.
	(init_vector_keywords): New function.
	(rs6000_macro_to_expand): Likewise.
	(rs6000_cpu_cpp_builtins): Enable context-sensitive macros if not
	compiling an ISO C dialect.

gcc/testsuite/
	* gcc.target/powerpc/altivec-macros.c: New test.
	* gcc.target/powerpc/altviec-26.c: Likewise.
	* gcc.dg/vmx/1b-06.c: Remove bool variable.
	* gcc.dg/vmx/1b-07.c: Likewise.
	* gcc.dg/vmx/1b-06-ansi.c: New test for the pre-define method.
	* gcc.dg/vmx/1b-07-ansi.c: Likewise.

From-SVN: r137775
This commit is contained in:
Ben Elliston 2008-07-14 05:09:48 +00:00 committed by Ben Elliston
parent b463e8de6c
commit 5950c3c9a7
17 changed files with 475 additions and 27 deletions

View file

@ -484,6 +484,10 @@ struct cpp_callbacks
void (*read_pch) (cpp_reader *, const char *, int, const char *);
missing_header_cb missing_header;
/* Context-sensitive macro support. Returns macro (if any) that should
be expanded. */
cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *);
/* Called to emit a diagnostic if client_diagnostic option is true.
This callback receives the translated message. */
void (*error) (cpp_reader *, int, const char *, va_list *)
@ -558,6 +562,7 @@ extern const char *progname;
#define NODE_DISABLED (1 << 5) /* A disabled macro. */
#define NODE_MACRO_ARG (1 << 6) /* Used during #define processing. */
#define NODE_USED (1 << 7) /* Dumped with -dU. */
#define NODE_CONDITIONAL (1 << 8) /* Conditional macro */
/* Different flavors of hash node. */
enum node_type
@ -629,8 +634,8 @@ struct cpp_hashnode GTY(())
then index into directive table.
Otherwise, a NODE_OPERATOR. */
unsigned char rid_code; /* Rid code - for front ends. */
ENUM_BITFIELD(node_type) type : 8; /* CPP node type. */
unsigned char flags; /* CPP flags. */
ENUM_BITFIELD(node_type) type : 7; /* CPP node type. */
unsigned int flags : 9; /* CPP flags. */
union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value;
};
@ -717,6 +722,7 @@ extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
extern const unsigned char *cpp_macro_definition (cpp_reader *,
const cpp_hashnode *);
extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
extern const cpp_token *cpp_peek_token (cpp_reader *, int);
/* Evaluate a CPP_CHAR or CPP_WCHAR token. */
extern cppchar_t cpp_interpret_charconst (cpp_reader *, const cpp_token *,