Commit 9698b078 by Sebastian Huber Committed by Marek Polacek

c-parser.c (c_parser_declaration_or_fndef): Discard all type qualifiers in…

c-parser.c (c_parser_declaration_or_fndef): Discard all type qualifiers in __auto_type for atomic types.

	* c-parser.c (c_parser_declaration_or_fndef): Discard all type
	qualifiers in __auto_type for atomic types.
	(c_parser_typeof_specifier): Discard all type qualifiers in
	__typeof__ for atomic types.

	* gcc.dg/typeof-2.c: New testcase.

From-SVN: r212062
parent 4443341a
2014-06-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
* c-parser.c (c_parser_declaration_or_fndef): Discard all type
qualifiers in __auto_type for atomic types.
(c_parser_typeof_specifier): Discard all type qualifiers in
__typeof__ for atomic types.
2014-06-25 Marek Polacek <polacek@redhat.com> 2014-06-25 Marek Polacek <polacek@redhat.com>
PR c/61162 PR c/61162
......
...@@ -1720,14 +1720,10 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, ...@@ -1720,14 +1720,10 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
" initializer"); " initializer");
init = convert_lvalue_to_rvalue (init_loc, init, true, true); init = convert_lvalue_to_rvalue (init_loc, init, true, true);
tree init_type = TREE_TYPE (init.value); tree init_type = TREE_TYPE (init.value);
/* As with typeof, remove _Atomic and const /* As with typeof, remove all qualifiers from atomic types. */
qualifiers from atomic types. */
if (init_type != error_mark_node && TYPE_ATOMIC (init_type)) if (init_type != error_mark_node && TYPE_ATOMIC (init_type))
init_type init_type
= c_build_qualified_type (init_type, = c_build_qualified_type (init_type, TYPE_UNQUALIFIED);
(TYPE_QUALS (init_type)
& ~(TYPE_QUAL_ATOMIC
| TYPE_QUAL_CONST)));
bool vm_type = variably_modified_type_p (init_type, bool vm_type = variably_modified_type_p (init_type,
NULL_TREE); NULL_TREE);
if (vm_type) if (vm_type)
...@@ -3024,16 +3020,11 @@ c_parser_typeof_specifier (c_parser *parser) ...@@ -3024,16 +3020,11 @@ c_parser_typeof_specifier (c_parser *parser)
if (was_vm) if (was_vm)
ret.expr = c_fully_fold (expr.value, false, &ret.expr_const_operands); ret.expr = c_fully_fold (expr.value, false, &ret.expr_const_operands);
pop_maybe_used (was_vm); pop_maybe_used (was_vm);
/* For use in macros such as those in <stdatomic.h>, remove /* For use in macros such as those in <stdatomic.h>, remove all
_Atomic and const qualifiers from atomic types. (Possibly qualifiers from atomic types. (const can be an issue for more macros
all qualifiers should be removed; const can be an issue for using typeof than just the <stdatomic.h> ones.) */
more macros using typeof than just the <stdatomic.h>
ones.) */
if (ret.spec != error_mark_node && TYPE_ATOMIC (ret.spec)) if (ret.spec != error_mark_node && TYPE_ATOMIC (ret.spec))
ret.spec = c_build_qualified_type (ret.spec, ret.spec = c_build_qualified_type (ret.spec, TYPE_UNQUALIFIED);
(TYPE_QUALS (ret.spec)
& ~(TYPE_QUAL_ATOMIC
| TYPE_QUAL_CONST)));
} }
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
return ret; return ret;
......
2014-06-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
* gcc.dg/typeof-2.c: New testcase.
2014-06-27 Marek Polacek <polacek@redhat.com> 2014-06-27 Marek Polacek <polacek@redhat.com>
* c-c++-common/ubsan/bounds-2.c: Adjust dg-output. * c-c++-common/ubsan/bounds-2.c: Adjust dg-output.
......
/* Test qualifier discard of typeof for atomic types. */
/* { dg-do compile } */
/* { dg-options "-std=c11" } */
extern int i;
extern int * p;
extern int _Atomic const ci;
extern __typeof (ci) i;
extern int _Atomic volatile vi;
extern __typeof (vi) i;
extern int * _Atomic restrict ri;
extern __typeof (ri) p;
void f(void)
{
__auto_type aci = ci;
int *paci = &aci;
__auto_type avi = vi;
int *pavi = &avi;
__auto_type ari = ri;
int **pari = &ari;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment