diff options
author | Joseph Myers <joseph@codesourcery.com> | 2013-11-13 00:38:49 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2013-11-13 00:38:49 +0000 |
commit | 38b7bc7fc6a883b7ed12f27c798496fceef28ba2 (patch) | |
tree | e843a9dc913b73d2b8924f2993e8aaeee0c8be4f /gcc/testsuite | |
parent | d6d3f03341138d3918c71ce9fc6f05b81ebe004e (diff) | |
download | gcc-38b7bc7fc6a883b7ed12f27c798496fceef28ba2.tar.gz |
extend.texi (Statement Exprs, Typeof): Discuss __auto_type.
* doc/extend.texi (Statement Exprs, Typeof): Discuss __auto_type.
* ginclude/stdatomic.h (kill_dependency, atomic_store_explicit)
(atomic_load_explicit, atomic_exchange_explicit)
(atomic_compare_exchange_strong_explicit)
(atomic_compare_exchange_weak_explicit): Use __auto_type to
declare variable initialized with PTR argument.
c-family:
* c-common.h (enum rid): Add RID_AUTO_TYPE.
* c-common.c (c_common_reswords): Add __auto_type.
(keyword_begins_type_specifier): Handle RID_AUTO_TYPE.
c:
* c-tree.h (c_typespec_keyword): Add cts_auto_type.
* c-decl.c (declspecs_add_type, finish_declspecs): Handle
__auto_type.
* c-parser.c (c_token_starts_typename, c_token_starts_declspecs)
(c_parser_attribute_any_word, c_parser_objc_selector): Handle
RID_AUTO_TYPE.
(c_parser_declspecs): Take argument AUTO_TYPE_OK.
(c_parser_declaration_or_fndef, c_parser_struct_declaration)
(c_parser_declarator, c_parser_direct_declarator_inner)
(c_parser_parameter_declaration, c_parser_type_name): All callers
changed.
(c_parser_declaration_or_fndef): Handle declarations with type
determined from the initializer.
testsuite:
* gcc.dg/atomic/stdatomic-vm.c, gcc.dg/auto-type-1.c,
gcc.dg/auto-type-2.c: New tests.
From-SVN: r204731
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/atomic/stdatomic-vm.c | 68 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/auto-type-1.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/auto-type-2.c | 23 |
4 files changed, 133 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 09c7f2017af..2d724f73207 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-11-13 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/atomic/stdatomic-vm.c, gcc.dg/auto-type-1.c, + gcc.dg/auto-type-2.c: New tests. + 2013-11-12 Balaji V. Iyer <balaji.v.iyer@intel.com> * gcc.dg/cilk-plus/cilk-plus.exp: Added a check for LTO before running diff --git a/gcc/testsuite/gcc.dg/atomic/stdatomic-vm.c b/gcc/testsuite/gcc.dg/atomic/stdatomic-vm.c new file mode 100644 index 00000000000..f43fa49ef12 --- /dev/null +++ b/gcc/testsuite/gcc.dg/atomic/stdatomic-vm.c @@ -0,0 +1,68 @@ +/* Test atomic operations on expressions of variably modified type + with side effects. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include <stdatomic.h> + +extern void abort (void); + +int s = 5; + +int count = 0; + +int +func (void) +{ + count++; + return 0; +} + +int +main (void) +{ + int vla[s][s]; + int (*_Atomic p)[s] = &vla[0]; + int (*b)[s] = kill_dependency (++p); + if (b != &vla[1] || p != &vla[1]) + abort (); + int (*_Atomic *q)[s] = &p; + atomic_store_explicit (q + func (), &vla[0], memory_order_seq_cst); + if (count != 1) + abort (); + atomic_store (q + func (), &vla[0]); + if (count != 2) + abort (); + (void) atomic_load_explicit (q + func (), memory_order_seq_cst); + if (count != 3) + abort (); + (void) atomic_load (q + func ()); + if (count != 4) + abort (); + (void) atomic_exchange_explicit (q + func (), &vla[0], memory_order_seq_cst); + if (count != 5) + abort (); + (void) atomic_exchange (q + func (), &vla[0]); + if (count != 6) + abort (); + int vla2[s][s]; + int (*p2)[s] = &vla2[0]; + int (**qna)[s] = &p2; + (void) atomic_compare_exchange_strong_explicit (q + func (), qna, &vla[0], + memory_order_seq_cst, + memory_order_seq_cst); + if (count != 7) + abort (); + (void) atomic_compare_exchange_strong (q + func (), qna, &vla[0]); + if (count != 8) + abort (); + (void) atomic_compare_exchange_weak_explicit (q + func (), qna, &vla[0], + memory_order_seq_cst, + memory_order_seq_cst); + if (count != 9) + abort (); + (void) atomic_compare_exchange_weak (q + func (), qna, &vla[0]); + if (count != 10) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/auto-type-1.c b/gcc/testsuite/gcc.dg/auto-type-1.c new file mode 100644 index 00000000000..f47693abbf3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/auto-type-1.c @@ -0,0 +1,37 @@ +/* Test __auto_type. Test correct uses. */ +/* { dg-do run } */ +/* { dg-options "" } */ + +extern void abort (void); +extern void exit (int); + +__auto_type i = 1; +extern int i; +__auto_type c = (char) 1; +extern char c; +static __auto_type u = 10U; +extern unsigned int u; +const __auto_type ll = 1LL; +extern const long long ll; + +int +main (void) +{ + if (i != 1 || c != 1 || u != 10U) + abort (); + __auto_type ai = i; + int *aip = &ai; + if (ai != 1) + abort (); + __auto_type p = (int (*) [++i]) 0; + if (i != 2) + abort (); + if (sizeof (*p) != 2 * sizeof (int)) + abort (); + int vla[u][u]; + int (*vp)[u] = &vla[0]; + __auto_type vpp = ++vp; + if (vp != &vla[1]) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/auto-type-2.c b/gcc/testsuite/gcc.dg/auto-type-2.c new file mode 100644 index 00000000000..761671b3c5a --- /dev/null +++ b/gcc/testsuite/gcc.dg/auto-type-2.c @@ -0,0 +1,23 @@ +/* Test __auto_type. Test invalid uses. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +__auto_type; /* { dg-error "empty declaration" } */ +__auto_type *p = (int *) 0; /* { dg-error "plain identifier" } */ +struct s0 { int i : 1; } x; +void f (void) { __auto_type v = x.i; } /* { dg-error "bit-field initializer" } */ +__auto_type i; /* { dg-error "initialized data declaration" } */ +__auto_type g { } /* { dg-error "initialized data declaration" } */ +__auto_type a = 1, b = 2; /* { dg-error "single declarator" } */ +__auto_type long e0 = 0; /* { dg-error "__auto_type" } */ +__auto_type short e1 = 0; /* { dg-error "__auto_type" } */ +__auto_type signed e2 = 0; /* { dg-error "__auto_type" } */ +__auto_type unsigned e3 = 0; /* { dg-error "__auto_type" } */ +__auto_type _Complex e4 = 0; /* { dg-error "__auto_type" } */ +long __auto_type e5 = 0; /* { dg-error "__auto_type" } */ +short __auto_type e6 = 0; /* { dg-error "__auto_type" } */ +signed __auto_type e7 = 0; /* { dg-error "__auto_type" } */ +unsigned __auto_type e8 = 0; /* { dg-error "__auto_type" } */ +_Complex __auto_type e9 = 0; /* { dg-error "__auto_type" } */ +int __auto_type e10 = 0; /* { dg-error "two or more data types" } */ +__auto_type _Bool e11 = 0; /* { dg-error "two or more data types" } */ |