llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.93k stars 11.53k forks source link

Clang misinterprets initialization #19184

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 18810
Version 3.4
OS Linux
Attachments Testcase
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

The attached test case can't be compiled by clang but passes without any hassles in g++ and the Oracle/Sunstudio C++ compiler.

The primary error message is:

foo.C:37:34: error: parameter declarator cannot be qualified
  QCursor waitCursor(QCursor(Qt::WaitCursor));

The attached test case is a common Qt usage in our tools. I have removed everything and only left the needed declarations.

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 10 years ago

Clang is correct here.

Your declaration disambiguates as a function declaration, not as a variable declaration. The disambiguation process doesn't take into account whether function parameter declarations are qualified or unqualified (because that is governed by semantic rules, not by the grammar).

That said, we should diagnose this better, especially since other implementations accept it. I'll also raise this with the C++ CWG and see if we can get a language change to accept this.