diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-11-30 22:51:18 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-11-30 22:51:18 +0000 |
commit | 8ba109cecce1cf6598380908a1d6b00e0360b85d (patch) | |
tree | ad4f9748a8f41861298cd65458deb892776a9643 /gcc/builtins.c | |
parent | 553a316b99c4af9d59e9594204298633b12f6618 (diff) | |
download | gcc-8ba109cecce1cf6598380908a1d6b00e0360b85d.zip gcc-8ba109cecce1cf6598380908a1d6b00e0360b85d.tar.gz gcc-8ba109cecce1cf6598380908a1d6b00e0360b85d.tar.bz2 |
C++: fix-it hint for missing parentheses
Consider:
class t1
{
public:
double length () const { return m_length; }
private:
double m_length;
};
missing-parens-fixit.C: In function 'bool test_1(const t1&)':
missing-parens-fixit.C:14:15: error: invalid use of member function
'double t1::length() const' (did you forget the '()' ?)
14 | return inst.length > 0.0;
| ~~~~~^~~~~~
This patch adds a fix-it hint for the case where the member function
takes no parameters, suggesting the addition of the parentheses:
14 | return inst.length > 0.0;
| ~~~~~^~~~~~
| ()
so that an IDE can potentially apply the fix.
gcc/cp/ChangeLog:
* typeck2.c: Include "gcc-rich-location.h".
(cxx_incomplete_type_diagnostic): When complaining about possibly
missing parens, add a fix-it hint if the member function takes no
additional params.
gcc/ChangeLog:
* diagnostic-core.h (emit_diagnostic): New decl.
* diagnostic.c (emit_diagnostic): New overload, taking a
rich_location *.
gcc/testsuite/ChangeLog:
* g++.dg/parse/missing-parens-fixit.C: New test.
From-SVN: r266696
Diffstat (limited to 'gcc/builtins.c')
0 files changed, 0 insertions, 0 deletions