llvm / llvm-project

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

clang error points to the wrong place entirely #8245

Open llvmbot opened 14 years ago

llvmbot commented 14 years ago
Bugzilla Link 7873
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic

Extended Description

This testcase has a typo where : was used in place of ;.

class Foo {
  virtual ~Foo():
  virtual void ListWidgets();
};

The clang error is Just Wrong:


nlewycky@ducttape:~$ clang++ test.cc -fsyntax-only
test.cc:3:29: error: expected '{'
  virtual void ListWidgets();
                            ^
1 error generated.
``
No. That's not where the error is. It was on the previous line.
llvmbot commented 13 years ago

Same error happens with normal member functions too (and probably with non-member ones since it seems it all depends on the parsing of the : making the code think what follows is very likely a function definition and thus issuing the confusing error).

lattner commented 14 years ago

You can't have an initializer list after a destructor tho :)

efriedma-quic commented 14 years ago

clang isn't going insane here :) Because of the colon, clang assumes there's an initializer list, which it delays parsing, so clang isn't actually aware something is wrong until it doesn't find the {. (As it happens, attaching an initializer list to a destructor isn't legal, and the syntax of the skipped tokens doesn't match that of an initializer list, but clang doesn't check for those issues until later.)