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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [cpp/] [macsyntx.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Copyright (C) 2000 Free Software Foundation, Inc.  */
2
 
3
/* { dg-do preprocess } */
4
/* { dg-options "-pedantic -std=gnu99" } */
5
 
6
/* Tests macro syntax, for both definition and invocation, including:-
7
 
8
   o Full range of macro definition semantics.
9
   o No. of arguments supplied to function-like macros.
10
   o Odd GNU rest args behavior.
11
   o Macro arguments do not flow into the rest of the file.  */
12
 
13
 
14
/* Test basic macro definition syntax.  The macros are all called
15
   "foo" deliberately to provoke an (excess) redefinition warning in
16
   case the macros succeed in being entered in the macro hash table
17
   despite being an error.
18
 
19
   Split a couple of the lines to check that the errors appear on the
20
   right line (i.e. are associated with the correct token).  */
21
 
22
#define ;                       /* { dg-error "identifier" } */
23
#define SEMI;                   /* { dg-warning "space" } */
24
#define foo(X                   /* { dg-error "missing" } */
25
#define foo\
26
(X,)                            /* { dg-error "parameter name" } */
27
#define foo(, X)                /* { dg-error "parameter name" } */
28
#define foo(X, X)               /* { dg-error "duplicate" } */
29
#define foo(X Y)                /* { dg-error "comma" } */
30
#define foo(()                  /* { dg-error "may not appear" } */
31
#define foo(..., X)             /* { dg-error "missing" } */
32
#define foo \
33
__VA_ARGS__                     /* { dg-warning "__VA_ARGS__" } */
34
#define goo(__VA_ARGS__)        /* { dg-warning "__VA_ARGS__" } */
35
#define hoo(...) __VA_ARGS__    /* OK.  */
36
#define __VA_ARGS__             /* { dg-warning "__VA_ARGS__" } */
37
__VA_ARGS__                     /* { dg-warning "__VA_ARGS__" } */
38
 
39
/* test # of supplied arguments.  */
40
#define none()
41
#define one(x)
42
#define two(x, y)
43
#define var0(...)
44
#define var1(x, ...)
45
none()                          /* OK.  */
46
none(ichi)                      /* { dg-error "passed 1" } */
47
one()                           /* OK.  */
48
one(ichi)                       /* OK.  */
49
one(ichi\
50
, ni)                           /* { dg-error "passed 2" } */
51
two(ichi)                       /* { dg-error "requires 2" } */
52
var0()                          /* OK.  */
53
var0(ichi)                      /* OK.  */
54
var1()                          /* { dg-warning "rest arguments to be used" } */
55
var1(ichi)                      /* { dg-warning "rest arguments to be used" } */
56
var1(ichi, ni)                  /* OK.  */
57
 
58
/* This tests two oddities of GNU rest args - omitting a comma is OK,
59
   and backtracking a token on pasting an empty rest args.  */
60
#define rest(x, y...) x ## y    /* { dg-warning "ISO C" } */
61
rest(ichi,)                     /* OK.  */
62
rest(ichi)                      /* { dg-warning "rest arguments to be used" } */
63
#if 23 != rest(2, 3)            /* OK, no warning.  */
64
#error 23 != 23 !!
65
#endif
66
 
67
/* Test that we don't allow arguments to flow into the rest of the
68
   file.  */
69
#define half_invocation do_nowt(2
70
#define do_nowt(x) x
71
half_invocation )               /* OK.  */
72
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.