diff options
author | Ollie Wild <aaw@google.com> | 2007-05-24 20:55:36 +0000 |
---|---|---|
committer | Ollie Wild <aaw@gcc.gnu.org> | 2007-05-24 20:55:36 +0000 |
commit | a702045a246397c2d31e1671fc3140112e669ec6 (patch) | |
tree | 39f5da17b3f4b0f1ab1e9e7b4922fef43daed126 /gcc/testsuite | |
parent | e1b871ecc12b6c2a7b62a64ffbbd0714ab8d5c56 (diff) | |
download | gcc-a702045a246397c2d31e1671fc3140112e669ec6.zip gcc-a702045a246397c2d31e1671fc3140112e669ec6.tar.gz gcc-a702045a246397c2d31e1671fc3140112e669ec6.tar.bz2 |
macro.c (_cpp_builtin_macro_text): Handle BT_COUNTER.
* macro.c (_cpp_builtin_macro_text): Handle BT_COUNTER.
* pch.c (cpp_write_pch_deps): Save __COUNTER__ state.
(cpp_write_pch_state): Save __COUNTER__ state.
(cpp_valid_state): Check valid __COUNTER__ state.
(cpp_read_state): Read new __COUNTER__ state.
* include/cpplib.h (enum builtin_type): Add BT_COUNTER enumerator.
* init.c (builtin_array): Add __COUNTER__/BT_COUNTER.
* internal.h (struct cpp_reader): Add counter member.
* gcc.dg/cpp/counter-1.c: New test.
* gcc.dg/pch/counter-1.c: New test.
* gcc.dg/pch/counter-1.hs: New file.
* gcc.dg/pch/counter-2.c: New test.
* gcc.dg/pch/counter-2.hs: New file.
* gcc.dg/pch/counter-3.c: New test.
* gcc.dg/pch/counter-3.hs: New file.
* doc/cpp.texi (Common Predefined Macros): Add __COUNTER__
description.
From-SVN: r125041
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/counter-1.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/counter-1.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/counter-1.hs | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/counter-2.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/counter-2.hs | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/counter-3.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/counter-3.hs | 4 |
8 files changed, 80 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e230bc3..7a33bde 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2007-05-24 Ollie Wild <aaw@google.com> + + * gcc.dg/cpp/counter-1.c: New test. + * gcc.dg/pch/counter-1.c: New test. + * gcc.dg/pch/counter-1.hs: New file. + * gcc.dg/pch/counter-2.c: New test. + * gcc.dg/pch/counter-2.hs: New file. + * gcc.dg/pch/counter-3.c: New test. + * gcc.dg/pch/counter-3.hs: New file. + 2007-05-24 Zdenek Dvorak <dvorakz@suse.cz> * gcc.dg/tree-ssa/predcom-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/cpp/counter-1.c b/gcc/testsuite/gcc.dg/cpp/counter-1.c new file mode 100644 index 0000000..80d8b78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/counter-1.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +/* { dg-do preprocess } */ + +/* Tests __COUNTER__ macro is correctly expanded. */ + +#define counter __COUNTER__ + +#if __COUNTER__ != 0 +#error __COUNTER__ != 0 +#endif + +#if counter != 1 +#error counter != 1 +#endif + +#if __COUNTER__ != 2 +#error __COUNTER__ != 2 +#endif diff --git a/gcc/testsuite/gcc.dg/pch/counter-1.c b/gcc/testsuite/gcc.dg/pch/counter-1.c new file mode 100644 index 0000000..79cea88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/counter-1.c @@ -0,0 +1,9 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +#include "counter-1.h" + +int main(void) +{ + return __COUNTER__; +} diff --git a/gcc/testsuite/gcc.dg/pch/counter-1.hs b/gcc/testsuite/gcc.dg/pch/counter-1.hs new file mode 100644 index 0000000..c3d2ce7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/counter-1.hs @@ -0,0 +1,5 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +static unsigned offset[] = {__COUNTER__, __COUNTER__, __COUNTER__}; +#define counter __COUNTER__ diff --git a/gcc/testsuite/gcc.dg/pch/counter-2.c b/gcc/testsuite/gcc.dg/pch/counter-2.c new file mode 100644 index 0000000..7bbde23 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/counter-2.c @@ -0,0 +1,15 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +/* { dg-options "-I. -Winvalid-pch" } */ + +#if __COUNTER__ != 0 +#error __COUNTER__ != 0 +#endif + +#include "counter-2.h"/* { dg-error "`__COUNTER__' is invalid|No such file|they were invalid" } */ + +int main(void) +{ + return __COUNTER__; +} diff --git a/gcc/testsuite/gcc.dg/pch/counter-2.hs b/gcc/testsuite/gcc.dg/pch/counter-2.hs new file mode 100644 index 0000000..63b8a2b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/counter-2.hs @@ -0,0 +1,4 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +static int i = __COUNTER__; diff --git a/gcc/testsuite/gcc.dg/pch/counter-3.c b/gcc/testsuite/gcc.dg/pch/counter-3.c new file mode 100644 index 0000000..8279205 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/counter-3.c @@ -0,0 +1,13 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +#if __COUNTER__ != 0 +#error __COUNTER__ != 0 +#endif + +#include "counter-3.h" + +int main(void) +{ + return __COUNTER__; +} diff --git a/gcc/testsuite/gcc.dg/pch/counter-3.hs b/gcc/testsuite/gcc.dg/pch/counter-3.hs new file mode 100644 index 0000000..19039c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/counter-3.hs @@ -0,0 +1,4 @@ +/* Copyright (C) 2007 Free Software Foundation + Contributed by Ollie Wild <aaw@google.com> */ + +#define counter __COUNTER__ |