From 018591f524ca4f3a1e657d0d0a66eadf9dbd55f6 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 2 Mar 2011 02:04:40 +0000 Subject: [PATCH] Semantic checking for exception specifications should be triggered by whether C++ exceptions are enabled, not exceptions in general. PR9358. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126820 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExceptionSpec.cpp | 6 +++--- test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp | 2 +- test/CXX/except/except.spec/p14.cpp | 2 +- test/CXX/temp/temp.decls/temp.variadic/p4.cpp | 2 +- test/SemaCXX/MicrosoftExtensions.cpp | 2 +- test/SemaCXX/exception-spec-no-exceptions.cpp | 7 ++++--- test/SemaCXX/exception-spec.cpp | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 5d7993b1af..123e185cab 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -160,7 +160,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { // If exceptions are disabled, suppress the warning about missing // exception specifications for new and delete operators. - if (!getLangOptions().Exceptions) { + if (!getLangOptions().CXXExceptions) { switch (New->getDeclName().getCXXOverloadedOperator()) { case OO_New: case OO_Array_New: @@ -249,7 +249,7 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, bool *MissingExceptionSpecification, bool *MissingEmptyExceptionSpecification) { // Just completely ignore this under -fno-exceptions. - if (!getLangOptions().Exceptions) + if (!getLangOptions().CXXExceptions) return false; if (MissingExceptionSpecification) @@ -331,7 +331,7 @@ bool Sema::CheckExceptionSpecSubset( const FunctionProtoType *Subset, SourceLocation SubLoc) { // Just auto-succeed under -fno-exceptions. - if (!getLangOptions().Exceptions) + if (!getLangOptions().CXXExceptions) return false; // FIXME: As usual, we could be more specific in our error messages, but diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp index 37a4f976ba..47b5158555 100644 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp +++ b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fexceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s int *use_new(int N) { if (N == 1) return new int; diff --git a/test/CXX/except/except.spec/p14.cpp b/test/CXX/except/except.spec/p14.cpp index 9450b1cf80..f5e83eaac6 100644 --- a/test/CXX/except/except.spec/p14.cpp +++ b/test/CXX/except/except.spec/p14.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexceptions -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -verify %s struct A { }; struct B { }; struct C { }; diff --git a/test/CXX/temp/temp.decls/temp.variadic/p4.cpp b/test/CXX/temp/temp.decls/temp.variadic/p4.cpp index e2fa122937..71839727e0 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p4.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++0x -fsyntax-only -fexceptions -verify %s +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -fexceptions -fcxx-exceptions -verify %s template struct tuple; template struct int_c; diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index 30ad4d0482..6a12d0dc96 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions +// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions // ::type_info is predeclared with forward class declartion diff --git a/test/SemaCXX/exception-spec-no-exceptions.cpp b/test/SemaCXX/exception-spec-no-exceptions.cpp index 1fe45b0cff..2e180706d3 100644 --- a/test/SemaCXX/exception-spec-no-exceptions.cpp +++ b/test/SemaCXX/exception-spec-no-exceptions.cpp @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fobjc-exceptions %s -// Note: this is intentionally -fno-exceptions, not just accidentally -// so because that's the current -cc1 default. +// Note that we're specifically excluding -fcxx-exceptions in the command line above. + +// That this should work even with -fobjc-exceptions is PR9358 // PR7243: redeclarations namespace test0 { diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp index b4bc78aa9a..80fd2c3d88 100644 --- a/test/SemaCXX/exception-spec.cpp +++ b/test/SemaCXX/exception-spec.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions %s // Straight from the standard: // Plain function with spec -- 2.40.0