[LLVMbugs] [Bug 8651] New: Terrible diagnostics if namespace omitted on constructor parameter

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 19 02:02:38 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8651

           Summary: Terrible diagnostics if namespace omitted on
                    constructor parameter
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


I was writing this class:

class RenameMethodConsumer : public clang::ASTConsumer {
  clang::Rewriter rewriter_;
  clang::ASTContext* context_;
 public:
  RenameMethodConsumer(ASTContext* context) : context_(context) {}
};

I should've written `clang::ASTContext` in the constructor, but failed to do
so. Here's clang's error:


macintosh-3:clangtut nico$ CXX=/Users/nico/src/llvm-2.8/Release/bin/clang++ 
make tut_rewrite
/Users/nico/src/llvm-2.8/Release/bin/clang++
-I/Users/nico/src/llvm-2.8/tools/clang/include -fno-rtti
`/Users/nico/src/llvm-2.8/Release/bin/llvm-config --cxxflags`   -c -o
tut_rewrite.o tut_rewrite.cpp
tut_rewrite.cpp:38:34: error: expected ')'
  RenameMethodConsumer(ASTContext* context) : context_(context) {}
                                 ^
tut_rewrite.cpp:38:23: note: to match this '('
  RenameMethodConsumer(ASTContext* context) : context_(context) {}
                      ^
tut_rewrite.cpp:38:47: error: invalid use of nonstatic data member 'context_'
  RenameMethodConsumer(ASTContext* context) : context_(context) {}
                                              ^~~~~~~~
tut_rewrite.cpp:38:24: error: field has incomplete type 'RenameMethodConsumer'
  RenameMethodConsumer(ASTContext* context) : context_(context) {}
                       ^
tut_rewrite.cpp:34:7: note: definition of 'RenameMethodConsumer' is not
complete until the closing '}'
class RenameMethodConsumer : public clang::ASTConsumer {
      ^
tut_rewrite.cpp:38:67: error: expected ';' at end of declaration list
  RenameMethodConsumer(ASTContext* context) : context_(context) {}
                                                                  ^
                                                                  ;
4 errors generated.
make: *** [tut_rewrite.o] Error 1


Here's what gcc does:

g++ -I/Users/nico/src/llvm-2.8/tools/clang/include -fno-rtti
`/Users/nico/src/llvm-2.8/Release/bin/llvm-config --cxxflags`   -c -o
tut_rewrite.o tut_rewrite.cpp
tut_rewrite.cpp:38: error: expected `)' before ‘*’ token
tut_rewrite.cpp: In function ‘int main(int, char**)’:
tut_rewrite.cpp:106: error: no matching function for call to
‘RenameMethodConsumer::RenameMethodConsumer(clang::ASTContext*)’
tut_rewrite.cpp:34: note: candidates are:
RenameMethodConsumer::RenameMethodConsumer()
tut_rewrite.cpp:34: note:                
RenameMethodConsumer::RenameMethodConsumer(const RenameMethodConsumer&)
make: *** [tut_rewrite.o] Error 1

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list