[PATCH] If a function decl cannot be merged, mark it as invalid, phab edition.

Nico Weber thakis at chromium.org
Fri Jan 16 13:57:03 PST 2015


Hi rsmith,

Clang currently crashes on

    class C {
      C() = default;
      C() = delete;
    };

My cunning plan for fixing this was to change the `if (!FnD)` in Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but alas, the second constructor decl wasn't marked as invalid. This patch lets Sema::MergeFunctionDecl() return true on function redeclarations, which leads to them being marked invalid. (There are two more diag::err_s later in the same function that also don't return true. These look fishy to me too – let me know if you think those should be changed too. Probably in a separate patch, though.)

This reduces the number of duplicate error messages in tests, which is probably a good thing for this kind of error – if you have two definitions of a function, things likely are pretty dire already.

http://reviews.llvm.org/D7021

Files:
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/Parser/DelayedTemplateParsing.cpp
  test/Parser/cxx0x-ambig.cpp
  test/SemaCXX/class.cpp
  test/SemaCXX/cxx1y-constexpr-not-const.cpp
  test/SemaCXX/cxx1y-deduced-return-type.cpp
  test/SemaCXX/overload-decl.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7021.18313.patch
Type: text/x-patch
Size: 5720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150116/662d1200/attachment.bin>


More information about the cfe-commits mailing list