[llvm-bugs] [Bug 40535] New: Error message for incorrectly specified constructor method is unhelpful

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 30 11:26:08 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40535

            Bug ID: 40535
           Summary: Error message for incorrectly specified constructor
                    method is unhelpful
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rgovostes at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

class Foo {
        Foo(int x);
    };

    Foo(int x) {
        // nothing
    }

Compiling this code gives the following error messages:

    foo.cpp:5:5: error: expected unqualified-id
    Foo(int x) {
        ^
    foo.cpp:5:5: error: expected ')'
    foo.cpp:5:4: note: to match this '('
    Foo(int x) {
       ^
    2 errors generated.

The actual problem is that I should have written:

    Foo::Foo(int x) {
        // nothing
    }

This mistake was easy because I moved the implementation of Foo::Foo from
inside the class, where it doesn't need to be qualified with the class name, to
outside the class, where it does.

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190130/3eabf9c0/attachment.html>


More information about the llvm-bugs mailing list