diff options
author | Jakub Jelinek <jakub@redhat.com> | 2015-03-23 09:02:39 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2015-03-23 09:02:39 +0100 |
commit | fb136e35c77e0374112189e3283c9ecf1e83abb1 (patch) | |
tree | ca62635a383044139bfcff92d867148331a09a0f /gcc | |
parent | 30c931de07f8fcbe4ef3b550633c274fe7828975 (diff) | |
download | gcc-fb136e35c77e0374112189e3283c9ecf1e83abb1.zip gcc-fb136e35c77e0374112189e3283c9ecf1e83abb1.tar.gz gcc-fb136e35c77e0374112189e3283c9ecf1e83abb1.tar.bz2 |
re PR preprocessor/65238 (__has_attribute is not handled properly with -traditional-cpp.)
PR preprocessor/65238
* internal.h (_cpp_scan_out_logical_line): Add third argument.
* directives.c (prepare_directive_trad): Pass false to it.
* traditional.c (_cpp_read_logical_line_trad,
_cpp_create_trad_definition): Likewise.
(struct fun_macro): Add paramc field.
(fun_like_macro): New function.
(maybe_start_funlike): Handle NODE_BUILTIN macros. Initialize
macro->paramc field.
(save_argument): Use macro->paramc instead of
macro->node->value.macro->paramc.
(push_replacement_text): Formatting fix.
(recursive_macro): Use fun_like_macro helper.
(_cpp_scan_out_logical_line): Likewise. Add BUILTIN_MACRO_ARG
argument. Initialize fmacro.paramc field. Handle builtin
function-like macros.
* c-c++-common/cpp/pr65238-1.c: New test.
* gcc.dg/cpp/pr65238-2.c: New test.
* gcc.dg/cpp/trad/pr65238-3.c: New test.
* gcc.dg/cpp/trad/pr65238-4.c: New test.
From-SVN: r221587
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/cpp/pr65238-1.c | 53 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/pr65238-2.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/trad/pr65238-3.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/trad/pr65238-4.c | 19 |
5 files changed, 103 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50d8691..9b84418 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2015-03-23 Jakub Jelinek <jakub@redhat.com> + + PR preprocessor/65238 + * c-c++-common/cpp/pr65238-1.c: New test. + * gcc.dg/cpp/pr65238-2.c: New test. + * gcc.dg/cpp/trad/pr65238-3.c: New test. + * gcc.dg/cpp/trad/pr65238-4.c: New test. + 2015-03-23 Paul Thomas <pault@gcc.gnu.org> Mikael Morin <mikael@gcc.gnu.org> diff --git a/gcc/testsuite/c-c++-common/cpp/pr65238-1.c b/gcc/testsuite/c-c++-common/cpp/pr65238-1.c new file mode 100644 index 0000000..6d63465 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/pr65238-1.c @@ -0,0 +1,53 @@ +/* PR preprocessor/65238 */ +/* { dg-do run } */ + +#define A unused +#define B A +#define C B +#define D __has_attribute(unused) +#define E __has_attribute(C) +#define F(X) __has_attribute(X) +#if !__has_attribute(unused) +#error unused attribute not supported - 1 +#endif +#if !__has_attribute(C) +#error unused attribute not supported - 2 +#endif +#if !D +#error unused attribute not supported - 3 +#endif +#if !E +#error unused attribute not supported - 4 +#endif +#if !F(unused) +#error unused attribute not supported - 5 +#endif +#if !F(C) +#error unused attribute not supported - 6 +#endif +int a = __has_attribute (unused) + __has_attribute (C) + D + E + F (unused) + F (C); +int b = __has_attribute (unused); +int c = __has_attribute (C); +int d = D; +int e = E; +int f = F (unused); +int g = F (C); +int h = __has_attribute ( + unused +) + __has_attribute ( + +C) + F ( +unused + +) + F +( +C +); + +int +main () +{ + if (a != 6 || b != 1 || c != 1 || d != 1 || e != 1 || f != 1 || g != 1 || h != 4) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/cpp/pr65238-2.c b/gcc/testsuite/gcc.dg/cpp/pr65238-2.c new file mode 100644 index 0000000..c6a7aecd --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr65238-2.c @@ -0,0 +1,18 @@ +/* PR preprocessor/65238 */ +/* { dg-do preprocess } */ + +#if __has_attribute( +#endif +#if __has_attribute(unused +#endif +#if __has_attribute(unused, unused) +#endif +#if __has_attribute(__has_attribute(unused)) +#endif + +/* { dg-error "macro .__has_attribute. requires an identifier" "" {target "*-*-*"} 4 } */ +/* { dg-error "missing ... after .__has_attribute." "" {target "*-*-*"} 6 } */ +/* { dg-error "missing ... after .__has_attribute." "" {target "*-*-*"} 8 } */ +/* { dg-error "missing binary operator before token .unused." "" {target "*-*-*"} 8 } */ +/* { dg-error "macro .__has_attribute. requires an identifier" "" {target "*-*-*"} 10 } */ +/* { dg-error "missing ... in expression" "" {target "*-*-*"} 10 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/trad/pr65238-3.c b/gcc/testsuite/gcc.dg/cpp/trad/pr65238-3.c new file mode 100644 index 0000000..949dc00 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/trad/pr65238-3.c @@ -0,0 +1,5 @@ +/* PR preprocessor/65238 */ +/* { dg-do run } */ +/* { dg-options "-traditional-cpp" } */ + +#include "../../../c-c++-common/cpp/pr65238-1.c" diff --git a/gcc/testsuite/gcc.dg/cpp/trad/pr65238-4.c b/gcc/testsuite/gcc.dg/cpp/trad/pr65238-4.c new file mode 100644 index 0000000..cf2f449 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/trad/pr65238-4.c @@ -0,0 +1,19 @@ +/* PR preprocessor/65238 */ +/* { dg-do preprocess } */ +/* { dg-options "-traditional-cpp" } */ + +#if __has_attribute( +#endif +#if __has_attribute(unused +#endif +#if __has_attribute(unused, unused) +#endif +#if __has_attribute(__has_attribute(unused)) +#endif + +/* { dg-error "unterminated argument list invoking macro .__has_attribute." "" {target "*-*-*"} 5 } */ +/* { dg-error "#if with no expression" "" {target "*-*-*"} 5 } */ +/* { dg-error "unterminated argument list invoking macro .__has_attribute." "" {target "*-*-*"} 7 } */ +/* { dg-error "macro .__has_attribute. passed 2 arguments, but takes just 1" "" {target "*-*-*"} 9 } */ +/* { dg-error "missing ... in expression" "" {target "*-*-*"} 9 } */ +/* { dg-error "macro .__has_attribute. requires an identifier" "" {target "*-*-*"} 11 } */ |