From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 13 10:28:18 2023 Received: (at submit) by debbugs.gnu.org; 13 Feb 2023 15:28:18 +0000 Received: from localhost ([127.0.0.1]:51249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRakb-0007l9-O5 for submit@debbugs.gnu.org; Mon, 13 Feb 2023 10:28:18 -0500 Received: from lists.gnu.org ([209.51.188.17]:49066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRaka-0007kx-47 for submit@debbugs.gnu.org; Mon, 13 Feb 2023 10:28:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRakY-0000Z2-QJ for bug-gnu-emacs@gnu.org; Mon, 13 Feb 2023 10:28:14 -0500 Received: from sonic307-36.consmr.mail.ne1.yahoo.com ([66.163.190.59]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRakW-0005kI-0K for bug-gnu-emacs@gnu.org; Mon, 13 Feb 2023 10:28:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676302088; bh=VUy82ArUYtlf0DPNOqt2SkgWDk7BIb+IxvWwj1dI/gE=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=nPVcLZcnNLs6vRi/KFWM8W8JlvVI4rK3GYy4ZgHbHNbyjyIX4Wdi9i/9SnYw0QO7ED5hnwwXuli9yGnL0lCXethQ3lxKId5YPwGuFhFvlp65LM36EnwBOX5OnCDoGETh4S3DzUTnfEfHTI8mpHM/XW8FtG3TnMk4CpDgiTWS7E70TbC0UKiwa8pEotLFZIxhiinwZPQoDFjTzjSlna7HQnDwdoS8blO26HqCukwt8VAJ7bgV4/gOQuEOkgK9PvojSKBhJE0v4YnSbyGzONEcvdtF1XKzCNnwy3YOtkE4Vo4Y9PKgCkANy829abSplMpWmMO0n9q5BiC5Xz0SBZFKNA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676302088; bh=zwAwZAZ1gJqf1ath7NXhOCoXaubhI+MM7Bhht8so/ah=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=aySt7c9zJb0W80jpCPsLxNUdtwW1vIkGGHkhcg7p+hRWEJkrBreyOBDF/pEc79V12Vzh/B5uaMtIo9rqbJ16pzK+h9WPKV6cnpNxAj7p2mMpKa3y/HqR+OckwWIGQtGpLFkXPrKkXj8ockzGKaiptxnarMWwExOMjAvKatFkriBQ0TRsWAY04AVi4fSo2FQrQG/Vh8F9nhI0r6Y+c+/mBQl5Eg19+UyRN9JC5NXfPxyjUqyI4TwvOWgNUf34jpDctrdrt8R3px2e6pDefXHdjS5nPuISa27yNMk/Av5w8Z2Aa0TcloxHrvgUKaIwOHoIbD41/iGrs2Qm0fizlBXQXw== X-YMail-OSG: 7Ed3Q7QVM1kxDIMe8TMeURKlLSWFBlYVbPowt3McBYDAgTz7WoWCogNh.0qQacD XpaSC.r8zKwwZEy2dD5S9oSPuRbs6IoGnOLrr4SOOobfGSZJm1YsqUv37XuRQu_Le278x_gqmjjS qz.CXqxn.WUMPleerThck.I_GmA_RJLm3XpCbXj1rmBFDyRM0qHO3U7._345NRMvxMsxThYaG4wn vePT5YY.aSFPsVdVRfnkAQmPqdGvwfsOSDa2wPdFg6rw0YFSPqS5TkI04tCJs452gfIdxqz8jG6v .1LQan0ygbhMr6gWfphaP4yLyRcf4t3pege6rclBv1A1xD1.6sV8yiRkZjee7llFegq3x4mAt5Di cNBL2Ynw1p6xgnlcLwOAvqk3bA44vlJ8LlqCE5Y5_Kas.18ryGxLV_ZpsvM.mC8SgxoVHZmh200Q fqOCReu3fej4PXfMjteVfaF2h4EG4b4V4Y0G45yyzR07quasdDjORUziuof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5o42_bs PUTtPB1T9wtO5.hWQZQiot_8kb7OOnMLPD7g3_04Z8loW7yRQ66TQdEGRLWasPqydQuOYd.MrgKf RD7F85Nj2AYbTT6L4.eWYfRKy6HjueiuycdQd8M.eh0eVfAj_.6lUjRaRRM49m7dUPsOFGbjvwC. ZszXeozb2nRN6_37wgDp.SozbeNBHRoE893.A1lwivJHWV3mnA4luH9abX7qtJ.vjH8Trh0rfzn9 ctI_LzY_LHCUGcQL7ueTSOuAasx5XtDEws8UOlWOjzTFNaHNdDJqvliLDLVPG7qRPsu.2TCwVpCo j.Zpxz6yJ8I5TAX2cf5hiU0E.osqQCg_HSdRJNoRcI67Lcb5pEgfWYg1eW.Z8RAXi2i2I_I2GVQe h0XeGw9LPUZW99chJTq.tEdEKMENQwnzMRU.WWbwBhrFqJpc9P4YpyDymAbCyI.pllyEd_8xy4GH RGjATb1KnlIIxU10MoZwMVdfBHoc1mfbb3Yo9mKg7ahv19it7VvXx1ju5OGRCY8.hhnpnoVYK5Bd mAn5f8RmWEmfv2Y9FjA8Y9iRCsukfpI_7zC1gc5kPP_Qd0sFMMgMCOs0.QaVI1CYmuEA1yfbvK45 w84j.CRnOGZE2G.ep5V.ujlYP6r8BwPq.ubUIGYPcs46tczC8dO7kiovIxGEqzA_Is5H1xWWBXf9 mVXvbo2gMaKFX71arz.KYaljaUZgo2DbeTsr2ZzJmOOUXS_IB0fQ- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Mon, 13 Feb 2023 15:28:08 +0000 Received: by hermes--production-sg3-9fc5746c8-pz6sb (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8c1650cb9ae514c4bf1bd74b88b1c619; Mon, 13 Feb 2023 15:26:04 +0000 (UTC) From: Po Lu To: bug-gnu-emacs@gnu.org Subject: CC Mode 5.35.2 (C/*l); _Generic unsupported X-Debbugs-Package: cc-mode Date: Mon, 13 Feb 2023 23:25:43 +0800 Message-ID: <87zg9hvb7s.fsf@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable References: <87zg9hvb7s.fsf.ref@yahoo.com> X-Mailer: WebService/1.1.21183 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 5156 Received-SPF: pass client-ip=66.163.190.59; envelope-from=luangruo@yahoo.com; helo=sonic307-36.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Package: cc-mode 2011 Standard C has a feature that works like `switch', except on the type of an expression and with different syntax. Today, I had to figure out how to port some code written with that in mind to ANSI C, and surprisingly enough, found that CC Mode does not support that feature at all. Code making use of _Generic looks more or less like this: { const char *typename =3D _Generic ((expr), const char *: "const char *", int: "int", unsigned long: "unsigned long" default: NULL); } where `typename' is set to an appropriate value based on the type of the expression ``expr''. CC Mode already works remarkably well, but it should be taught to indent the cases separately from the values. Emacs : GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu) of 2022-12-24 Package: CC Mode 5.35.2 (C/*l) Buffer Style: gnu c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-st= ring-delim gen-comment-delim syntax-properties category-properties 1-bit) current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq c-basic-offset 2 c-comment-only-line-offset '(0 . 0) c-indent-comment-alist '((anchored-comment column . 0) (end-block space . = 1) (cpp-end-block space . 2)) c-indent-comments-syntactically-p nil c-block-comment-prefix "" c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (= other . "//+\\|\\**")) c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) (c-mode = . gtkdoc) (c++-mode . gtkdoc)) c-cleanup-list '(scope-operator) c-hanging-braces-alist '((substatement-open before after) (arglist-cont-no= nempty)) c-hanging-colons-alist nil c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist) c-backslash-column 48 c-backslash-max-column 72 c-special-indent-hook '(t c-gnu-impose-minimum) c-label-minimum-indentation 1 c-offsets-alist '((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . 0) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-= method-call +) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist) (arglist-cont c-lineup-gcc-asm-reg 0) (comment-intro c-lineup-knr-region-comment c-lineup-comment) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (access-label . -) (case-label . 0) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-close . 0) (block-close . 0) (block-open . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (func-decl-cont . +) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEF= UN-intro-cont) (brace-list-intro first c-lineup-2nd-brace-entry-in-arglist c-lineup-c= lass-decl-init-+ +) (brace-list-open . +) (inline-open . 0) (arglist-close . c-lineup-arglist) (arglist-intro . c-lineup-arglist-intro-after-paren) (statement-cont . +) (statement-case-open . +) (label . 0) (substatement-label . 0) (substatement-open . +) (knr-argdecl-intro . 5) (statement-block-intro . +) ) c-buffer-is-cc-mode 'c-mode c-tab-always-indent t c-syntactic-indentation t c-syntactic-indentation-in-macros t c-ignore-auto-fill '(string cpp code) c-auto-align-backslashes t c-backspace-function 'backward-delete-char-untabify c-delete-function 'delete-char c-electric-pound-behavior nil c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu")) c-enable-xemacs-performance-kludge-p nil c-old-style-variable-behavior nil defun-prompt-regexp nil tab-width 8 comment-column 32 parse-sexp-ignore-comments t parse-sexp-lookup-properties t auto-fill-function nil comment-multi-line t comment-start-skip "\\(?://+\\|/\\*+\\)\\s *" fill-prefix nil fill-column 70 paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*$\\|^\f" adaptive-fill-mode t adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*\\([-=E2=80=93!|#%= ;>*=C2=B7=E2=80=A2=E2=80=A3=E2=81=83=E2=97=A6]+[ ]*\\)*\\)" ) From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 16 08:15:46 2023 Received: (at 61481) by debbugs.gnu.org; 16 Feb 2023 13:15:47 +0000 Received: from localhost ([127.0.0.1]:35265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSe70-0003Ag-EQ for submit@debbugs.gnu.org; Thu, 16 Feb 2023 08:15:46 -0500 Received: from mx3.muc.de ([193.149.48.5]:27395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSe6x-0003AS-P3 for 61481@debbugs.gnu.org; Thu, 16 Feb 2023 08:15:46 -0500 Received: (qmail 48324 invoked by uid 3782); 16 Feb 2023 14:15:37 +0100 Received: from acm.muc.de (pd953a954.dip0.t-ipconnect.de [217.83.169.84]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 16 Feb 2023 14:15:36 +0100 Received: (qmail 18426 invoked by uid 1000); 16 Feb 2023 13:15:36 -0000 Date: Thu, 16 Feb 2023 13:15:36 +0000 To: Po Lu Subject: Re: bug#61481: CC Mode 5.35.2 (C/*l); _Generic unsupported Message-ID: References: <87zg9hvb7s.fsf.ref@yahoo.com> <87zg9hvb7s.fsf@yahoo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a9n8ZMd5FfbvR+ja" Content-Disposition: inline In-Reply-To: <87zg9hvb7s.fsf@yahoo.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61481 Cc: 61481@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --a9n8ZMd5FfbvR+ja Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, Po. On Mon, Feb 13, 2023 at 23:25:43 +0800, Po Lu via CC-Mode-help wrote: > Package: cc-mode > 2011 Standard C has a feature that works like `switch', except on the > type of an expression and with different syntax. Yuck! How on Earth did something like this get included in the standard? It's not used often (I wasn't aware of it until three days ago), it's wholly unlike anything else in C, and just takes up effort from compiler and editor maintainers. > Today, I had to figure out how to port some code written with that in > mind to ANSI C, and surprisingly enough, found that CC Mode does not > support that feature at all. :-) > Code making use of _Generic looks more or less like this: > { > const char *typename = _Generic ((expr), > const char *: > "const char *", > int: > "int", > unsigned long: > "unsigned long" > default: > NULL); > } > where `typename' is set to an appropriate value based on the type of the > expression ``expr''. > CC Mode already works remarkably well, but it should be taught to indent > the cases separately from the values. Thanks! I've made a first patch for this, which is fairly crude. It handles only the indentation, not the fontification, which will be more difficult. Would you please try out the attached patch, and let me know how well it does the job. Thanks! [ .... ] -- Alan Mackenzie (Nuremberg, Germany). --a9n8ZMd5FfbvR+ja Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="diff.20230216.diff" diff -r 97e4c3437e75 cc-engine.el --- a/cc-engine.el Sun Feb 05 17:48:26 2023 +0000 +++ b/cc-engine.el Thu Feb 16 13:13:59 2023 +0000 @@ -14927,7 +14927,31 @@ (c-add-syntax 'topmost-intro-cont (c-point 'boi))) )) - ;; (CASE 6 has been removed.) + ;; ((Old) CASE 6 has been removed.) + ;; CASE 6: line is within a C11 _Generic expression. + ((and c-generic-key + (eq (char-after containing-sexp) ?\() + (save-excursion + (and + (progn (goto-char containing-sexp) + (zerop (c-backward-token-2))) + (looking-at c-generic-key) + (progn (goto-char (1+ containing-sexp)) + (c-syntactic-re-search-forward + "," indent-point 'bound t t)) + (setq placeholder (point))))) + (let ((delim ?,)) + (goto-char placeholder) + (while + (and (c-syntactic-re-search-forward ":" indent-point 'bound t t) + (setq delim ?:) + (c-syntactic-re-search-forward + "," indent-point 'bound t t) + (setq delim ?,))) + (c-add-syntax (if (eq delim ?,) + 'case-label + 'statement-case-intro) + containing-sexp))) ;; CASE 7: line is an expression, not a statement. Most ;; likely we are either in a function prototype or a function diff -r 97e4c3437e75 cc-langs.el --- a/cc-langs.el Sun Feb 05 17:48:26 2023 +0000 +++ b/cc-langs.el Thu Feb 16 13:13:59 2023 +0000 @@ -3071,6 +3071,28 @@ t (c-make-keywords-re t (c-lang-const c-block-stmt-2-kwds))) (c-lang-defvar c-block-stmt-2-key (c-lang-const c-block-stmt-2-key)) +(c-lang-defconst c-generic-kwds + "The keyword \"_Generic\" which introduces a C11 generic statement." + t nil + c '("_Generic")) + +(c-lang-defconst c-generic-key + ;; Regexp matching the keyword(s) in `c-generic-kwds'. + t (if (c-lang-const c-generic-kwds) + (c-make-keywords-re t (c-lang-const c-generic-kwds)))) +(c-lang-defvar c-generic-key (c-lang-const c-generic-key)) + +(c-lang-defconst c-generic-default-kwds + "The keyword \"default\" used in a C11 generic statement." + t nil + c '("default")) + +(c-lang-defconst c-generic-default-key + ;; Regexp matching the keyword(s) in `c-generic-default-kwds'. + t (if (c-lang-const c-generic-default-kwds) + (c-make-keywords-re t (c-lang-const c-generic-default-kwds)))) +(c-lang-defvar c-generic-default-key (c-lang-const c-generic-default-key)) + (c-lang-defconst c-block-stmt-kwds ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'. t (c--delete-duplicates (append (c-lang-const c-block-stmt-1-kwds) --a9n8ZMd5FfbvR+ja-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 16 21:36:16 2023 Received: (at 61481) by debbugs.gnu.org; 17 Feb 2023 02:36:16 +0000 Received: from localhost ([127.0.0.1]:38121 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSqbg-0000Cm-Bd for submit@debbugs.gnu.org; Thu, 16 Feb 2023 21:36:16 -0500 Received: from sonic309-49.consmr.mail.ne1.yahoo.com ([66.163.184.175]:35804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSqbd-0000CV-JV for 61481@debbugs.gnu.org; Thu, 16 Feb 2023 21:36:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676601367; bh=nh8qk4Yk9YvFf87CEaA3IWD46CHigPZprkhVnl/AZzo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=K+G24r1amUlay+pRrwDOZhC8cMxnop+NejVkG9nOGzoA77srpV7H0Ire/TkLLR1rawrvZ70cfUhxv36A21dE6iUd5s2qqvBcdwB02o5sBCl4GRkySPgEmM6zy/UOpzHiHsrXaUBAC/8pEXG4DoxSYy8LG5zlqf1CwEoRmVEouLnhqLiWFqeyvTvj22MTg1To5ikrJaxzqIRLqIY1imt04x6M+g4ngLsz8regUjaKD4Lacu3LFs9pilreqpYAhwt8DbGeATbcQ3u7SIIVtYvfO8rP+Pd9+1YOhoQD3QqK0+sTFFQ5ybbTiax41iZX6WlXuYii+IK14DlD9QgheklHNQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676601367; bh=jWrvpRATsTqqlvaSuHkYzQjiCv/T1KLO5oSwehZsUrG=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=gtY9ptuwlHlbQkL1NFTrur7F1SyXhFOBmYAyKdvMynZb0Uhs0B60gTTbgXiVXzWnxm34KqI+Q084JRCXU8aS8uCRfPGh89AIECsKzdVC4iqh0JX2WUvz5U4bvSfRrynkzRGPgdQz088r1MV1GyhANIBE1XtWRtJVf3F51OmZdsHx/9n172dcPzE7dLqBdO3nXQklwbte0/Gbwa6x5K1nD7DAMxl8+7IJTWP+Y9sywA/XZljxwbfro3G5RyHTeDLkEVNWdxb5ZCkEtC8rLD90iW2NU7N/T2VPLmm2Qpn0fKfebYYXDXAViLHc6OpFGjlZiYtkca5F+fP4y9Xyx7OqFQ== X-YMail-OSG: Z_21138VM1k2sYTRd1kEsc5eWonjNFTjPef9x9xhR5HJuHp3j.prfEurZ_eFPFV YwABQHSSWyfoeYt0lvLde6fYkHVAbjvbEmhp4PBxCbk2IQPizRAtP9A1NVG1ki0QLfgMeHy43rF3 Ir8380DpOgszvOO4ISGFG59.CjYNA3O8pLfZOwWP.8tFgTGovDgrKsqMV.ZHLwj3UgtrQ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Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ne1.yahoo.com with HTTP; Fri, 17 Feb 2023 02:36:07 +0000 Received: by hermes--production-sg3-9fc5746c8-7wpmf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID dbe3fe80eb9cb9f3a28c2631dcbeef9e; Fri, 17 Feb 2023 02:34:04 +0000 (UTC) From: Po Lu To: Alan Mackenzie Subject: Re: bug#61481: CC Mode 5.35.2 (C/*l); _Generic unsupported In-Reply-To: (Alan Mackenzie's message of "Thu, 16 Feb 2023 13:15:36 +0000") References: <87zg9hvb7s.fsf.ref@yahoo.com> <87zg9hvb7s.fsf@yahoo.com> Date: Fri, 17 Feb 2023 10:33:45 +0800 Message-ID: <87cz69owae.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.21183 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 1642 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61481 Cc: 61481@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Alan Mackenzie writes: > Hello, Po. > > On Mon, Feb 13, 2023 at 23:25:43 +0800, Po Lu via CC-Mode-help wrote: >> Package: cc-mode > >> 2011 Standard C has a feature that works like `switch', except on the >> type of an expression and with different syntax. > > Yuck! How on Earth did something like this get included in the > standard? It's not used often (I wasn't aware of it until three days > ago), it's wholly unlike anything else in C, and just takes up effort > from compiler and editor maintainers. > >> Today, I had to figure out how to port some code written with that in >> mind to ANSI C, and surprisingly enough, found that CC Mode does not >> support that feature at all. > > :-) > >> Code making use of _Generic looks more or less like this: > >> { >> const char *typename = _Generic ((expr), >> const char *: >> "const char *", >> int: >> "int", >> unsigned long: >> "unsigned long" >> default: >> NULL); >> } > >> where `typename' is set to an appropriate value based on the type of the >> expression ``expr''. > >> CC Mode already works remarkably well, but it should be taught to indent >> the cases separately from the values. > > Thanks! > > I've made a first patch for this, which is fairly crude. It handles > only the indentation, not the fontification, which will be more > difficult. > > Would you please try out the attached patch, and let me know how well it > does the job. Thanks! > > [ .... ] Thanks, Alan. I finished working on that code by now, so I have nothing to test it on. If it works for you, please install, thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 17 04:29:00 2023 Received: (at 61481-done) by debbugs.gnu.org; 17 Feb 2023 09:29:00 +0000 Received: from localhost ([127.0.0.1]:38497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSx35-0008MM-Ty for submit@debbugs.gnu.org; Fri, 17 Feb 2023 04:29:00 -0500 Received: from mx3.muc.de ([193.149.48.5]:64105) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSx33-0008M8-JF for 61481-done@debbugs.gnu.org; Fri, 17 Feb 2023 04:28:58 -0500 Received: (qmail 47325 invoked by uid 3782); 17 Feb 2023 10:28:50 +0100 Received: from acm.muc.de (pd953aad7.dip0.t-ipconnect.de [217.83.170.215]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 17 Feb 2023 10:28:50 +0100 Received: (qmail 27123 invoked by uid 1000); 17 Feb 2023 09:28:49 -0000 Date: Fri, 17 Feb 2023 09:28:49 +0000 To: Po Lu Subject: Re: bug#61481: CC Mode 5.35.2 (C/*l); _Generic unsupported Message-ID: References: <87zg9hvb7s.fsf.ref@yahoo.com> <87zg9hvb7s.fsf@yahoo.com> <87cz69owae.fsf@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87cz69owae.fsf@yahoo.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61481-done Cc: 61481-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Po. On Fri, Feb 17, 2023 at 10:33:45 +0800, Po Lu wrote: > Alan Mackenzie writes: [ .... ] > > I've made a first patch for this, which is fairly crude. It handles > > only the indentation, not the fontification, which will be more > > difficult. > > Would you please try out the attached patch, and let me know how well it > > does the job. Thanks! > > [ .... ] > Thanks, Alan. > I finished working on that code by now, so I have nothing to test it on. > If it works for you, please install, thanks. OK. I've enhanced it a fair bit since yesterday, in particular, the types now get fontified as types. I've committed that patch, and I'm closing the bug with this post. -- Alan Mackenzie (Nuremberg, Germany). From unknown Tue Sep 23 05:03:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 17 Mar 2023 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator