comparison gcc/testsuite/gcc.dg/cpp/macsyntx.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Copyright (C) 2000 Free Software Foundation, Inc. */ 1 /* Copyright (C) 2000-2017 Free Software Foundation, Inc. */
2 2
3 /* { dg-do preprocess } */ 3 /* { dg-do preprocess } */
4 /* { dg-options "-pedantic -std=gnu99" } */ 4 /* { dg-options "-pedantic -std=gnu99" } */
5 5
6 /* Tests macro syntax, for both definition and invocation, including:- 6 /* Tests macro syntax, for both definition and invocation, including:-
19 Split a couple of the lines to check that the errors appear on the 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). */ 20 right line (i.e. are associated with the correct token). */
21 21
22 #define ; /* { dg-error "identifier" } */ 22 #define ; /* { dg-error "identifier" } */
23 #define SEMI; /* { dg-warning "space" } */ 23 #define SEMI; /* { dg-warning "space" } */
24 #define foo(X /* { dg-error "missing" } */ 24 #define foo(X /* { dg-error "expected" } */
25 #define foo\ 25 #define foo\
26 (X,) /* { dg-error "parameter name" } */ 26 (X,) /* { dg-error "parameter name" } */
27 #define foo(, X) /* { dg-error "parameter name" } */ 27 #define foo(, X) /* { dg-error "parameter name" } */
28 #define foo(X, X) /* { dg-error "duplicate" } */ 28 #define foo(X, X) /* { dg-error "duplicate" } */
29 #define foo(X Y) /* { dg-error "comma" } */ 29 #define foo(X Y) /* { dg-error "expected" } */
30 #define foo(() /* { dg-error "may not appear" } */ 30 #define foo(() /* { dg-error "parameter name" } */
31 #define foo(..., X) /* { dg-error "missing" } */ 31 #define foo(..., X) /* { dg-error "expected" } */
32 #define foo \ 32 #define foo \
33 __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */ 33 __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */
34 #define goo(__VA_ARGS__) /* { dg-warning "__VA_ARGS__" } */ 34 #define goo(__VA_ARGS__) /* { dg-warning "__VA_ARGS__" } */
35 #define hoo(...) __VA_ARGS__ /* OK. */ 35 #define hoo(...) __VA_ARGS__ /* OK. */
36 #define __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */ 36 #define __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */
49 one(ichi\ 49 one(ichi\
50 , ni) /* { dg-error "passed 2" } */ 50 , ni) /* { dg-error "passed 2" } */
51 two(ichi) /* { dg-error "requires 2" } */ 51 two(ichi) /* { dg-error "requires 2" } */
52 var0() /* OK. */ 52 var0() /* OK. */
53 var0(ichi) /* OK. */ 53 var0(ichi) /* OK. */
54 var1() /* { dg-warning "requires at least one" } */ 54 var1() /* { dg-bogus "requires at least one" } */
55 var1(ichi) /* { dg-warning "requires at least one" } */ 55 var1(ichi) /* { dg-bogus "requires at least one" } */
56 var1(ichi, ni) /* OK. */ 56 var1(ichi, ni) /* OK. */
57 57
58 /* This tests two oddities of GNU rest args - omitting a comma is OK, 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. */ 59 and backtracking a token on pasting an empty rest args. */
60 #define rest(x, y...) x ## y /* { dg-warning "ISO C" } */ 60 #define rest(x, y...) x ## y /* { dg-warning "ISO C" } */
61 rest(ichi,) /* OK. */ 61 rest(ichi,) /* OK. */
62 rest(ichi) /* { dg-warning "requires at least one" } */ 62 rest(ichi) /* { dg-bogus "requires at least one" } */
63 #if 23 != rest(2, 3) /* OK, no warning. */ 63 #if 23 != rest(2, 3) /* OK, no warning. */
64 #error 23 != 23 !! 64 #error 23 != 23 !!
65 #endif 65 #endif
66 66
67 /* Test that we don't allow arguments to flow into the rest of the 67 /* Test that we don't allow arguments to flow into the rest of the