From 5d99a252c63a7745bcd71231ca5240d2a65e4f1d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 22 Sep 2012 00:53:56 +0000 Subject: [PATCH] Fix bug which sometimes resulted in further diagnostics being produced after a fatal error. Previously, if a fatal error was followed by a diagnostic which was suppressed due to a SFINAETrap, we'd forget that we'd seen a fatal error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164437 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Diagnostic.h | 5 ++++- .../instantiate-exception-spec-cxx11.cpp | 12 ------------ .../instantiation-depth-exception-spec.cpp | 11 +++++++++++ test/SemaTemplate/instantiation-depth-subst-2.cpp | 7 ++----- test/SemaTemplate/instantiation-depth-subst.cpp | 6 +++--- 5 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 test/SemaTemplate/instantiation-depth-exception-spec.cpp diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index b7cfa38685..b596937061 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -478,10 +478,13 @@ public: } OverloadsShown getShowOverloads() const { return ShowOverloads; } - /// \brief Pretend that the last diagnostic issued was ignored. + /// \brief Pretend that the last diagnostic issued was ignored, so any + /// subsequent notes will be suppressed. /// /// This can be used by clients who suppress diagnostics themselves. void setLastDiagnosticIgnored() { + if (LastDiagLevel == DiagnosticIDs::Fatal) + FatalErrorOccurred = true; LastDiagLevel = DiagnosticIDs::Ignored; } diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp index c560c6ba2a..97bf00303b 100644 --- a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp +++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp @@ -34,18 +34,6 @@ template<> struct S<10> {}; void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}} expected-error {{not superset}} -template T go(T a) noexcept(noexcept(go(a))); // \ -// expected-error 16{{call to function 'go' that is neither visible}} \ -// expected-note 16{{'go' should be declared prior to the call site}} \ -// expected-error {{recursive template instantiation exceeded maximum depth of 16}} \ -// expected-error {{use of undeclared identifier 'go'}} \ - -void f() { - int k = go(0); // \ - // expected-note {{in instantiation of exception specification for 'go' requested here}} -} - - namespace dr1330_example { template struct A { void f(...) throw (typename T::X); // expected-error {{'int'}} diff --git a/test/SemaTemplate/instantiation-depth-exception-spec.cpp b/test/SemaTemplate/instantiation-depth-exception-spec.cpp new file mode 100644 index 0000000000..6caa4a60e6 --- /dev/null +++ b/test/SemaTemplate/instantiation-depth-exception-spec.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s + +template T go(T a) noexcept(noexcept(go(a))); // \ +// expected-error 16{{call to function 'go' that is neither visible}} \ +// expected-note 16{{'go' should be declared prior to the call site}} \ +// expected-error {{recursive template instantiation exceeded maximum depth of 16}} + +void f() { + int k = go(0); // \ + // expected-note {{in instantiation of exception specification for 'go' requested here}} +} diff --git a/test/SemaTemplate/instantiation-depth-subst-2.cpp b/test/SemaTemplate/instantiation-depth-subst-2.cpp index a29d6b5a1b..ef2a5c765d 100644 --- a/test/SemaTemplate/instantiation-depth-subst-2.cpp +++ b/test/SemaTemplate/instantiation-depth-subst-2.cpp @@ -1,9 +1,6 @@ // RUN: %clang_cc1 -verify %s -ftemplate-depth 2 template struct S { }; -// FIXME: We produce the same 'instantiation depth' error here many times -// (2^(depth+1) in total), due to additional lookups performed as part of -// error recovery in DiagnoseTwoPhaseOperatorLookup. -template S operator+(T, T); // expected-error 8{{}} expected-note 10{{}} +template S operator+(T, T); // expected-error {{instantiation exceeded maximum depth}} expected-note 3{{while substituting}} S<0> s; -int k = s + s; // expected-error {{invalid operands to binary expression}} +int k = s + s; diff --git a/test/SemaTemplate/instantiation-depth-subst.cpp b/test/SemaTemplate/instantiation-depth-subst.cpp index 58e637411c..06795f9514 100644 --- a/test/SemaTemplate/instantiation-depth-subst.cpp +++ b/test/SemaTemplate/instantiation-depth-subst.cpp @@ -3,7 +3,7 @@ // PR9793 template auto f(T t) -> decltype(f(t)); // \ // expected-error {{recursive template instantiation exceeded maximum depth of 2}} \ -// expected-note 3 {{while substituting}} \ -// expected-note {{candidate}} +// expected-note 3 {{while substituting}} -int k = f(0); // expected-error {{no matching function for call to 'f'}} +struct S {}; +int k = f(S{}); -- 2.40.0