www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22073] New: importC: Error: found '.' when expecting ';'

https://issues.dlang.org/show_bug.cgi?id=22073

          Issue ID: 22073
           Summary: importC: Error: found '.' when expecting ';' following
                    compound literal
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

Compound literals are a postfix-expression, and so can be followed by any other
postfix-expression in the statement, as per C11 6.5.2
---
postfix-expression:
   primary-expression
   postfix-expression [ expression ]
   postfix-expression ( argument-expression-list (opt) )
   postfix-expression . identifier
   postfix-expression -> identifier
   postfix-expression ++
   postfix-expression --
   ( type-name ) { initializer-list }
   ( type-name ) { initializer-list , }
---

Reduced test:
---
struct S { int field; };

void test()
{
  (struct S) { 42 }.field = 24;      // valid lvalue, see issue 22072.
  int var = (struct S) { 42 }.field;
}

--
Jun 22