[{"id":1761178,"web_url":"http://patchwork.ozlabs.org/comment/1761178/","msgid":"<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>","list_archive_url":null,"date":"2017-08-31T16:38:27","subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","submitter":{"id":4349,"url":"http://patchwork.ozlabs.org/api/people/4349/","name":"Joseph Myers","email":"joseph@codesourcery.com"},"content":"I think the documentation needs to say (and the tests need to test) that \nthis produces a non-atomic type (like lvalue-to-rvalue conversion), if \nthat's the intent for how it handles atomic types, since _Atomic is \nsyntactically a qualifier but largely not treated like one in the \nstandard.","headers":{"Return-Path":"<gcc-patches-return-461216-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461216-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"WC3OGB1M\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjp3g0Vl3z9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 02:38:54 +1000 (AEST)","(qmail 86330 invoked by alias); 31 Aug 2017 16:38:46 -0000","(qmail 85705 invoked by uid 89); 31 Aug 2017 16:38:46 -0000","from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131)\n\tby sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with\n\tESMTP; Thu, 31 Aug 2017 16:38:36 +0000","from nat-ies.mentorg.com ([192.94.31.2]\n\thelo=svr-ies-mbx-01.mgc.mentorg.com)\tby relay1.mentorg.com\n\twith esmtp id 1dnSUE-00077R-Df from joseph_myers@mentor.com ;\n\tThu, 31 Aug 2017 09:38:34 -0700","from digraph.polyomino.org.uk (137.202.0.87) by\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft\n\tSMTP Server (TLS) id 15.0.1263.5; Thu, 31 Aug 2017 17:38:30 +0100","from jsm28 (helo=localhost)\tby digraph.polyomino.org.uk with\n\tlocal-esmtp (Exim 4.86_2)\t(envelope-from\n\t<joseph@codesourcery.com>)\tid 1dnSU7-0004O0-54;\n\tThu, 31 Aug 2017 16:38:27 +0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:in-reply-to:message-id:references\n\t:mime-version:content-type; q=dns; s=default; b=KbhxcCXF4RU/aXHR\n\tJDGJzLAhejl4hzEhWldSsYfYJrE5k0gyCocOcdnTOYBE1XIAAV7I7KOgnwFhz/jm\n\tdHQeUNnptgpUgnKW8auNQp+r4kl01xD1zAkwaiwaswu6czBRX2iad65jbzAjBuTD\n\t/dXM90ZMYJ6Xs+Qlhb/IUpQa8C4=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:in-reply-to:message-id:references\n\t:mime-version:content-type; s=default; bh=XkMrlewxw6iWDnDX4mq4K5\n\tbPFPI=; b=WC3OGB1Mif9i+qZvagS6pt05BhLxVJRwufv+y3eolNBPUcqF1oDSnS\n\t4E3QjJnlzLeBzywoXjMJUq+hU90nPZXKP2hHSGjvzUVJ5x7b2cANKGvFl40VCi/7\n\tmxDPJZ0t7yR9zJT+fr/CEEBNc3sU4CE0g3NHLL1KyywrkSQhq8s1w=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-2.0 required=5.0 tests=AWL, BAYES_00,\n\tRCVD_IN_DNSWL_NONE, SPF_PASS,\n\tURIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:398","X-HELO":"relay1.mentorg.com","Date":"Thu, 31 Aug 2017 16:38:27 +0000","From":"Joseph Myers <joseph@codesourcery.com>","To":"Marek Polacek <polacek@redhat.com>","CC":"GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>","Subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","In-Reply-To":"<20170831152515.GR17069@redhat.com>","Message-ID":"<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>","References":"<20170831152515.GR17069@redhat.com>","User-Agent":"Alpine 2.20 (DEB 67 2015-01-07)","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"US-ASCII\"","X-ClientProxiedBy":"svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1)"}},{"id":1761656,"web_url":"http://patchwork.ozlabs.org/comment/1761656/","msgid":"<20170901124638.GT17069@redhat.com>","list_archive_url":null,"date":"2017-09-01T12:46:38","subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","submitter":{"id":14370,"url":"http://patchwork.ozlabs.org/api/people/14370/","name":"Marek Polacek","email":"polacek@redhat.com"},"content":"On Thu, Aug 31, 2017 at 04:38:27PM +0000, Joseph Myers wrote:\n> I think the documentation needs to say (and the tests need to test) that \n> this produces a non-atomic type (like lvalue-to-rvalue conversion), if \n> that's the intent for how it handles atomic types, since _Atomic is \n> syntactically a qualifier but largely not treated like one in the \n> standard.\n\nTrue, updated patch here:\n\nBootstrapped/regtested on x86_64-linux, ok for trunk?\n\n2017-09-01  Marek Polacek  <polacek@redhat.com>\n\n\tPR c/39985\n\tPR c/65455\n\t* c-common.c (c_common_reswords): Add __remove_qualifiers and\n\t__remove_qualifiers__.\n\t(keyword_begins_type_specifier): Handle RID_REMOVE_QUALS.\n\t* c-common.h (enum rid): Add RID_REMOVE_QUALS.\n\n\t* c-decl.c (start_struct): Also check in_remove_qualifiers.\n\t(finish_struct): Likewise.\n\t(start_enum): Likewise.\n\t(finish_enum): Likewise.\n\t* c-parser.c (c_keyword_starts_typename): Handle RID_REMOVE_QUALS.\n\t(c_token_starts_declspecs): Likewise.\n\t(c_parser_declaration_or_fndef): For __auto_type, remove all type\n\tqualifiers.\n\t(c_parser_declspecs): Handle RID_REMOVE_QUALS.\n\t(c_parser_remove_qualifiers_specifier): New function.\n\t(c_parser_objc_selector): Handle RID_REMOVE_QUALS.\n\t* c-tree.h (enum c_typespec_kind): Update a comment.\n\tDeclare in_remove_qualifiers.\n\t* c-typeck.c (in_remove_qualifiers): New global variable.\n\t(build_external_ref): Also check in_remove_qualifiers.\n\t(struct maybe_used_decl): Likewise.\n\t(record_maybe_used_decl): Likewise.\n\t(pop_maybe_used): Likewise.\n\n\t* parser.c (cp_keyword_starts_decl_specifier_p): Handle\n\tRID_REMOVE_QUALS.\n\t(cp_parser_simple_type_specifier): Likewise.\n\t(cp_parser_sizeof_operand): For __remove_qualifiers, remove all type\n\tqualifiers.\n\n\t* doc/extend.texi: Document __remove_qualifiers.\n\n\t* c-c++-common/remove-quals-1.c: New test.\n\t* c-c++-common/remove-quals-2.c: New test.\n\t* c-c++-common/remove-quals-3.c: New test.\n\t* c-c++-common/remove-quals-4.c: New test.\n\t* g++.dg/ext/remove-quals-1.C: New test.\n\t* g++.dg/ext/remove-quals-2.C: New test.\n\t* gcc.dg/auto-type-3.c: New test.\n\t* gcc.dg/remove-quals-1.c: New test.\n\t* gcc.dg/remove-quals-2.c: New test.\n\t* gcc.dg/remove-quals-3.c: New test.\n\ndiff --git gcc/c-family/c-common.c gcc/c-family/c-common.c\nindex d959dbc25bb..ae92ff440f6 100644\n--- gcc/c-family/c-common.c\n+++ gcc/c-family/c-common.c\n@@ -423,6 +423,8 @@ const struct c_common_resword c_common_reswords[] =\n   { \"__null\",\t\tRID_NULL,\t0 },\n   { \"__real\",\t\tRID_REALPART,\t0 },\n   { \"__real__\",\t\tRID_REALPART,\t0 },\n+  { \"__remove_qualifiers\", RID_REMOVE_QUALS, 0 },\n+  { \"__remove_qualifiers__\", RID_REMOVE_QUALS, 0 },\n   { \"__restrict\",\tRID_RESTRICT,\t0 },\n   { \"__restrict__\",\tRID_RESTRICT,\t0 },\n   { \"__signed\",\t\tRID_SIGNED,\t0 },\n@@ -7525,6 +7527,7 @@ keyword_begins_type_specifier (enum rid keyword)\n     case RID_CLASS:\n     case RID_UNION:\n     case RID_ENUM:\n+    case RID_REMOVE_QUALS:\n       return true;\n     default:\n       if (keyword >= RID_FIRST_INT_N\ndiff --git gcc/c-family/c-common.h gcc/c-family/c-common.h\nindex 8e367680600..e726aa8844b 100644\n--- gcc/c-family/c-common.h\n+++ gcc/c-family/c-common.h\n@@ -101,7 +101,7 @@ enum rid\n   RID_ASM,       RID_TYPEOF,   RID_ALIGNOF,  RID_ATTRIBUTE,  RID_VA_ARG,\n   RID_EXTENSION, RID_IMAGPART, RID_REALPART, RID_LABEL,      RID_CHOOSE_EXPR,\n   RID_TYPES_COMPATIBLE_P,      RID_BUILTIN_COMPLEX,\t     RID_BUILTIN_SHUFFLE,\n-  RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128,\n+  RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128,  RID_REMOVE_QUALS,\n \n   /* TS 18661-3 keywords, in the same sequence as the TI_* values.  */\n   RID_FLOAT16,\ndiff --git gcc/c/c-decl.c gcc/c/c-decl.c\nindex d526f0e88e4..b9cd5f8cf56 100644\n--- gcc/c/c-decl.c\n+++ gcc/c/c-decl.c\n@@ -7516,12 +7516,14 @@ start_struct (location_t loc, enum tree_code code, tree name,\n      within a statement expr used within sizeof, et. al.  This is not\n      terribly serious as C++ doesn't permit statement exprs within\n      sizeof anyhow.  */\n-  if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof))\n+  if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof\n+\t\t\t  || in_remove_qualifiers))\n     warning_at (loc, OPT_Wc___compat,\n \t\t\"defining type in %qs expression is invalid in C++\",\n-\t\t(in_sizeof\n-\t\t ? \"sizeof\"\n-\t\t : (in_typeof ? \"typeof\" : \"alignof\")));\n+\t\t(in_sizeof ? \"sizeof\"\n+\t\t : (in_typeof ? \"typeof\"\n+\t\t\t      : (in_alignof ? \"alignof\"\n+\t\t\t\t\t    : \"__remove_qualifiers\"))));\n \n   return ref;\n }\n@@ -8159,7 +8161,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,\n      struct_types.  */\n   if (warn_cxx_compat\n       && struct_parse_info != NULL\n-      && !in_sizeof && !in_typeof && !in_alignof)\n+      && !in_sizeof && !in_typeof && !in_alignof && !in_remove_qualifiers)\n     struct_parse_info->struct_types.safe_push (t);\n \n   return t;\n@@ -8235,12 +8237,14 @@ start_enum (location_t loc, struct c_enum_contents *the_enum, tree name)\n   /* FIXME: This will issue a warning for a use of a type defined\n      within sizeof in a statement expr.  This is not terribly serious\n      as C++ doesn't permit statement exprs within sizeof anyhow.  */\n-  if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof))\n+  if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof\n+\t\t\t  || in_remove_qualifiers))\n     warning_at (loc, OPT_Wc___compat,\n \t\t\"defining type in %qs expression is invalid in C++\",\n-\t\t(in_sizeof\n-\t\t ? \"sizeof\"\n-\t\t : (in_typeof ? \"typeof\" : \"alignof\")));\n+\t\t(in_sizeof ? \"sizeof\"\n+\t\t : (in_typeof ? \"typeof\"\n+\t\t\t      : (in_alignof ? \"alignof\"\n+\t\t\t\t\t    : \"__remove_qualifiers\"))));\n \n   return enumtype;\n }\n@@ -8395,7 +8399,7 @@ finish_enum (tree enumtype, tree values, tree attributes)\n      struct_types.  */\n   if (warn_cxx_compat\n       && struct_parse_info != NULL\n-      && !in_sizeof && !in_typeof && !in_alignof)\n+      && !in_sizeof && !in_typeof && !in_alignof && !in_remove_qualifiers)\n     struct_parse_info->struct_types.safe_push (enumtype);\n \n   return enumtype;\ndiff --git gcc/c/c-parser.c gcc/c/c-parser.c\nindex f4e1cf6aa0c..f65d5f17ebb 100644\n--- gcc/c/c-parser.c\n+++ gcc/c/c-parser.c\n@@ -504,6 +504,7 @@ c_keyword_starts_typename (enum rid keyword)\n     case RID_ACCUM:\n     case RID_SAT:\n     case RID_AUTO_TYPE:\n+    case RID_REMOVE_QUALS:\n       return true;\n     default:\n       if (keyword >= RID_FIRST_INT_N\n@@ -681,6 +682,7 @@ c_token_starts_declspecs (c_token *token)\n \tcase RID_ALIGNAS:\n \tcase RID_ATOMIC:\n \tcase RID_AUTO_TYPE:\n+\tcase RID_REMOVE_QUALS:\n \t  return true;\n \tdefault:\n \t  if (token->keyword >= RID_FIRST_INT_N\n@@ -1361,6 +1363,7 @@ static struct c_typespec c_parser_enum_specifier (c_parser *);\n static struct c_typespec c_parser_struct_or_union_specifier (c_parser *);\n static tree c_parser_struct_declaration (c_parser *);\n static struct c_typespec c_parser_typeof_specifier (c_parser *);\n+static struct c_typespec c_parser_remove_qualifiers_specifier (c_parser *);\n static tree c_parser_alignas_specifier (c_parser *);\n static struct c_declarator *c_parser_direct_declarator (c_parser *, bool,\n \t\t\t\t\t\t\tc_dtr_syn, bool *);\n@@ -2039,8 +2042,8 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,\n \t\t\t      \" initializer\");\n \t\t  init = convert_lvalue_to_rvalue (init_loc, init, true, true);\n \t\t  tree init_type = TREE_TYPE (init.value);\n-\t\t  /* As with typeof, remove all qualifiers from atomic types.  */\n-\t\t  if (init_type != error_mark_node && TYPE_ATOMIC (init_type))\n+\t\t  /* Remove all qualifiers from all types.  */\n+\t\t  if (init_type != error_mark_node)\n \t\t    init_type\n \t\t      = c_build_qualified_type (init_type, TYPE_UNQUALIFIED);\n \t\t  bool vm_type = variably_modified_type_p (init_type,\n@@ -2732,6 +2735,14 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,\n \t  t = c_parser_typeof_specifier (parser);\n \t  declspecs_add_type (loc, specs, t);\n \t  break;\n+\tcase RID_REMOVE_QUALS:\n+\t  if (!typespec_ok)\n+\t    goto out;\n+\t  attrs_ok = true;\n+\t  seen_type = true;\n+\t  t = c_parser_remove_qualifiers_specifier (parser);\n+\t  declspecs_add_type (loc, specs, t);\n+\t  break;\n \tcase RID_ATOMIC:\n \t  /* C parser handling of Objective-C constructs needs\n \t     checking for correct lvalue-to-rvalue conversions, and\n@@ -3435,6 +3446,55 @@ c_parser_typeof_specifier (c_parser *parser)\n   return ret;\n }\n \n+/* Parse a __remove_qualifiers specifier (a GNU extension).\n+\n+   remove-qualifiers-specifier:\n+     __remove_qualifiers ( type-name )\n+*/\n+\n+static struct c_typespec\n+c_parser_remove_qualifiers_specifier (c_parser *parser)\n+{\n+  struct c_typespec ret;\n+  ret.kind = ctsk_typeof;\n+  ret.spec = error_mark_node;\n+  ret.expr = NULL_TREE;\n+  ret.expr_const_operands = true;\n+  gcc_assert (c_parser_next_token_is_keyword (parser, RID_REMOVE_QUALS));\n+\n+  /* Consume '__remove_qualifiers'.  */\n+  c_parser_consume_token (parser);\n+\n+  matching_parens parens;\n+  if (!parens.require_open (parser))\n+    return ret;\n+\n+  /* Only accept a type-name as an argument.  */\n+  if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))\n+    {\n+      /* Do not warn about problems with the expression.  */\n+      c_inhibit_evaluation_warnings++;\n+      in_remove_qualifiers++;\n+      struct c_type_name *type = c_parser_type_name (parser);\n+      /* Go back to evaluating expressions.  */\n+      c_inhibit_evaluation_warnings--;\n+      in_remove_qualifiers--;\n+      if (type != NULL)\n+\t{\n+\t  ret.spec = groktypename (type, &ret.expr, &ret.expr_const_operands);\n+\t  pop_maybe_used (variably_modified_type_p (ret.spec, NULL_TREE));\n+\t  /* Remove all type qualifiers.  */\n+\t  if (ret.spec != error_mark_node)\n+\t    ret.spec = c_build_qualified_type (ret.spec, TYPE_UNQUALIFIED);\n+\t}\n+    }\n+  else\n+    error_at (c_parser_peek_token (parser)->location,\n+\t      \"%<__remove_qualifiers%> can only be applied to a type\");\n+  parens.skip_until_found_close (parser);\n+  return ret;\n+}\n+\n /* Parse an alignment-specifier.\n \n    C11 6.7.5:\n@@ -9879,7 +9939,7 @@ c_parser_objc_synchronized_statement (c_parser *parser)\n        break continue return goto asm sizeof typeof __alignof\n        unsigned long const short volatile signed restrict _Complex\n        in out inout bycopy byref oneway int char float double void _Bool\n-       _Atomic\n+       _Atomic __remove_qualifiers\n \n    ??? Why this selection of keywords but not, for example, storage\n    class specifiers?  */\n@@ -9944,6 +10004,7 @@ c_parser_objc_selector (c_parser *parser)\n     case RID_INT_N_1:\n     case RID_INT_N_2:\n     case RID_INT_N_3:\n+    case RID_REMOVE_QUALS:\n       c_parser_consume_token (parser);\n       return value;\n     default:\ndiff --git gcc/c/c-tree.h gcc/c/c-tree.h\nindex 96c7ae7613f..e16c4185350 100644\n--- gcc/c/c-tree.h\n+++ gcc/c/c-tree.h\n@@ -191,7 +191,7 @@ enum c_typespec_kind {\n   ctsk_typedef,\n   /* An ObjC-specific kind of type specifier.  */\n   ctsk_objc,\n-  /* A typeof specifier, or _Atomic ( type-name ).  */\n+  /* A typeof specifier, _Atomic ( type-name ), or __remove_qualifiers.  */\n   ctsk_typeof\n };\n \n@@ -617,6 +617,7 @@ extern bool c_vla_unspec_p (tree x, tree fn);\n extern int in_alignof;\n extern int in_sizeof;\n extern int in_typeof;\n+extern int in_remove_qualifiers;\n \n extern tree c_last_sizeof_arg;\n extern location_t c_last_sizeof_loc;\ndiff --git gcc/c/c-typeck.c gcc/c/c-typeck.c\nindex 135dd9d665c..ce720802e70 100644\n--- gcc/c/c-typeck.c\n+++ gcc/c/c-typeck.c\n@@ -72,6 +72,9 @@ int in_sizeof;\n /* The level of nesting inside \"typeof\".  */\n int in_typeof;\n \n+/* The level of nesting inside \"__remove_qualifiers\".  */\n+int in_remove_qualifiers;\n+\n /* The argument of last parsed sizeof expression, only to be tested\n    if expr.original_code == SIZEOF_EXPR.  */\n tree c_last_sizeof_arg;\n@@ -2782,7 +2785,7 @@ build_external_ref (location_t loc, tree id, bool fun, tree *type)\n \n   if (TREE_CODE (ref) == FUNCTION_DECL && !in_alignof)\n     {\n-      if (!in_sizeof && !in_typeof)\n+      if (!in_sizeof && !in_typeof && !in_remove_qualifiers)\n \tC_DECL_USED (ref) = 1;\n       else if (DECL_INITIAL (ref) == NULL_TREE\n \t       && DECL_EXTERNAL (ref)\n@@ -2838,7 +2841,7 @@ struct maybe_used_decl\n {\n   /* The decl.  */\n   tree decl;\n-  /* The level seen at (in_sizeof + in_typeof).  */\n+  /* The level seen at (in_sizeof + in_typeof + in_remove_qualifiers).  */\n   int level;\n   /* The next one at this level or above, or NULL.  */\n   struct maybe_used_decl *next;\n@@ -2856,7 +2859,7 @@ record_maybe_used_decl (tree decl)\n {\n   struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);\n   t->decl = decl;\n-  t->level = in_sizeof + in_typeof;\n+  t->level = in_sizeof + in_typeof + in_remove_qualifiers;\n   t->next = maybe_used_decls;\n   maybe_used_decls = t;\n }\n@@ -2870,7 +2873,7 @@ void\n pop_maybe_used (bool used)\n {\n   struct maybe_used_decl *p = maybe_used_decls;\n-  int cur_level = in_sizeof + in_typeof;\n+  int cur_level = in_sizeof + in_typeof + in_remove_qualifiers;\n   while (p && p->level > cur_level)\n     {\n       if (used)\ndiff --git gcc/cp/parser.c gcc/cp/parser.c\nindex 4bfae3655d5..2d4605d8726 100644\n--- gcc/cp/parser.c\n+++ gcc/cp/parser.c\n@@ -973,9 +973,10 @@ cp_keyword_starts_decl_specifier_p (enum rid keyword)\n     case RID_FLOAT:\n     case RID_DOUBLE:\n     case RID_VOID:\n-      /* GNU extensions.  */ \n+      /* GNU extensions.  */\n     case RID_ATTRIBUTE:\n     case RID_TYPEOF:\n+    case RID_REMOVE_QUALS:\n       /* C++0x extensions.  */\n     case RID_DECLTYPE:\n     case RID_UNDERLYING_TYPE:\n@@ -16960,6 +16961,24 @@ cp_parser_simple_type_specifier (cp_parser* parser,\n \n       return type;\n \n+    case RID_REMOVE_QUALS:\n+      /* Consume the `__remove_qualifiers' token.  */\n+      cp_lexer_consume_token (parser->lexer);\n+      /* Parse the operand to __remove_qualifiers`'.  */\n+      type = cp_parser_sizeof_operand (parser, RID_REMOVE_QUALS);\n+      if (!TYPE_P (type))\n+\t{\n+\t  error_at (token->location,\n+\t\t    \"%<__remove_qualifiers%> can only be applied to a type\");\n+\t  type = error_mark_node;\n+\t}\n+      if (decl_specs)\n+\tcp_parser_set_decl_spec_type (decl_specs, type,\n+\t\t\t\t      token,\n+\t\t\t\t      /*type_definition_p=*/false);\n+\n+      return type;\n+\n     case RID_UNDERLYING_TYPE:\n       type = cp_parser_trait_expr (parser, RID_UNDERLYING_TYPE);\n       if (decl_specs)\n@@ -27696,6 +27715,9 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)\n \t\t\t\t TYPENAME,\n \t\t\t\t /*initialized=*/0,\n \t\t\t\t /*attrlist=*/NULL);\n+\t  /* __remove_qualifiers removes all type qualifiers.  */\n+\t  if (keyword == RID_REMOVE_QUALS)\n+\t    expr = cp_build_qualified_type (expr, TYPE_UNQUALIFIED);\n \t}\n     }\n \ndiff --git gcc/doc/extend.texi gcc/doc/extend.texi\nindex 649be015dbb..8e6a7d8c395 100644\n--- gcc/doc/extend.texi\n+++ gcc/doc/extend.texi\n@@ -29,6 +29,7 @@ extensions, accepted by GCC in C90 mode and in C++.\n * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.\n * Constructing Calls::  Dispatching a call to another function.\n * Typeof::              @code{typeof}: referring to the type of an expression.\n+* __remove_qualifiers::\tRemoving type qualifiers using @code{__remove_qualifiers}.\n * Conditionals::        Omitting the middle operand of a @samp{?:} expression.\n * __int128::\t\t128-bit integers---@code{__int128}.\n * Long Long::           Double-word integers---@code{long long int}.\n@@ -788,6 +789,38 @@ evaluated only once when using @code{__auto_type}, but twice if\n @code{typeof} is used.\n @end itemize\n \n+@node __remove_qualifiers\n+@section Removing type qualifiers using @code{__remove_qualifiers}\n+@findex __remove_qualifiers\n+\n+@code{__remove_qualifiers} takes a typename as an argument:\n+\n+@smallexample\n+__remove_qualifiers (const int)\n+@end smallexample\n+\n+and produces the same type with all type qualifiers such as @code{const} and\n+@code{volatile} removed.  In C11, the @code{_Atomic} qualifier is also removed\n+so the resulting type is a non-atomic type.  This is useful in combination with\n+@code{typeof}, e.g. for certain macros when passed const arguments:\n+\n+@smallexample\n+#define MAX(x, y)                                \\\n+  (@{                                             \\\n+  __remove_qualifiers (__typeof (x)) ret = x;    \\\n+  if (y > ret) ret = y;                          \\\n+    ret;                                         \\\n+  @})\n+\n+const int ci = 5;\n+MAX (ci, 12);\n+@end smallexample\n+\n+In C++, it's possible to combine @code{__remove_qualifiers} with\n+@code{decltype} instead of @code{typeof}.\n+\n+It is an error to pass an expression as an argument.\n+\n @node Conditionals\n @section Conditionals with Omitted Operands\n @cindex conditional expressions, extensions\ndiff --git gcc/testsuite/c-c++-common/remove-quals-1.c gcc/testsuite/c-c++-common/remove-quals-1.c\nindex e69de29bb2d..28464eb6b87 100644\n--- gcc/testsuite/c-c++-common/remove-quals-1.c\n+++ gcc/testsuite/c-c++-common/remove-quals-1.c\n@@ -0,0 +1,42 @@\n+/* PR c/65455 */\n+/* { dg-do compile } */\n+/* { dg-options \"-pedantic-errors\" } */\n+\n+void\n+foo (void)\n+{\n+  int i = 0;\n+  const int ci = 0;\n+  volatile int vi = 0;\n+\n+  __typeof(i) *ip = 0;\n+  __typeof(ci) *cip = 0;\n+  __typeof(vi) *vip = 0;\n+\n+  __remove_qualifiers (__typeof (i)) *nip = 0;\n+  __remove_qualifiers (__typeof (ci)) *ncip = 0;\n+  __remove_qualifiers (__typeof (vi)) *nvip = 0;\n+\n+  __remove_qualifiers (__typeof (i)) *nip2 = 0;\n+  __remove_qualifiers (__typeof (ci)) *ncip2 = 0;\n+  __remove_qualifiers (__typeof (vi)) *nvip2 = 0;\n+\n+  ip = cip;            /* { dg-error \"assignment discards|invalid conversion\" } */\n+  ip = vip;            /* { dg-error \"assignment discards|invalid conversion\" } */\n+\n+  ip = nip;\n+  ip = ncip;\n+  ip = nvip;\n+\n+  ip = nip2;\n+  ip = ncip2;\n+  ip = nvip2;\n+\n+  ncip = cip;          /* { dg-error \"assignment discards|invalid conversion\" } */\n+  nvip = vip;          /* { dg-error \"assignment discards|invalid conversion\" } */\n+  ncip2 = cip;         /* { dg-error \"assignment discards|invalid conversion\" } */\n+  nvip2 = vip;         /* { dg-error \"assignment discards|invalid conversion\" } */\n+\n+  nip = ip;\n+  nip2 = ip;\n+}\ndiff --git gcc/testsuite/c-c++-common/remove-quals-2.c gcc/testsuite/c-c++-common/remove-quals-2.c\nindex e69de29bb2d..fac314d52d8 100644\n--- gcc/testsuite/c-c++-common/remove-quals-2.c\n+++ gcc/testsuite/c-c++-common/remove-quals-2.c\n@@ -0,0 +1,32 @@\n+/* PR c/65455 */\n+/* { dg-do compile } */\n+\n+const int g(void);\n+\n+#define MAX(__x, __y)\t\t\t\t\t\\\n+  ({\t\t\t\t\t\t\t\\\n+  __remove_qualifiers (__typeof (__x)) __ret = __x;\t\\\n+  if (__y > __ret) __ret = __y;\t\t\t\t\\\n+    __ret;\t\t\t\t\t\t\\\n+  })\n+\n+void\n+fn (void)\n+{\n+  const int ci = 5;\n+  __remove_qualifiers (__typeof (({ ci; }))) n1;\n+  __remove_qualifiers (__typeof (ci)) n2;\n+  __typeof (g ()) n4;\n+  __remove_qualifiers (__typeof (g ())) n3;\n+\n+  typedef __remove_qualifiers (__typeof (ci)) T;\n+  T n5;\n+\n+  n1 = 5;\n+  n2 = 5;\n+  n3 = 5;\n+  n4 = 5;\n+  n5 = 5;\n+\n+  MAX (ci, 12);\n+}\ndiff --git gcc/testsuite/c-c++-common/remove-quals-3.c gcc/testsuite/c-c++-common/remove-quals-3.c\nindex e69de29bb2d..c3ace534adf 100644\n--- gcc/testsuite/c-c++-common/remove-quals-3.c\n+++ gcc/testsuite/c-c++-common/remove-quals-3.c\n@@ -0,0 +1,17 @@\n+/* PR c/65455 */\n+/* { dg-do run } */\n+\n+int\n+main ()\n+{\n+  __remove_qualifiers (const int) h;\n+  h = 9;\n+\n+  int i = 1;\n+  __typeof (int [++i]) e;\n+  __remove_qualifiers (int [++i]) e2;\n+  __remove_qualifiers (__typeof (int [++i])) e3;\n+\n+  if (i != 4)\n+    __builtin_abort ();\n+}\ndiff --git gcc/testsuite/c-c++-common/remove-quals-4.c gcc/testsuite/c-c++-common/remove-quals-4.c\nindex e69de29bb2d..d140f553345 100644\n--- gcc/testsuite/c-c++-common/remove-quals-4.c\n+++ gcc/testsuite/c-c++-common/remove-quals-4.c\n@@ -0,0 +1,15 @@\n+/* PR c/65455 */\n+/* { dg-do compile } */\n+/* { dg-options \"-Wall -Wextra -Wpedantic -Wno-unused -Wno-vla\" } */\n+\n+void\n+fn (void)\n+{\n+  __typeof (int [1 / 0]) t1;\n+  __remove_qualifiers (int [1 / 0]) t2;\n+\n+  int i;\n+  __remove_qualifiers (i) t3; /* { dg-error \".__remove_qualifiers. can only be applied to a type|expected\" } */\n+  __remove_qualifiers (1) t4; /* { dg-error \".__remove_qualifiers. can only be applied to a type|expected\" } */\n+  __remove_qualifiers (int []) t5; /* { dg-error \"array size|storage size\" } */\n+}\ndiff --git gcc/testsuite/g++.dg/ext/remove-quals-1.C gcc/testsuite/g++.dg/ext/remove-quals-1.C\nindex e69de29bb2d..0d0e33538b2 100644\n--- gcc/testsuite/g++.dg/ext/remove-quals-1.C\n+++ gcc/testsuite/g++.dg/ext/remove-quals-1.C\n@@ -0,0 +1,12 @@\n+// PR c/65455\n+// { dg-do compile }\n+// { dg-options \"-pedantic-errors\" }\n+\n+void\n+fn (void)\n+{\n+  signed __remove_qualifiers (const int) s; /* { dg-error \"used invalidly\" } */\n+\n+  __typeof (struct S { int i; }) q; /* { dg-error \"types may not be defined in .typeof. expressions\" } */\n+  __remove_qualifiers (struct S2 { int i; }) q2; /* { dg-error \"types may not be defined in .__remove_qualifiers__. expressions\" } */\n+}\ndiff --git gcc/testsuite/g++.dg/ext/remove-quals-2.C gcc/testsuite/g++.dg/ext/remove-quals-2.C\nindex e69de29bb2d..10f7b5c5d7c 100644\n--- gcc/testsuite/g++.dg/ext/remove-quals-2.C\n+++ gcc/testsuite/g++.dg/ext/remove-quals-2.C\n@@ -0,0 +1,25 @@\n+// PR c/65455\n+// { dg-do compile { target c++11 } }\n+\n+template<typename T, typename U>\n+struct is_same\n+{\n+  static const bool value = false;\n+};\n+\n+template<typename T>\n+struct is_same<T, T>\n+{\n+  static const bool value = true;\n+};\n+\n+const int x = 1;\n+typedef __remove_qualifiers (decltype (x)) T;\n+T y = 1;\n+volatile int i;\n+static_assert(is_same<__remove_qualifiers (decltype (x)), int>::value,\n+\t      \"type should be int\");\n+static_assert(is_same<decltype (y), int>::value,\n+\t      \"type should be int\");\n+static_assert(is_same<__remove_qualifiers (decltype (i)), int>::value,\n+\t      \"type should be int\");\ndiff --git gcc/testsuite/gcc.dg/auto-type-3.c gcc/testsuite/gcc.dg/auto-type-3.c\nindex e69de29bb2d..79479c80084 100644\n--- gcc/testsuite/gcc.dg/auto-type-3.c\n+++ gcc/testsuite/gcc.dg/auto-type-3.c\n@@ -0,0 +1,25 @@\n+/* { dg-do compile } */\n+/* { dg-options \"\" } */\n+\n+struct S\n+{\n+  int k;\n+};\n+\n+void\n+foo (void)\n+{\n+  _Atomic register const int a = 3;\n+  const int b = 16;\n+  const struct S s;\n+  int *const c = 0;\n+\n+  __auto_type i = a;\n+  i++;\n+  __auto_type j = b;\n+  j++;\n+  __auto_type k = s.k;\n+  k++;\n+  __auto_type l = c;\n+  l++;\n+}\ndiff --git gcc/testsuite/gcc.dg/remove-quals-1.c gcc/testsuite/gcc.dg/remove-quals-1.c\nindex e69de29bb2d..aecc17c949b 100644\n--- gcc/testsuite/gcc.dg/remove-quals-1.c\n+++ gcc/testsuite/gcc.dg/remove-quals-1.c\n@@ -0,0 +1,23 @@\n+/* PR c/65455 */\n+/* { dg-do compile } */\n+/* { dg-options \"-Wrestrict\" } */\n+\n+int *restrict t;\n+\n+void\n+bar (__remove_qualifiers (__typeof (t)) p, __remove_qualifiers (__typeof (t)) q)\n+{\n+}\n+\n+void\n+baz (__typeof (t) p, __typeof (t) q)\n+{\n+}\n+\n+void\n+foo (void)\n+{\n+  int i = 42;\n+  bar (&i, &i);\n+  baz (&i, &i); /* { dg-warning \"passing argument 1 to restrict-qualified parameter aliases\" } */\n+}\ndiff --git gcc/testsuite/gcc.dg/remove-quals-2.c gcc/testsuite/gcc.dg/remove-quals-2.c\nindex e69de29bb2d..2d13bf2b34e 100644\n--- gcc/testsuite/gcc.dg/remove-quals-2.c\n+++ gcc/testsuite/gcc.dg/remove-quals-2.c\n@@ -0,0 +1,12 @@\n+/* PR c/65455 */\n+/* { dg-do compile } */\n+/* { dg-options \"-Wc++-compat\" } */\n+\n+void\n+fn (void)\n+{\n+  signed __remove_qualifiers (const int) s; /* { dg-error \"two or more data types in declaration specifiers\" } */\n+\n+  __typeof (struct S { int i; }) q; /* { dg-warning \"defining type in .typeof. expression is invalid\" } */\n+  __remove_qualifiers (struct S2 { int i; }) q2; /* { dg-warning \"defining type in .__remove_qualifiers. expression is invalid\" } */\n+}\ndiff --git gcc/testsuite/gcc.dg/remove-quals-3.c gcc/testsuite/gcc.dg/remove-quals-3.c\nindex e69de29bb2d..8e88031003d 100644\n--- gcc/testsuite/gcc.dg/remove-quals-3.c\n+++ gcc/testsuite/gcc.dg/remove-quals-3.c\n@@ -0,0 +1,13 @@\n+/* PR c/65455 */\n+/* { dg-do compile } */\n+/* { dg-options \"\" } */\n+\n+void\n+fn (void)\n+{\n+  _Atomic int a;\n+  __remove_qualifiers (_Atomic int) a; /* { dg-error \"conflicting type qualifiers\" } */\n+\n+  _Atomic int b;\n+  __remove_qualifiers (__typeof (b)) b; /* { dg-error \"conflicting type qualifiers\" } */\n+}\n\n\tMarek","headers":{"Return-Path":"<gcc-patches-return-461280-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461280-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"vom3TyXK\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=polacek@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkJsk0YZfz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 22:47:04 +1000 (AEST)","(qmail 82156 invoked by alias); 1 Sep 2017 12:46:54 -0000","(qmail 82047 invoked by uid 89); 1 Sep 2017 12:46:51 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 01 Sep 2017 12:46:44 +0000","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.11])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 7315D404338;\n\tFri,  1 Sep 2017 12:46:43 +0000 (UTC)","from redhat.com (ovpn-204-79.brq.redhat.com [10.40.204.79])\tby\n\tsmtp.corp.redhat.com (Postfix) with ESMTPS id B43CA93437;\n\tFri,  1 Sep 2017 12:46:41 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=FNcdMOH+HetI2sz6Z\n\tAjRw5EexJl1xQ8wwLRd1uwwXD3IytmDXHwHgM0sDhUw9KWoFOK+08OW4Ouy36kMe\n\tvX5OkK182m0Vdz9p00RgGyVky4YATkiWICnbtJ6eLsn/PlDCJWHr2aX6UXFxrvux\n\tgVHsKR87Z2regWnF3d1FbeIVbY=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=gFsax1OSVGbNYWq3eikxrHX\n\tVVyw=; b=vom3TyXKA3/vlgcxel6NHjw9A5dwDAHyMw38wUNLJz1GyGB+Nwhk8C+\n\t6pNlPDLZYJszZkraEOUSvzsc2kUBol42aX3s9FEWRpsEv8aBRq3ifjSSl7klkg3S\n\toZzzCGbCrbUbYWNAUw1zfiUCDJp/BJtZrKJ1ioZTGtvdYWGydr+Q=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 7315D404338","Date":"Fri, 1 Sep 2017 14:46:38 +0200","From":"Marek Polacek <polacek@redhat.com>","To":"Joseph Myers <joseph@codesourcery.com>","Cc":"GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>","Subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","Message-ID":"<20170901124638.GT17069@redhat.com>","References":"<20170831152515.GR17069@redhat.com>\n\t<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1765796,"web_url":"http://patchwork.ozlabs.org/comment/1765796/","msgid":"<CADzB+2mQ1xKgrxuVkEUtrYoq5aSiqP7z1-jkTk7BBE7yCmxrPg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-09T13:55:04","subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On Fri, Sep 1, 2017 at 2:46 PM, Marek Polacek <polacek@redhat.com> wrote:\n> @@ -16960,6 +16961,24 @@ cp_parser_simple_type_specifier (cp_parser* parser,\n>\n>        return type;\n>\n> +    case RID_REMOVE_QUALS:\n> +      /* Consume the `__remove_qualifiers' token.  */\n> +      cp_lexer_consume_token (parser->lexer);\n> +      /* Parse the operand to __remove_qualifiers`'.  */\n> +      type = cp_parser_sizeof_operand (parser, RID_REMOVE_QUALS);\n\nWouldn't it be simpler to use cp_parser_type_id?\n\n> +      if (!TYPE_P (type))\n> +       {\n> +         error_at (token->location,\n> +                   \"%<__remove_qualifiers%> can only be applied to a type\");\n> +         type = error_mark_node;\n> +       }\n\n...rather than check this.\n\nIt doesn't look like you handle use of __remove_qualifiers in a\ntemplate, and you don't have any testcases for it.\n\n> +@code{__remove_qualifiers} takes a typename as an argument:\n\nI think it would be better to use the term \"type-id\" here, to avoid\nconfusion with \"type-name\", which is only a single identifier.\n\nJason","headers":{"Return-Path":"<gcc-patches-return-461778-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461778-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"wwUXy9do\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xqG170hvDz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 23:55:37 +1000 (AEST)","(qmail 108641 invoked by alias); 9 Sep 2017 13:55:27 -0000","(qmail 108391 invoked by uid 89); 9 Sep 2017 13:55:27 -0000","from mail-it0-f45.google.com (HELO mail-it0-f45.google.com)\n\t(209.85.214.45) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tSat, 09 Sep 2017 13:55:26 +0000","by mail-it0-f45.google.com with SMTP id g142so6283303ita.0 for\n\t<gcc-patches@gcc.gnu.org>; Sat, 09 Sep 2017 06:55:26 -0700 (PDT)","by 10.107.181.23 with HTTP; Sat, 9 Sep 2017 06:55:04 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:cc:content-type; q=dns; s=default; b=dmVm3aivI+ySr0z\n\tg6Eq0QP1qft4gtKtfNQoVgr2EGmuJydYZphe/xJqqlwXvuJ9u7AHUOYUAB+lg5jE\n\tlhBlc1Za4X/K2Cf2calNlFeOapXQGukgSTFxZVswsXdlhjBRLhqOB5UBV5Dz4r7h\n\teG6PA/xih8kO1+SnN5dUUHUCeUpI=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:cc:content-type; s=default; bh=AeBC27nUXRIfjI+qQ2sSD\n\tjIlncg=; b=wwUXy9do0hKGR07e7bGZB7+y+7QrWWTwcs3DL2NyFLUcn8zzj6LzN\n\tqhRlK7/gmHGqEiollcgK9FZdRplahxj4muhf2TDlIJ6GvaOzn9mg3VuylKSKVxWU\n\tJlwLhCT8AIS+sN0hNc22mqtwTMS1gh4tDvKutnvhd74JTgTvH1qUD8=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-1.4 required=5.0 tests=AWL, BAYES_00,\n\tKAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=","X-HELO":"mail-it0-f45.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=AlKIjg4ZYqnHn4pzGpC/2k0soGYcO8ag99CTl+xCh28=;\n\tb=d0EcSlqyaBXbUgifI3r5g8oHa8BfbnO5I8xOOPHGRgnvQGVvMsiVLO7RMXBurNOgLP\n\td1dom5XhGX4dnyCxl3fsd5+5PGzwrtoELnzqMavvH3qKt9X67rXh2dAuhr+ArJ2SOv56\n\tpULIoU1W8D6DQhX6fJStEqptCPYAhvNCPPB1Wd8MEfwrm+T1/KiA7lxTjVshS3BW3HGW\n\tyGPxy4JmBdtn2hRxDBMcDH8XNdyf6UCHXME+nkbBoCY4ydlbfvGix3ejzI3qVVRyvqPu\n\t3xn7U28mlf65S7y7XhK86/YADVKSrl212B+MJ26glgG5ryJ8LuVTOCGlF8wb+wtZG5VY\n\tnHIg==","X-Gm-Message-State":"AHPjjUiE1b2ytF1NG2UsREX/BGX/FsgHALuonI8qF/e3CBCgE1ln16/q\trQNRLVuYCen3ZyXSLQwigm6A21nSOrst","X-Google-Smtp-Source":"AOwi7QCWwQ4XAoXUB+pNk+xd1n0C/KB+XmwR469CexEv0VZobxvJVRYEXu2D4sG80k4fCPMy53dMqUy8+AjoFYeYDc0=","X-Received":"by 10.36.200.132 with SMTP id w126mr5521536itf.101.1504965324462;\n\tSat, 09 Sep 2017 06:55:24 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170901124638.GT17069@redhat.com>","References":"<20170831152515.GR17069@redhat.com>\n\t<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>\n\t<20170901124638.GT17069@redhat.com>","From":"Jason Merrill <jason@redhat.com>","Date":"Sat, 9 Sep 2017 15:55:04 +0200","Message-ID":"<CADzB+2mQ1xKgrxuVkEUtrYoq5aSiqP7z1-jkTk7BBE7yCmxrPg@mail.gmail.com>","Subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","To":"Marek Polacek <polacek@redhat.com>","Cc":"Joseph Myers <joseph@codesourcery.com>,\n\tGCC Patches <gcc-patches@gcc.gnu.org>","Content-Type":"text/plain; charset=\"UTF-8\"","X-IsSubscribed":"yes"}},{"id":1768014,"web_url":"http://patchwork.ozlabs.org/comment/1768014/","msgid":"<alpine.DEB.2.20.1709131634510.29579@digraph.polyomino.org.uk>","list_archive_url":null,"date":"2017-09-13T16:36:30","subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","submitter":{"id":4349,"url":"http://patchwork.ozlabs.org/api/people/4349/","name":"Joseph Myers","email":"joseph@codesourcery.com"},"content":"On Sat, 9 Sep 2017, Jason Merrill wrote:\n\n> > +@code{__remove_qualifiers} takes a typename as an argument:\n> \n> I think it would be better to use the term \"type-id\" here, to avoid\n> confusion with \"type-name\", which is only a single identifier.\n\nThere's no such thing as a type-id in C, and type-name is the term used in \nC syntax (for what goes in a cast, etc.).","headers":{"Return-Path":"<gcc-patches-return-462055-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462055-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"FZ92tofI\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xsnPg1FrNz9s7B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 02:37:10 +1000 (AEST)","(qmail 123358 invoked by alias); 13 Sep 2017 16:37:01 -0000","(qmail 123348 invoked by uid 89); 13 Sep 2017 16:37:01 -0000","from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131)\n\tby sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with\n\tESMTP; Wed, 13 Sep 2017 16:37:00 +0000","from nat-ies.mentorg.com ([192.94.31.2]\n\thelo=svr-ies-mbx-01.mgc.mentorg.com)\tby relay1.mentorg.com\n\twith esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256)\tid\n\t1dsAeo-0006O3-9O from joseph_myers@mentor.com ;\n\tWed, 13 Sep 2017 09:36:58 -0700","from digraph.polyomino.org.uk (137.202.0.87) by\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft\n\tSMTP Server (TLS) id 15.0.1263.5; Wed, 13 Sep 2017 17:36:35 +0100","from jsm28 (helo=localhost)\tby digraph.polyomino.org.uk with\n\tlocal-esmtp (Exim 4.86_2)\t(envelope-from\n\t<joseph@codesourcery.com>)\tid 1dsAeM-0001EF-UY;\n\tWed, 13 Sep 2017 16:36:31 +0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:in-reply-to:message-id:references\n\t:mime-version:content-type; q=dns; s=default; b=jV7rwVXMlcsUaRMz\n\tcEYmksKhe2esQbSE01Ewr+O03eqPGw9rDtk+vtBELNyH6IVn6Tv/OMULZABxjAUa\n\tzmVY+ngSODvjP4moXnr7VBwT2TVUxL39t5DxnIgTPnnLUTeW3MGcV7cVD1RSQZOn\n\tyy1x30Ygk1zE7XdrAkGzi6U4yUU=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:in-reply-to:message-id:references\n\t:mime-version:content-type; s=default; bh=TnBKK3oSYJ5pBmcw6XiGcY\n\tzObG0=; b=FZ92tofIzHs2pR6B//a+uJ0M1ZeBEIpM+KG2L3X/8sL3YSAf18mQ4n\n\twSl179ZICOuJSBoXxMduLzgRPyPiOcRtMY/6p/gqNeGvzX6fAFqb6AMSQJUOSVAE\n\tUmuIGdHpLA3F5PbqWkoAQhADLvQi9Lu4ID3R+uPehjjO9zS9sjaKc=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-2.0 required=5.0 tests=AWL, BAYES_00,\n\tRCVD_IN_DNSWL_NONE, SPF_PASS,\n\tURIBL_RED autolearn=ham version=3.3.2 spammy=","X-HELO":"relay1.mentorg.com","Date":"Wed, 13 Sep 2017 16:36:30 +0000","From":"Joseph Myers <joseph@codesourcery.com>","To":"Jason Merrill <jason@redhat.com>","CC":"Marek Polacek <polacek@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>","Subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","In-Reply-To":"<CADzB+2mQ1xKgrxuVkEUtrYoq5aSiqP7z1-jkTk7BBE7yCmxrPg@mail.gmail.com>","Message-ID":"<alpine.DEB.2.20.1709131634510.29579@digraph.polyomino.org.uk>","References":"<20170831152515.GR17069@redhat.com>\n\t<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>\n\t<20170901124638.GT17069@redhat.com>\n\t<CADzB+2mQ1xKgrxuVkEUtrYoq5aSiqP7z1-jkTk7BBE7yCmxrPg@mail.gmail.com>","User-Agent":"Alpine 2.20 (DEB 67 2015-01-07)","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"US-ASCII\"","X-ClientProxiedBy":"svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1)"}},{"id":1768021,"web_url":"http://patchwork.ozlabs.org/comment/1768021/","msgid":"<alpine.DEB.2.20.1709131651040.29579@digraph.polyomino.org.uk>","list_archive_url":null,"date":"2017-09-13T16:54:54","subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","submitter":{"id":4349,"url":"http://patchwork.ozlabs.org/api/people/4349/","name":"Joseph Myers","email":"joseph@codesourcery.com"},"content":"This patch (for C) is setting c_inhibit_evaluation_warnings and \nin_remove_qualifiers and doing corresponding use of pop_maybe_used, but I \ndon't see the need for that.  Expressions within the argument to \n__remove_qualifiers are evaluated exactly if they would be evaluated in \nthe containing context; it's not like sizeof or typeof (expression) which \ncan cause expressions not to be evaluated.  (I don't actually think any of \nthat handling is needed for typeof (type) either, it simply happens that \nthe initial adjustments of c_inhibit_evaluation_warnings and in_typeof are \ndone in code shared by typeof (expression) and typeof (type).)","headers":{"Return-Path":"<gcc-patches-return-462058-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462058-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"pif2aVjH\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xsnpc6q2Lz9s7B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 02:55:20 +1000 (AEST)","(qmail 28038 invoked by alias); 13 Sep 2017 16:55:12 -0000","(qmail 27986 invoked by uid 89); 13 Sep 2017 16:55:06 -0000","from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131)\n\tby sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with\n\tESMTP; Wed, 13 Sep 2017 16:55:05 +0000","from nat-ies.mentorg.com ([192.94.31.2]\n\thelo=svr-ies-mbx-01.mgc.mentorg.com)\tby relay1.mentorg.com\n\twith esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256)\tid\n\t1dsAwI-0003Cc-KN from joseph_myers@mentor.com ;\n\tWed, 13 Sep 2017 09:55:02 -0700","from digraph.polyomino.org.uk (137.202.0.87) by\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft\n\tSMTP Server (TLS) id 15.0.1263.5; Wed, 13 Sep 2017 17:54:59 +0100","from jsm28 (helo=localhost)\tby digraph.polyomino.org.uk with\n\tlocal-esmtp (Exim 4.86_2)\t(envelope-from\n\t<joseph@codesourcery.com>)\tid 1dsAwA-0002SN-PP;\n\tWed, 13 Sep 2017 16:54:54 +0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:in-reply-to:message-id:references\n\t:mime-version:content-type; q=dns; s=default; b=FLIEOjn08oXt3amu\n\tw1hKuICl3dk94w9p8pvmiUfbX/I+4Vx01EEoedc8mbYyIBz2JxbCuDsZbZtUfm8I\n\tzrBdZtlnJl9J2at2wmumqZhz5qX5TC2G0owGCVw3P/jNH2aFR3vV/t0TogIItNfN\n\t2lohWCHCcKDjgBL7+wctQdh32dM=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:in-reply-to:message-id:references\n\t:mime-version:content-type; s=default; bh=FzxYSI2mQUvlqbUlnrYZHR\n\tgY3V0=; b=pif2aVjH4zpUIyz8u0SWzqsJA7Qhd3LQGqo6BdSpZDueC0oGH7fInO\n\tmsa0wCmCfuq4+JDH/YrylW+vMGxEaL90Lwv0fryUrz8kCLYzpr7unnvqHYugY1L/\n\tqdLga3BWRCueKgXcv8UDMnN5jtXP+C5IK8/3HItymjmeyqM3JhHV4=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-2.0 required=5.0 tests=AWL, BAYES_00,\n\tRCVD_IN_DNSWL_NONE, SPF_PASS,\n\tURIBL_RED autolearn=ham version=3.3.2 spammy=","X-HELO":"relay1.mentorg.com","Date":"Wed, 13 Sep 2017 16:54:54 +0000","From":"Joseph Myers <joseph@codesourcery.com>","To":"Marek Polacek <polacek@redhat.com>","CC":"GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>","Subject":"Re: C/C++ PATCH to add __remove_qualifiers (PR c/65455, c/39985)","In-Reply-To":"<20170901124638.GT17069@redhat.com>","Message-ID":"<alpine.DEB.2.20.1709131651040.29579@digraph.polyomino.org.uk>","References":"<20170831152515.GR17069@redhat.com>\n\t<alpine.DEB.2.20.1708311637240.24662@digraph.polyomino.org.uk>\n\t<20170901124638.GT17069@redhat.com>","User-Agent":"Alpine 2.20 (DEB 67 2015-01-07)","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"US-ASCII\"","X-ClientProxiedBy":"svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1)"}}]