From 811d0bec4d4eb6a8ff373f97f98354d6e0e54ecb Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 28 May 2010 08:37:35 +0000 Subject: [PATCH] Disable exception-spec compatibility checking under -fno-exceptions. Fixes PR7243. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104942 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExceptionSpec.cpp | 9 ++++++ test/SemaCXX/exception-spec-no-exceptions.cpp | 32 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/SemaCXX/exception-spec-no-exceptions.cpp diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 7d73fe4777..34a479ae2a 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -249,6 +249,10 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, SourceLocation NewLoc, bool *MissingExceptionSpecification, bool *MissingEmptyExceptionSpecification) { + // Just completely ignore this under -fno-exceptions. + if (!getLangOptions().Exceptions) + return false; + if (MissingExceptionSpecification) *MissingExceptionSpecification = false; @@ -318,6 +322,11 @@ bool Sema::CheckExceptionSpecSubset( const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, const FunctionProtoType *Superset, SourceLocation SuperLoc, const FunctionProtoType *Subset, SourceLocation SubLoc) { + + // Just auto-succeed under -fno-exceptions. + if (!getLangOptions().Exceptions) + return false; + // FIXME: As usual, we could be more specific in our error messages, but // that better waits until we've got types with source locations. diff --git a/test/SemaCXX/exception-spec-no-exceptions.cpp b/test/SemaCXX/exception-spec-no-exceptions.cpp new file mode 100644 index 0000000000..1fe45b0cff --- /dev/null +++ b/test/SemaCXX/exception-spec-no-exceptions.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Note: this is intentionally -fno-exceptions, not just accidentally +// so because that's the current -cc1 default. + +// PR7243: redeclarations +namespace test0 { + void foo() throw(int); + void foo() throw(); +} + +// Overrides. +namespace test1 { + struct A { + virtual void foo() throw(); + }; + + struct B : A { + virtual void foo() throw(int); + }; +} + +// Calls from less permissive contexts. We don't actually do this +// check, but if we did it should also be disabled under +// -fno-exceptions. +namespace test2 { + void foo() throw(int); + void bar() throw() { + foo(); + } +} +