Issue |
120409
|
Summary |
[clang] error: expected '(' or '{' cl dialect
|
Labels |
clang
|
Assignees |
|
Reporter |
mzyKi
|
```cpp
template<class T>
class Tuple
{
public:
Tuple(const T* pTup) : m_tup[0](pTup[0]), m_tup[1](pTup[1]), m_tup[2](pTup[2]) {}
protected:
T m_tup[3];
};
```
I use clang.exe to compile the above code it will tell me ```error: expected '(' or '{'```
But it will have no error in cl.exe.
Should we need to support this?
I am not very familiar with clang parser.
My thought about this is I can change some logic in clang parser and add one AST Node like ```MSArrayInitListExpr``` to fix this error.
At the same time, I found the following code,
```cpp
template<class T>
class Tuple
{
public:
Tuple(const T* pTup) : m_tup{pTup[0], pTup[1], pTup[2]} {}
protected:
T m_tup[3];
};
```
Its ast is
```bash
`-ClassTemplateDecl 0x20423924f00 <test.cpp:1:1, line:9:1> line:2:7 Tuple
|-TemplateTypeParmDecl 0x20423924da0 <line:1:10, col:16> col:16 referenced class depth 0 index 0 T
`-CXXRecordDecl 0x20423924e70 <line:2:1, line:9:1> line:2:7 class Tuple definition
|-DefinitionData standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
| |-DefaultConstructor
| |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
|-CXXRecordDecl 0x20423925198 <col:1, col:7> col:7 implicit referenced class Tuple
|-AccessSpecDecl 0x20423925228 <line:4:1, col:7> col:1 public
|-CXXConstructorDecl 0x20423925430 <line:5:5, col:24> col:5 Tuple<T> 'void (const T *)' implicit-inline
| |-ParmVarDecl 0x204239252d0 <col:11, col:20> col:20 pTup 'const T *'
| `-<<<NULL>>>
|-AccessSpecDecl 0x204239254e8 <line:7:1, col:10> col:1 protected
`-FieldDecl 0x20423925600 <line:8:5, col:14> col:7 m_tup 'T[3]'
```
Maybe I can simplify this problem by giving ```<<<NULL>>>```.
I would be very grateful if someone knowledgeable in this area could offer me some advice.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs