<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 16, 2015 at 6:33 PM, Nico Weber <span dir="ltr"><<a href="mailto:nicolasweber@gmx.de" target="_blank">nicolasweber@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: nico<br>
Date: Fri Jan 16 20:33:17 2015<br>
New Revision: 226365<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=226365&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=226365&view=rev</a><br>
Log:<br>
If a function decl cannot be merged, mark it as invalid.<br>
<br>
Clang currently crashes on<br>
<br>
class C {<br>
C() = default;<br>
C() = delete;<br>
};<br></blockquote><div><br></div><div>This is wrong. clang used to crash when these two lines were swapped. Anyhow, my cunning plan wasn't necessary: This change was enough to fix the crash. I added a test for this in r226370.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
My cunning plan for fixing this was to change the `if (!FnD)` in<br>
Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but<br>
alas, the second constructor decl wasn't marked as invalid. This lets<br>
Sema::MergeFunctionDecl() return true on function redeclarations, which leads<br>
to them being marked invalid.<br>
<br>
This also improves error messages when functions are redeclared.<br>
<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaDecl.cpp<br>
cfe/trunk/test/Parser/DelayedTemplateParsing.cpp<br>
cfe/trunk/test/Parser/cxx0x-ambig.cpp<br>
cfe/trunk/test/SemaCXX/class.cpp<br>
cfe/trunk/test/SemaCXX/cxx1y-constexpr-not-const.cpp<br>
cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp<br>
cfe/trunk/test/SemaCXX/overload-decl.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 16 20:33:17 2015<br>
@@ -2761,6 +2761,7 @@ bool Sema::MergeFunctionDecl(FunctionDec<br>
<< New << New->getType();<br>
}<br>
Diag(OldLocation, PrevDiag) << Old << Old->getType();<br>
+ return true;<br>
<br>
// Complain if this is an explicit declaration of a special<br>
// member that was initially declared implicitly.<br>
<br>
Modified: cfe/trunk/test/Parser/DelayedTemplateParsing.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/DelayedTemplateParsing.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/DelayedTemplateParsing.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Parser/DelayedTemplateParsing.cpp (original)<br>
+++ cfe/trunk/test/Parser/DelayedTemplateParsing.cpp Fri Jan 16 20:33:17 2015<br>
@@ -10,8 +10,8 @@ class A {<br>
<br>
template <class T><br>
class B {<br>
- void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}}<br>
- void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}}<br>
+ void foo4() { } // expected-note {{previous definition is here}}<br>
+ void foo4() { } // expected-error {{class member cannot be redeclared}}<br>
void foo5() { } // expected-note {{previous definition is here}}<br>
<br>
friend void foo3() {<br>
<br>
Modified: cfe/trunk/test/Parser/cxx0x-ambig.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-ambig.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-ambig.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Parser/cxx0x-ambig.cpp (original)<br>
+++ cfe/trunk/test/Parser/cxx0x-ambig.cpp Fri Jan 16 20:33:17 2015<br>
@@ -110,8 +110,8 @@ namespace ellipsis {<br>
template<typename...T><br>
struct S {<br>
void e(S::S());<br>
- void f(S(...args[sizeof(T)])); // expected-note {{here}}<br>
- void f(S(...args)[sizeof(T)]); // expected-error {{redeclared}} expected-note {{here}}<br>
+ void f(S(...args[sizeof(T)])); // expected-note {{here}} expected-note {{here}}<br>
+ void f(S(...args)[sizeof(T)]); // expected-error {{redeclared}}<br>
void f(S ...args[sizeof(T)]); // expected-error {{redeclared}}<br>
void g(S(...[sizeof(T)])); // expected-note {{here}} expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}}<br>
void g(S(...)[sizeof(T)]); // expected-error {{function cannot return array type}}<br>
<br>
Modified: cfe/trunk/test/SemaCXX/class.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/class.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/class.cpp Fri Jan 16 20:33:17 2015<br>
@@ -119,9 +119,9 @@ struct C4 {<br>
// PR5415 - don't hang!<br>
struct S<br>
{<br>
- void f(); // expected-note 1 {{previous declaration}}<br>
- void S::f() {} // expected-error {{extra qualification on member}} expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}<br>
- void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}}<br>
+ void f(); // expected-note 1 {{previous declaration}} expected-note {{previous declaration}}<br>
+ void S::f() {} // expected-error {{extra qualification on member}} expected-error {{class member cannot be redeclared}}<br>
+ void f() {} // expected-error {{class member cannot be redeclared}}<br>
};<br>
<br>
// Don't crash on this bogus code.<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx1y-constexpr-not-const.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-constexpr-not-const.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-constexpr-not-const.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/cxx1y-constexpr-not-const.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx1y-constexpr-not-const.cpp Fri Jan 16 20:33:17 2015<br>
@@ -11,8 +11,6 @@ struct X {<br>
<br>
// expected-error@6 {{class member cannot be redeclared}}<br>
// expected-note@5 {{previous}}<br>
-// expected-error@6 {{non-constexpr declaration of 'f' follows constexpr declaration}}<br>
-// expected-note@5 {{previous}}<br>
#else<br>
// expected-warning@5 {{'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior}}<br>
#endif<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp Fri Jan 16 20:33:17 2015<br>
@@ -21,8 +21,8 @@ int conv1c = conv1.operator auto();<br>
int conv1d = conv1.operator int(); // expected-error {{no member named 'operator int'}}<br>
<br>
struct Conv2 {<br>
- operator auto() { return 0; } // expected-note 2{{previous}}<br>
- operator auto() { return 0.; } // expected-error {{cannot be redeclared}} expected-error {{redefinition of 'operator auto'}}<br>
+ operator auto() { return 0; } // expected-note {{previous}}<br>
+ operator auto() { return 0.; } // expected-error {{cannot be redeclared}} expected-error {{cannot initialize return object of type 'auto' with an rvalue of type 'double'}}<br>
};<br>
<br>
struct Conv3 {<br>
<br>
Modified: cfe/trunk/test/SemaCXX/overload-decl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-decl.cpp?rev=226365&r1=226364&r2=226365&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-decl.cpp?rev=226365&r1=226364&r2=226365&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/overload-decl.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/overload-decl.cpp Fri Jan 16 20:33:17 2015<br>
@@ -30,10 +30,8 @@ class X {<br>
static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}<br>
static void g(float); // expected-error {{class member cannot be redeclared}}<br>
<br>
- void h(); // expected-note {{previous declaration is here}} \<br>
- expected-note {{previous declaration is here}}<br>
- void h() __restrict; // expected-error {{class member cannot be redeclared}} \<br>
- expected-error {{conflicting types for 'h'}}<br>
+ void h(); // expected-note {{previous declaration is here}}<br>
+ void h() __restrict; // expected-error {{class member cannot be redeclared}}<br>
};<br>
<br>
int main() {} // expected-note {{previous definition is here}}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>