Commit 91fcd158 by Neil Booth Committed by Neil Booth

cpphash.h: ISvspace, is_vspace, is_nvspace: New.

	* cpphash.h: ISvspace, is_vspace, is_nvspace: New.
	IShspace, ISspace: Update.

	* cppinit.c: ISTABLE: Update.
	V: New.

	* cpplex.c (IS_HSPACE, S_NEWLINE): Remove.
	(IS_DIRECTIVE): Rename KNOWN_DIRECTIVE.
	(skip_block_comment, skip_line_comment,	parse_string,
	lex_line): Use is_vspace rather than IS_NEWLINE.
	(skip_whitespace, lex_line): Clean up to use is_nvspace.
	(lex_line): Use KNOWN_DIRECTIVE.  Any kind of directive
	gets a BOL flag.
	(lex_next): Unconditionally stop if within a directive.
	Treat directives within macro invocations as directives
	(after parse_args emits error), not as the argument.

	* testsuite/gcc.dg/cpp/directiv.c: New tests.
	* testsuite/gcc.dg/cpp/undef1.c: Update.

From-SVN: r34933
parent 8514e318
2000-07-09 Neil Booth <NeilB@earthling.net>
* cpphash.h: ISvspace, is_vspace, is_nvspace: New.
IShspace, ISspace: Update.
* cppinit.c: ISTABLE: Update.
V: New.
* cpplex.c (IS_HSPACE, S_NEWLINE): Remove.
(IS_DIRECTIVE): Rename KNOWN_DIRECTIVE.
(skip_block_comment, skip_line_comment, parse_string,
lex_line): Use is_vspace rather than IS_NEWLINE.
(skip_whitespace, lex_line): Clean up to use is_nvspace.
(lex_line): Use KNOWN_DIRECTIVE. Any kind of directive
gets a BOL flag.
(lex_next): Unconditionally stop if within a directive.
Treat directives within macro invocations as directives
(after parse_args emits error), not as the argument.
2000-07-09 Gabriel Dos Reis <gdr@codesourcery.com> 2000-07-09 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.c (diagnostic_args): New macro. * diagnostic.c (diagnostic_args): New macro.
......
...@@ -141,12 +141,17 @@ struct spec_nodes ...@@ -141,12 +141,17 @@ struct spec_nodes
/* Character classes. /* Character classes.
If the definition of `numchar' looks odd to you, please look up the If the definition of `numchar' looks odd to you, please look up the
definition of a pp-number in the C standard [section 6.4.8 of C99] */ definition of a pp-number in the C standard [section 6.4.8 of C99].
In the unlikely event that characters other than \r and \n enter
the set is_vspace, the macro handle_newline() in cpplex.c must be
updated. */
#define ISidnum 0x01 /* a-zA-Z0-9_ */ #define ISidnum 0x01 /* a-zA-Z0-9_ */
#define ISidstart 0x02 /* _a-zA-Z */ #define ISidstart 0x02 /* _a-zA-Z */
#define ISnumstart 0x04 /* 0-9 */ #define ISnumstart 0x04 /* 0-9 */
#define IShspace 0x08 /* ' ' \t \f \v */ #define IShspace 0x08 /* ' ' \t */
#define ISspace 0x10 /* ' ' \t \f \v \n */ #define ISvspace 0x10 /* \r \n */
#define ISspace 0x20 /* ' ' \t \r \n \f \v \0 */
#define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident)) #define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
...@@ -155,6 +160,8 @@ struct spec_nodes ...@@ -155,6 +160,8 @@ struct spec_nodes
#define is_numchar(x) (_cpp_IStable[x] & ISidnum) #define is_numchar(x) (_cpp_IStable[x] & ISidnum)
#define is_numstart(x) (_cpp_IStable[x] & ISnumstart) #define is_numstart(x) (_cpp_IStable[x] & ISnumstart)
#define is_hspace(x) (_cpp_IStable[x] & IShspace) #define is_hspace(x) (_cpp_IStable[x] & IShspace)
#define is_vspace(x) (_cpp_IStable[x] & ISvspace)
#define is_nvspace(x) ((_cpp_IStable[x] & (ISspace | ISvspace)) == ISspace)
#define is_space(x) (_cpp_IStable[x] & ISspace) #define is_space(x) (_cpp_IStable[x] & ISspace)
/* This table is constant if it can be initialized at compile time, /* This table is constant if it can be initialized at compile time,
......
...@@ -138,6 +138,7 @@ enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; ...@@ -138,6 +138,7 @@ enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
#define A(x) s(x, ISidnum|ISidstart) #define A(x) s(x, ISidnum|ISidstart)
#define N(x) s(x, ISidnum|ISnumstart) #define N(x) s(x, ISidnum|ISnumstart)
#define H(x) s(x, IShspace|ISspace) #define H(x) s(x, IShspace|ISspace)
#define V(x) s(x, ISvspace|ISspace)
#define S(x) s(x, ISspace) #define S(x) s(x, ISspace)
ISTABLE ISTABLE
...@@ -153,14 +154,17 @@ ISTABLE ...@@ -153,14 +154,17 @@ ISTABLE
N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0') N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
H('\0') H(' ') H('\t') H('\v') H('\f') H(' ') H('\t')
S('\n') V('\n') V('\r')
S('\0') S('\v') S('\f')
END END
#undef A #undef A
#undef N #undef N
#undef H #undef H
#undef V
#undef S #undef S
#undef s #undef s
#undef ISTABLE #undef ISTABLE
......
2000-07-09 Neil Booth <NeilB@earthling.net>
* testsuite/gcc.dg/cpp/directiv.c: New tests.
* testsuite/gcc.dg/cpp/undef1.c: Update.
2000-07-08 Angela Marie Thomas <angela@cygnus.com> 2000-07-08 Angela Marie Thomas <angela@cygnus.com>
* lib/c-torture.exp: Make compiler_conditional_xfail_data global. * lib/c-torture.exp: Make compiler_conditional_xfail_data global.
......
/* Copyright (C) 2000 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* { dg-options -pedantic } */
/* Tests general directive syntax, and directive error recovery. */
/* Test directive name is not expanded. */
#define foo define
#foo EMPTY /* { dg-error "invalid" } */
/* Test # must be first on line. */
EMPTY #define bar
#ifdef bar
#error bar is defined
#endif
/* Test form feed and vertical tab warn pedantically, see 6.10
paragraph 5. Tab is OK. */
# define something /* { dg-warning "form feed" } */
#define something_else /* { dg-warning "vertical tab" } */
#define some thing /* Tab OK, as is form feed before #. */
/* Our friend the null directive OK? */
#
/* Check that directives always start a line, even if in middle of
macro expansion. */
#define func(x) x
func (2 /* { dg-error "unterminated invocation" } */
#define foobar /* { dg-error "may not be used inside" } */
/* For tidiness, I think the directive should still be processed
above. Certainly, continuing to try to find the closing ')' can
lead to some really confusing error messages. Hence this test. */
#ifndef foobar
#error It is nice if the directive is processed!
#endif
/* Check newlines end directives, even in function-like macro
invocations. 6.10 paragraph 1.
Note that the #if is still treated as a conditional, so there
should be no errors about #endif without #if. */
#if func ( /* { dg-error "unterminated invocation" } */
#endif
...@@ -9,6 +9,6 @@ ...@@ -9,6 +9,6 @@
#define foo(bar) bar #define foo(bar) bar
foo( blah foo( blah /* { dg-error "unterminated invocation" } */
#undef foo /* { dg-error "may not be used inside" "foo(#undef foo)" } */ #undef foo /* { dg-error "may not be used inside" "foo(#undef foo)" } */
blah ) blah )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment