summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/DelayedTemplateParsing.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-07-07 23:49:50 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-07-07 23:49:50 +0000
commitea5092a3b05ef184f0f73ccb8a4820740f0c2744 (patch)
tree2560e603c7e355bfe1fb33623bbc87d11adb0a42 /clang/test/Parser/DelayedTemplateParsing.cpp
parent7adf6111a8b5781dbd56a704d119e0398d284411 (diff)
downloadbcm5719-llvm-ea5092a3b05ef184f0f73ccb8a4820740f0c2744.tar.gz
bcm5719-llvm-ea5092a3b05ef184f0f73ccb8a4820740f0c2744.zip
Sema: Do not merge new decls with invalid, old decls
Sema::MergeFunctionDecl attempts merging two decls even if the old decl is invalid. This can lead to interesting circumstances where we successfully merge the decls but the result makes no sense. Take the following for example: template <typename T> int main(void); int main(void); Sema will not consider these to be overloads of the same name because main can't be overloaded, which means that this must be a redeclaration. In this case the templated decl is compatible with the non-templated decl allowing the Sema::CheckFunctionDeclaration machinery to move on and do bizarre things like setting the previous decl of a non-templated decl to a templated decl! The way I see it, we should just bail from MergeFunctionDecl if the old decl is invalid. This fixes PR16531. llvm-svn: 185779
Diffstat (limited to 'clang/test/Parser/DelayedTemplateParsing.cpp')
-rw-r--r--clang/test/Parser/DelayedTemplateParsing.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/test/Parser/DelayedTemplateParsing.cpp b/clang/test/Parser/DelayedTemplateParsing.cpp
index 77b47239f4c..3e429d41162 100644
--- a/clang/test/Parser/DelayedTemplateParsing.cpp
+++ b/clang/test/Parser/DelayedTemplateParsing.cpp
@@ -11,7 +11,8 @@ class A {
template <class T>
class B {
void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
- void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}}
+ void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}}
+ void foo5() { } // expected-note {{previous definition is here}}
friend void foo3() {
undeclared();
@@ -20,7 +21,7 @@ class B {
template <class T>
-void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}}
+void B<T>::foo5() { // expected-error {{redefinition of 'foo5'}}
}
template <class T>
OpenPOWER on IntegriCloud