diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | clang/test/CXX/basic/basic.start/basic.start.main/p2.cpp | 9 | ||||
-rw-r--r-- | clang/test/Parser/DelayedTemplateParsing.cpp | 5 | ||||
-rw-r--r-- | clang/test/Sema/warn-main.c | 8 | ||||
-rw-r--r-- | clang/test/SemaTemplate/canonical-expr-type.cpp | 6 |
5 files changed, 19 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2024acc9755..5abacca732c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2305,6 +2305,10 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S) { return true; } + // If the old declaration is invalid, just give up here. + if (Old->isInvalidDecl()) + return true; + // Determine whether the previous declaration was a definition, // implicit declaration, or a declaration. diag::kind PrevDiag; diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2.cpp index cd912b834d7..5c7d60c1df4 100644 --- a/clang/test/CXX/basic/basic.start/basic.start.main/p2.cpp +++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2.cpp @@ -15,8 +15,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST13 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST14 #if TEST1 @@ -103,6 +103,13 @@ int main(void) {} template <typename T> int main(void); // expected-error{{'main' cannot be a template}} +#elif TEST14 + +template <typename T> +int main(void); // expected-error{{'main' cannot be a template}} + +int main(void) {} + #else #error Unknown test mode 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> diff --git a/clang/test/Sema/warn-main.c b/clang/test/Sema/warn-main.c index b67f96125d4..58a6dfde108 100644 --- a/clang/test/Sema/warn-main.c +++ b/clang/test/Sema/warn-main.c @@ -14,16 +14,14 @@ static int main() { return 0; } -// expected-error@+3 {{redefinition of 'main'}} -// expected-error@+2 {{'main' is not allowed to be declared inline}} -// expected-note@+1 {{previous definition is here}} +// expected-error@+2 {{redefinition of 'main'}} +// expected-error@+1 {{'main' is not allowed to be declared inline}} inline int main() { // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:"" return 0; } -// expected-warning@+6 {{function 'main' declared 'noreturn' should not return}} -// expected-error@+3 {{redefinition of 'main'}} +// expected-warning@+5 {{function 'main' declared 'noreturn' should not return}} // expected-warning@+2 {{'main' is not allowed to be declared _Noreturn}} // expected-note@+1 {{remove '_Noreturn'}} _Noreturn int main() { diff --git a/clang/test/SemaTemplate/canonical-expr-type.cpp b/clang/test/SemaTemplate/canonical-expr-type.cpp index 7582df5e66a..4770c4fa3ed 100644 --- a/clang/test/SemaTemplate/canonical-expr-type.cpp +++ b/clang/test/SemaTemplate/canonical-expr-type.cpp @@ -22,14 +22,10 @@ void f0a(T x, __typeof__(f(N)) y) { } // expected-note{{previous}} void f(int); template<typename T, T N> -void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} \ - // expected-note{{previous}} +void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} void f(float); -template<typename T, T N> -void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} - // Test dependently-sized array canonicalization template<typename T, int N, int M> void f1(T (&array)[N + M]) { } // expected-note{{previous}} |