" initializer");
init = convert_lvalue_to_rvalue (init_loc, init, true, true);
tree init_type = TREE_TYPE (init.value);
- /* As with typeof, remove all qualifiers from atomic types. */
- if (init_type != error_mark_node && TYPE_ATOMIC (init_type))
- init_type
- = c_build_qualified_type (init_type, TYPE_UNQUALIFIED);
bool vm_type = variably_modified_type_p (init_type,
NULL_TREE);
if (vm_type)
if (was_vm)
ret.expr = c_fully_fold (expr.value, false, &ret.expr_const_operands);
pop_maybe_used (was_vm);
- /* For use in macros such as those in <stdatomic.h>, remove all
- qualifiers from atomic types. (const can be an issue for more macros
- using typeof than just the <stdatomic.h> ones.) */
- if (ret.spec != error_mark_node && TYPE_ATOMIC (ret.spec))
- ret.spec = c_build_qualified_type (ret.spec, TYPE_UNQUALIFIED);
}
parens.skip_until_found_close (parser);
return ret;
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
-/* Note that these macros require __typeof__ and __auto_type to remove
+/* Note that these macros require __auto_type to remove
_Atomic qualifiers (and const qualifiers, if those are valid on
macro operands).
__extension__ \
({ \
__auto_type __atomic_store_ptr = (PTR); \
- __typeof__ (*__atomic_store_ptr) __atomic_store_tmp = (VAL); \
+ __typeof__ ((void)0, *__atomic_store_ptr) __atomic_store_tmp = (VAL); \
__atomic_store (__atomic_store_ptr, &__atomic_store_tmp, (MO)); \
})
__extension__ \
({ \
__auto_type __atomic_load_ptr = (PTR); \
- __typeof__ (*__atomic_load_ptr) __atomic_load_tmp; \
+ __typeof__ ((void)0, *__atomic_load_ptr) __atomic_load_tmp; \
__atomic_load (__atomic_load_ptr, &__atomic_load_tmp, (MO)); \
__atomic_load_tmp; \
})
__extension__ \
({ \
__auto_type __atomic_exchange_ptr = (PTR); \
- __typeof__ (*__atomic_exchange_ptr) __atomic_exchange_val = (VAL); \
- __typeof__ (*__atomic_exchange_ptr) __atomic_exchange_tmp; \
+ __typeof__ ((void)0, *__atomic_exchange_ptr) __atomic_exchange_val = (VAL); \
+ __typeof__ ((void)0, *__atomic_exchange_ptr) __atomic_exchange_tmp; \
__atomic_exchange (__atomic_exchange_ptr, &__atomic_exchange_val, \
&__atomic_exchange_tmp, (MO)); \
__atomic_exchange_tmp; \
__extension__ \
({ \
__auto_type __atomic_compare_exchange_ptr = (PTR); \
- __typeof__ (*__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \
+ __typeof__ ((void)0, *__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \
= (DES); \
__atomic_compare_exchange (__atomic_compare_exchange_ptr, (VAL), \
&__atomic_compare_exchange_tmp, 0, \
__extension__ \
({ \
__auto_type __atomic_compare_exchange_ptr = (PTR); \
- __typeof__ (*__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \
+ __typeof__ ((void)0, *__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \
= (DES); \
__atomic_compare_exchange (__atomic_compare_exchange_ptr, (VAL), \
&__atomic_compare_exchange_tmp, 1, \
-/* Test qualifier discard of typeof for atomic types. */
+/* Test qualifier preservation of typeof and discarded for __auto_type. */
/* { dg-do compile } */
/* { dg-options "-std=c11" } */
-/* Check that the qualifiers are discarded for atomic types. */
+/* Check that the qualifiers are preserved for atomic types. */
extern int i;
extern int * p;
extern int _Atomic const ci;
-extern __typeof (ci) i;
+extern __typeof (ci) ci;
extern int _Atomic volatile vi;
-extern __typeof (vi) i;
+extern __typeof (vi) vi;
extern int * _Atomic restrict ri;
-extern __typeof (ri) p;
+extern __typeof (ri) ri;
+
+/* Check that the qualifiers are discarded for atomic types. */
void f(void)
{
extern int * restrict nri;
extern __typeof (nri) q;
+/* Check that the qualifiers are discarded for non-atomic types. */
+
void g(void)
{
__auto_type aci = nci;
- int const *paci = &aci;
+ int *paci = &aci;
__auto_type avi = nvi;
- int volatile *pavi = &avi;
+ int *pavi = &avi;
__auto_type ari = nri;
- int * restrict *pari = &ari;
+ int **pari = &ari;
}