* cppinit.c (cpp_post_options): Shut off macro expansion if -fpreprocessed. * cpplib.c (_cpp_handle_directive): If -fpreprocessed, accept IN_I directives only if the # is in column 1 and the directive name begins in column 2. * cppmain.c (scan_buffer): Insert a space between # and an identifier, when that identifier is a directive name. * tradcpp.c (struct file_buf): Add a pointer to the next entry in the header search path. (enum node_type): Add T_INCLUDE_NEXT. (directive_table): Add entry for include_next. (do_include_next): New function. (process_include): New routine, broken out of do_include. (finclude): Insert 'nhd' argument, to be copied into next_header_dir of the new buffer. (main): Adjust to match. * gsyslimits.h, limity.h: Un-indent #include_next. testsuite: * gcc.dg/cpp/direct2.c: New test. * gcc.dg/cpp/direct2s.c: New test. * gcc.c-torture/execute/920730-1t.c: #undef __GNUC__ at head. From-SVN: r41932
38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
|
Contributed by Nathan Sidwell 8 May 2001 <nathan@codesourcery.com> */
|
|
|
|
/* Test of prohibition on directives which result from macro expansion.
|
|
See also direct2s.c */
|
|
|
|
/* { dg-do compile } */
|
|
|
|
#define HASH #
|
|
#define HASHDEFINE #define
|
|
#define HASHINCLUDE #include
|
|
|
|
HASH include "somerandomfile" /*{ dg-error "syntax|parse" "non-include" }*/
|
|
/*{ dg-bogus "No such" "don't execute non-include" { target *-*-* } 13 }*/
|
|
HASHINCLUDE <somerandomfile> /*{ dg-error "syntax|parse" "non-include 2" }*/
|
|
/*{ dg-bogus "No such" "don't execute non-include 2" { target *-*-* } 15 }*/
|
|
|
|
void g ()
|
|
{
|
|
HASH define X 1 /* { dg-error "syntax error" "# from macro" } */
|
|
HASHDEFINE Y 1 /* { dg-error "syntax error" "#define from macro" } */
|
|
}
|
|
|
|
#pragma GCC dependency "direct2.c"
|
|
#
|
|
|
|
void f ()
|
|
{
|
|
int i = X; /* { dg-error "undeclared|for each" "no macro X" } */
|
|
int j = Y; /* { dg-error "undeclared|for each" "no macro Y" } */
|
|
}
|
|
|
|
#define slashstar /##*
|
|
#define starslash *##/
|
|
|
|
slashstar starslash /* { dg-error "parse error" "not a comment" } */
|
|
/* { dg-warning "does not give" "paste warning(s)" { target *-*-* } 36 } */
|