OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [cpp/] [macsyntx.c] - Diff between revs 149 and 154

Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
/* Copyright (C) 2000 Free Software Foundation, Inc.  */
/* Copyright (C) 2000 Free Software Foundation, Inc.  */
 
 
/* { dg-do preprocess } */
/* { dg-do preprocess } */
/* { dg-options "-pedantic -std=gnu99" } */
/* { dg-options "-pedantic -std=gnu99" } */
 
 
/* Tests macro syntax, for both definition and invocation, including:-
/* Tests macro syntax, for both definition and invocation, including:-
 
 
   o Full range of macro definition semantics.
   o Full range of macro definition semantics.
   o No. of arguments supplied to function-like macros.
   o No. of arguments supplied to function-like macros.
   o Odd GNU rest args behavior.
   o Odd GNU rest args behavior.
   o Macro arguments do not flow into the rest of the file.  */
   o Macro arguments do not flow into the rest of the file.  */
 
 
 
 
/* Test basic macro definition syntax.  The macros are all called
/* Test basic macro definition syntax.  The macros are all called
   "foo" deliberately to provoke an (excess) redefinition warning in
   "foo" deliberately to provoke an (excess) redefinition warning in
   case the macros succeed in being entered in the macro hash table
   case the macros succeed in being entered in the macro hash table
   despite being an error.
   despite being an error.
 
 
   Split a couple of the lines to check that the errors appear on the
   Split a couple of the lines to check that the errors appear on the
   right line (i.e. are associated with the correct token).  */
   right line (i.e. are associated with the correct token).  */
 
 
#define ;                       /* { dg-error "identifier" } */
#define ;                       /* { dg-error "identifier" } */
#define SEMI;                   /* { dg-warning "space" } */
#define SEMI;                   /* { dg-warning "space" } */
#define foo(X                   /* { dg-error "missing" } */
#define foo(X                   /* { dg-error "missing" } */
#define foo\
#define foo\
(X,)                            /* { dg-error "parameter name" } */
(X,)                            /* { dg-error "parameter name" } */
#define foo(, X)                /* { dg-error "parameter name" } */
#define foo(, X)                /* { dg-error "parameter name" } */
#define foo(X, X)               /* { dg-error "duplicate" } */
#define foo(X, X)               /* { dg-error "duplicate" } */
#define foo(X Y)                /* { dg-error "comma" } */
#define foo(X Y)                /* { dg-error "comma" } */
#define foo(()                  /* { dg-error "may not appear" } */
#define foo(()                  /* { dg-error "may not appear" } */
#define foo(..., X)             /* { dg-error "missing" } */
#define foo(..., X)             /* { dg-error "missing" } */
#define foo \
#define foo \
__VA_ARGS__                     /* { dg-warning "__VA_ARGS__" } */
__VA_ARGS__                     /* { dg-warning "__VA_ARGS__" } */
#define goo(__VA_ARGS__)        /* { dg-warning "__VA_ARGS__" } */
#define goo(__VA_ARGS__)        /* { dg-warning "__VA_ARGS__" } */
#define hoo(...) __VA_ARGS__    /* OK.  */
#define hoo(...) __VA_ARGS__    /* OK.  */
#define __VA_ARGS__             /* { dg-warning "__VA_ARGS__" } */
#define __VA_ARGS__             /* { dg-warning "__VA_ARGS__" } */
__VA_ARGS__                     /* { dg-warning "__VA_ARGS__" } */
__VA_ARGS__                     /* { dg-warning "__VA_ARGS__" } */
 
 
/* test # of supplied arguments.  */
/* test # of supplied arguments.  */
#define none()
#define none()
#define one(x)
#define one(x)
#define two(x, y)
#define two(x, y)
#define var0(...)
#define var0(...)
#define var1(x, ...)
#define var1(x, ...)
none()                          /* OK.  */
none()                          /* OK.  */
none(ichi)                      /* { dg-error "passed 1" } */
none(ichi)                      /* { dg-error "passed 1" } */
one()                           /* OK.  */
one()                           /* OK.  */
one(ichi)                       /* OK.  */
one(ichi)                       /* OK.  */
one(ichi\
one(ichi\
, ni)                           /* { dg-error "passed 2" } */
, ni)                           /* { dg-error "passed 2" } */
two(ichi)                       /* { dg-error "requires 2" } */
two(ichi)                       /* { dg-error "requires 2" } */
var0()                          /* OK.  */
var0()                          /* OK.  */
var0(ichi)                      /* OK.  */
var0(ichi)                      /* OK.  */
var1()                          /* { dg-warning "rest arguments to be used" } */
var1()                          /* { dg-warning "rest arguments to be used" } */
var1(ichi)                      /* { dg-warning "rest arguments to be used" } */
var1(ichi)                      /* { dg-warning "rest arguments to be used" } */
var1(ichi, ni)                  /* OK.  */
var1(ichi, ni)                  /* OK.  */
 
 
/* This tests two oddities of GNU rest args - omitting a comma is OK,
/* This tests two oddities of GNU rest args - omitting a comma is OK,
   and backtracking a token on pasting an empty rest args.  */
   and backtracking a token on pasting an empty rest args.  */
#define rest(x, y...) x ## y    /* { dg-warning "ISO C" } */
#define rest(x, y...) x ## y    /* { dg-warning "ISO C" } */
rest(ichi,)                     /* OK.  */
rest(ichi,)                     /* OK.  */
rest(ichi)                      /* { dg-warning "rest arguments to be used" } */
rest(ichi)                      /* { dg-warning "rest arguments to be used" } */
#if 23 != rest(2, 3)            /* OK, no warning.  */
#if 23 != rest(2, 3)            /* OK, no warning.  */
#error 23 != 23 !!
#error 23 != 23 !!
#endif
#endif
 
 
/* Test that we don't allow arguments to flow into the rest of the
/* Test that we don't allow arguments to flow into the rest of the
   file.  */
   file.  */
#define half_invocation do_nowt(2
#define half_invocation do_nowt(2
#define do_nowt(x) x
#define do_nowt(x) x
half_invocation )               /* OK.  */
half_invocation )               /* OK.  */
do_nowt (half_invocation))      /* { dg-error "unterminated argument" } */
do_nowt (half_invocation))      /* { dg-error "unterminated argument" } */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.