[llvm-bugs] [Bug 43494] New: Improve diagnostics for trying to invoke a destructor on a qualified namespace
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Sep 28 11:13:07 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43494
Bug ID: 43494
Summary: Improve diagnostics for trying to invoke a destructor
on a qualified namespace
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: arcata 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
If you try to invoke the destructor on a `std::string`, and you don't already
know the answer for what you're supposed to write, then the diagnostics are not
helpful at best, and misleading at worst:
% cat ~/foo.cpp
#include <string>
void destroyString(std::string &&s) {
s.~string();
}
% xcrun clang++ ~/foo.cpp
/Users/jgroff/foo.cpp:3:6: error: identifier 'string' in object destruction
expression does not name
a type
s.~string();
^
% cat ~/foo1.cpp
#include <string>
void destroyString(std::string &&s) {
s.~std::string();
}
% clang++ ~/foo1.cpp
/Users/jgroff/foo1.cpp:3:5: error: '~' in destructor name should be after
nested name specifier
s.~std::string();
^
~
/Users/jgroff/foo.cpp:3:5: error: qualified member access refers to a member in
namespace 'std'
s.~std::string();
^~~~~~
% cat ~/foo2.cpp
#include <string>
void destroyString(std::string &&s) {
s.std::~string();
}
% clang++ ~/foo2.cpp
/Users/jgroff/foo2.cpp:3:10: error: qualified member access refers to a member
in namespace 'std'
s.std::~string();
~~~~~^
% cat ~/foo3.cpp
#include <string>
void destroyString(std::string &&s) {
s.std::string::~string();
}
% clang++ ~/foo3.cpp
/Users/jgroff/foo3.cpp:3:19: error: expected the class name after '~' to name a
destructor
s.std::string::~string();
^
Any of these diagnostics seem like they could offer a fixit directly to the
correct syntax for what the user is trying to write, `s.~basic_string()`.
--
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/20190928/f78ca1d2/attachment.html>
More information about the llvm-bugs
mailing list