This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Revised patch for #-directives as result of macro expansion
On Wed, May 09, 2001 at 10:51:43AM -0700, Zack Weinberg wrote:
> On Wed, May 09, 2001 at 09:06:32AM +0100, Nathan Sidwell wrote:
> > Zack Weinberg wrote:
> > >
> > > This is the same patch I posted on Thursday, with additional changes
> > > to avoid causing execute/920730-1t.c to regress. tradcpp now
> > I tried this patch, and it is good.
> > Here are two C++ test cases which check for the right thing happening.
>
> Thanks. I'd prefer these were gcc.dg/cpp test cases rather than g++
> test cases. I'll re-cast them as such and apply with the patch later
> today.
Revised test cases are appended. They needed a bit more work than
just changing // ERROR - ... to /* { dg-error ... } */ throughout;
dg.exp is pickier than old-deja.exp, it appears.
I changed the way the #include tests are written mainly because, if
cpp0 throws an error in -save-temps mode, cc1 doesn't run, therefore
we don't get to test -fpreprocessed.
Patch + test cases have now been applied to branch and trunk.
--
zw The phrase causes storage to be reserved, doesn't mean that it causes
storage to be reserved. This is a fundamental misunderstanding of
Standardese.
-- Mike Stump
/* 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 } */
/* 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. Same as direct2.c, with -save-temps applied; results
should be identical. */
/* { dg-do compile } */
/* { dg-options "-save-temps -ansi -pedantic-errors" } */
#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 *-*-* } 15 }*/
HASHINCLUDE <somerandomfile> /*{ dg-error "syntax|parse" "non-include 2" }*/
/*{ dg-bogus "No such" "don't execute non-include 2" { target *-*-* } 17 }*/
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 "direct2s.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 *-*-* } 38 } */