diff options
author | aaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-24 20:55:36 +0000 |
---|---|---|
committer | aaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-24 20:55:36 +0000 |
commit | ce079f700daa3663cfaeb8286f84ad54edee6733 (patch) | |
tree | 39f5da17b3f4b0f1ab1e9e7b4922fef43daed126 /gcc/testsuite/gcc.dg/pch | |
parent | a78b652c30ccccb155dc1d9d644e8f42a53d6d19 (diff) | |
download | gcc-ce079f700daa3663cfaeb8286f84ad54edee6733.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125041 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/pch')
-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 |
6 files changed, 50 insertions, 0 deletions
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 00000000000..79cea882d9b --- /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 00000000000..c3d2ce7919a --- /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 00000000000..7bbde23e062 --- /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 00000000000..63b8a2b7fa5 --- /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 00000000000..827920563bd --- /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 00000000000..19039c82074 --- /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__ |