diff options
author | Joseph Myers <joseph@codesourcery.com> | 2019-11-18 17:41:40 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2019-11-18 17:41:40 +0000 |
commit | 092508a07975a00b3bc7c4c6ef551d5b6dc2c193 (patch) | |
tree | c89eb335e50073d6894de650c5344e92b4195c93 /gcc | |
parent | 9d2b80ea51e42d5011badf2d654fb3fd93289fe3 (diff) | |
download | gcc-092508a07975a00b3bc7c4c6ef551d5b6dc2c193.zip gcc-092508a07975a00b3bc7c4c6ef551d5b6dc2c193.tar.gz gcc-092508a07975a00b3bc7c4c6ef551d5b6dc2c193.tar.bz2 |
Add more C2x attributes tests.
This patch adds more tests of C2x attributes, where I found cases that
were handled correctly by my patches but missing from the original
tests. Tests are added for -std=c11 -pedantic handling of C2x
attribute syntax and corresponding -Wc11-c2x-compat handling; for
struct [[deprecated]]; and for the [[__fallthrough__]] spelling of
[[fallthrough]] in the case of valid fallthrough attributes.
Tested for x86_64-pc-linux-gnu.
* gcc.dg/c11-attr-syntax-1.c, gcc.dg/c11-attr-syntax-2.c,
gcc.dg/c11-attr-syntax-3.c, gcc.dg/c2x-attr-syntax-4.c: New tests.
* gcc.dg/c2x-attr-deprecated-1.c: Also test struct [[deprecated]].
* gcc.dg/c2x-attr-fallthrough-1.c: Also test [[__fallthrough__]].
From-SVN: r278418
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c11-attr-syntax-1.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c11-attr-syntax-2.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c11-attr-syntax-3.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-attr-syntax-4.c | 7 |
7 files changed, 50 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8bd2fa..83f704f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-11-18 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/c11-attr-syntax-1.c, gcc.dg/c11-attr-syntax-2.c, + gcc.dg/c11-attr-syntax-3.c, gcc.dg/c2x-attr-syntax-4.c: New tests. + * gcc.dg/c2x-attr-deprecated-1.c: Also test struct [[deprecated]]. + * gcc.dg/c2x-attr-fallthrough-1.c: Also test [[__fallthrough__]]. + 2019-11-18 Marek Polacek <polacek@redhat.com> PR c++/91962 - ICE with reference binding and qualification conversion. diff --git a/gcc/testsuite/gcc.dg/c11-attr-syntax-1.c b/gcc/testsuite/gcc.dg/c11-attr-syntax-1.c new file mode 100644 index 0000000..5a3f70c --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-attr-syntax-1.c @@ -0,0 +1,7 @@ +/* Test C2x attribute syntax: rejected in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +[[]]; /* { dg-error "attributes before C2X" } */ + +void f [[]] (void); /* { dg-error "attributes before C2X" } */ diff --git a/gcc/testsuite/gcc.dg/c11-attr-syntax-2.c b/gcc/testsuite/gcc.dg/c11-attr-syntax-2.c new file mode 100644 index 0000000..d92a189 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-attr-syntax-2.c @@ -0,0 +1,7 @@ +/* Test C2x attribute syntax: rejected in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +[[]]; /* { dg-warning "attributes before C2X" } */ + +void f [[]] (void); /* { dg-warning "attributes before C2X" } */ diff --git a/gcc/testsuite/gcc.dg/c11-attr-syntax-3.c b/gcc/testsuite/gcc.dg/c11-attr-syntax-3.c new file mode 100644 index 0000000..4d7cb77 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-attr-syntax-3.c @@ -0,0 +1,8 @@ +/* Test C2x attribute syntax: rejected in C11, but warning disabled + with -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */ + +[[]]; + +void f [[]] (void); diff --git a/gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c b/gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c index de0ae51..227c241 100644 --- a/gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c +++ b/gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c @@ -89,3 +89,11 @@ f11 (void) { return y.b; /* { dg-warning "deprecated" } */ } + +struct [[deprecated]] s { int x; }; + +void +f12 (void) +{ + struct s var; /* { dg-warning "deprecated" } */ +} diff --git a/gcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c b/gcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c index ffa5226..c0d9031 100644 --- a/gcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c +++ b/gcc/testsuite/gcc.dg/c2x-attr-fallthrough-1.c @@ -16,6 +16,12 @@ f (int a) case 3: b += 7; break; + case 4: + b = 5; + [[__fallthrough__]]; + case 5: + b += 1; + break; } return b; } diff --git a/gcc/testsuite/gcc.dg/c2x-attr-syntax-4.c b/gcc/testsuite/gcc.dg/c2x-attr-syntax-4.c new file mode 100644 index 0000000..30c9668 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-attr-syntax-4.c @@ -0,0 +1,7 @@ +/* Test C2x attribute syntax: diagnosed with -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +[[]]; /* { dg-warning "attributes before C2X" } */ + +void f [[]] (void); /* { dg-warning "attributes before C2X" } */ |