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/ginclude/stdatomic.h | |
parent | d6d3f03341138d3918c71ce9fc6f05b81ebe004e (diff) | |
download | gcc-38b7bc7fc6a883b7ed12f27c798496fceef28ba2.zip gcc-38b7bc7fc6a883b7ed12f27c798496fceef28ba2.tar.gz gcc-38b7bc7fc6a883b7ed12f27c798496fceef28ba2.tar.bz2 |
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/ginclude/stdatomic.h')
-rw-r--r-- | gcc/ginclude/stdatomic.h | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/gcc/ginclude/stdatomic.h b/gcc/ginclude/stdatomic.h index 622577f..b558bf1 100644 --- a/gcc/ginclude/stdatomic.h +++ b/gcc/ginclude/stdatomic.h @@ -87,7 +87,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; #define kill_dependency(Y) \ __extension__ \ ({ \ - __typeof__ (Y) __kill_dependency_tmp = (Y); \ + __auto_type __kill_dependency_tmp = (Y); \ __kill_dependency_tmp; \ }) @@ -121,9 +121,9 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; __atomic_type_lock_free (void * _Atomic) -/* Note that these macros require __typeof__ to remove _Atomic - qualifiers (and const qualifiers, if those are valid on macro - operands). +/* Note that these macros require __typeof__ and __auto_type to remove + _Atomic qualifiers (and const qualifiers, if those are valid on + macro operands). Also note that the header file uses the generic form of __atomic builtins, which requires the address to be taken of the value @@ -132,11 +132,12 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; these to lock-free _N variants if possible, and throw away the temps. */ -#define atomic_store_explicit(PTR, VAL, MO) \ - __extension__ \ - ({ \ - __typeof__ (*(PTR)) __atomic_store_tmp = (VAL); \ - __atomic_store ((PTR), &__atomic_store_tmp, (MO)); \ +#define atomic_store_explicit(PTR, VAL, MO) \ + __extension__ \ + ({ \ + __auto_type __atomic_store_ptr = (PTR); \ + __typeof__ (*__atomic_store_ptr) __atomic_store_tmp = (VAL); \ + __atomic_store (__atomic_store_ptr, &__atomic_store_tmp, (MO)); \ }) #define atomic_store(PTR, VAL) \ @@ -146,8 +147,9 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; #define atomic_load_explicit(PTR, MO) \ __extension__ \ ({ \ - __typeof__ (*(PTR)) __atomic_load_tmp; \ - __atomic_load ((PTR), &__atomic_load_tmp, (MO)); \ + __auto_type __atomic_load_ptr = (PTR); \ + __typeof__ (*__atomic_load_ptr) __atomic_load_tmp; \ + __atomic_load (__atomic_load_ptr, &__atomic_load_tmp, (MO)); \ __atomic_load_tmp; \ }) @@ -157,8 +159,10 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; #define atomic_exchange_explicit(PTR, VAL, MO) \ __extension__ \ ({ \ - __typeof__ (*(PTR)) __atomic_exchange_val = (VAL), __atomic_exchange_tmp; \ - __atomic_exchange ((PTR), &__atomic_exchange_val, \ + __auto_type __atomic_exchange_ptr = (PTR); \ + __typeof__ (*__atomic_exchange_ptr) __atomic_exchange_val = (VAL); \ + __typeof__ (*__atomic_exchange_ptr) __atomic_exchange_tmp; \ + __atomic_exchange (__atomic_exchange_ptr, &__atomic_exchange_val, \ &__atomic_exchange_tmp, (MO)); \ __atomic_exchange_tmp; \ }) @@ -170,8 +174,10 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; #define atomic_compare_exchange_strong_explicit(PTR, VAL, DES, SUC, FAIL) \ __extension__ \ ({ \ - __typeof__ (*(PTR)) __atomic_compare_exchange_tmp = (DES); \ - __atomic_compare_exchange ((PTR), (VAL), \ + __auto_type __atomic_compare_exchange_ptr = (PTR); \ + __typeof__ (*__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \ + = (DES); \ + __atomic_compare_exchange (__atomic_compare_exchange_ptr, (VAL), \ &__atomic_compare_exchange_tmp, 0, \ (SUC), (FAIL)); \ }) @@ -183,8 +189,10 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; #define atomic_compare_exchange_weak_explicit(PTR, VAL, DES, SUC, FAIL) \ __extension__ \ ({ \ - __typeof__ (*(PTR)) __atomic_compare_exchange_tmp = (DES); \ - __atomic_compare_exchange ((PTR), (VAL), \ + __auto_type __atomic_compare_exchange_ptr = (PTR); \ + __typeof__ (*__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \ + = (DES); \ + __atomic_compare_exchange (__atomic_compare_exchange_ptr, (VAL), \ &__atomic_compare_exchange_tmp, 1, \ (SUC), (FAIL)); \ }) |