diff options
author | John McCall <rjmccall@apple.com> | 2010-05-28 08:37:35 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-05-28 08:37:35 +0000 |
commit | 811d0bec4d4eb6a8ff373f97f98354d6e0e54ecb (patch) | |
tree | f8786274a29f2ca23e786fc43023d9d090d8e36e | |
parent | 1d0a5856d066f9030efbe3e0d9bbbb50ea597b99 (diff) |
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
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 9 | ||||
-rw-r--r-- | test/SemaCXX/exception-spec-no-exceptions.cpp | 32 |
2 files changed, 41 insertions, 0 deletions
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(); + } +} + |