GNU bug report logs - #72263
31.0.50; Wrong indentation c++-ts-mode

Previous Next

Package: emacs;

Reported by: Ergus <spacibba <at> aol.com>

Date: Wed, 24 Jul 2024 00:03:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ergus <spacibba <at> aol.com>
To: Yuan Fu <casouri <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 72263 <at> debbugs.gnu.org
Subject: bug#72263: 31.0.50; Wrong indentation c++-ts-mode
Date: Wed, 31 Jul 2024 23:09:53 +0200
[Message part 1 (text/plain, inline)]
Hi again Yuan:

I found another indentation issue in if-else conditions without
parenthesis:

if (pid == 0)
   print "hello from the child"
   else
   print "hello from the parent"


The else is not indented properly:

This is the explore output:

(translation_unit
 (if_statement if
  condition: 
   (parenthesized_expression (
    (binary_expression left: (identifier) operator: == right: (number_literal))
    ))
  consequence: 
   (expression_statement
    (concatenated_string (identifier)
     (string_literal " (string_content) ")
     (identifier) (identifier)
     (string_literal " (string_content) "))
    ;)))


Best,
Ergus


On July 25, 2024 9:53:16 AM GMT+02:00, Yuan Fu <casouri <at> gmail.com> wrote:
>
>
>> On Jul 25, 2024, at 12:29 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> 
>>> Date: Wed, 24 Jul 2024 02:02:33 +0200
>>> From:  Ergus via "Bug reports for GNU Emacs,
>>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>> 
>>> When using c++-ts-mode there is an indentation issue apparently related
>>> with namespaces+templates.
>>> 
>>> c-ts-mode-indent-style 'linux (but with 'gnu also happens)
>>> 
>>> ```
>>> namespace A {
>>> 
>>> T myfunction1(const char *fname)
>>> {
>>> }
>>> 
>>> template <class T>
>>> T myfunction2(const char *fname)
>>> {
>>> }
>>> 
>>> }
>>> ```
>>> 
>>> The myfunction2 may be indented as expected, but it is not.
>>> 
>>> The explorer shows:
>>> 
>>> ```
>>> (translation_unit
>>> (namespace_definition namespace name: (namespace_identifier)
>>>  body: 
>>>   (declaration_list {
>>>    (function_definition type: (primitive_type)
>>>     declarator: 
>>>      (function_declarator declarator: (identifier)
>>>       parameters: 
>>> (parameter_list (
>>> (parameter_declaration
>>>  (type_qualifier const)
>>>  type: (primitive_type)
>>>  declarator: (pointer_declarator * declarator: (identifier)))
>>> )))
>>>     body: (compound_statement { }))
>>>    (template_declaration template
>>>     parameters: 
>>>      (template_parameter_list <
>>>       (type_parameter_declaration class (type_identifier))
>>>> )
>>>     (function_definition type: (type_identifier)
>>>      declarator: 
>>>       (function_declarator declarator: (identifier)
>>> parameters: 
>>> (parameter_list (
>>>  (parameter_declaration
>>>   (type_qualifier const)
>>>   type: (primitive_type)
>>>   declarator: (pointer_declarator * declarator: (identifier)))
>>>  )))
>>>      body: (compound_statement { })))
>>>    })))
>>> ```
>> 
>> Yuan, can you take a look, please?
>
>Yeah let me take a look.
>
>Yuan
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
[Message part 2 (text/html, inline)]

This bug report was last modified 337 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.