r370087 - Move EH spec mismatches under -fms-compatibility
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 27 10:52:03 PDT 2019
Author: rnk
Date: Tue Aug 27 10:52:03 2019
New Revision: 370087
URL: http://llvm.org/viewvc/llvm-project?rev=370087&view=rev
Log:
Move EH spec mismatches under -fms-compatibility
-fms-extensions is intended to enable conforming language extensions and
-fms-compatibility is intended to language rule relaxations, so a user
could plausibly compile with -fno-ms-compatibility on Windows while
still using dllexport, for example. This exception specification
validation behavior has been handled as a warning since before
-fms-compatibility was added in 2011. I think it's just an oversight
that it hasn't been moved yet.
This will help users find conformance issues in their code such as those
found in _com_ptr_t as described in https://llvm.org/PR42842.
Reviewers: hans
Subscribers: STL_MSFT, cfe-commits
Differential Revision: https://reviews.llvm.org/D66770
Modified:
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/test/CodeGenCXX/pr18661.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=370087&r1=370086&r2=370087&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Tue Aug 27 10:52:03 2019
@@ -149,7 +149,7 @@ bool Sema::CheckSpecifiedExceptionType(Q
// In Microsoft mode, downgrade this to a warning.
unsigned DiagID = diag::err_incomplete_in_exception_spec;
bool ReturnValueOnError = true;
- if (getLangOpts().MicrosoftExt) {
+ if (getLangOpts().MSVCCompat) {
DiagID = diag::ext_incomplete_in_exception_spec;
ReturnValueOnError = false;
}
@@ -282,7 +282,7 @@ bool Sema::CheckEquivalentExceptionSpec(
unsigned DiagID = diag::err_mismatched_exception_spec;
bool ReturnValueOnError = true;
- if (getLangOpts().MicrosoftExt) {
+ if (getLangOpts().MSVCCompat) {
DiagID = diag::ext_mismatched_exception_spec;
ReturnValueOnError = false;
}
@@ -371,7 +371,7 @@ bool Sema::CheckEquivalentExceptionSpec(
NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
}
- if (getLangOpts().MicrosoftExt && ESI.Type != EST_DependentNoexcept) {
+ if (getLangOpts().MSVCCompat && ESI.Type != EST_DependentNoexcept) {
// Allow missing exception specifications in redeclarations as an extension.
DiagID = diag::ext_ms_missing_exception_specification;
ReturnValueOnError = false;
@@ -473,14 +473,14 @@ bool Sema::CheckEquivalentExceptionSpec(
return false;
unsigned DiagID = diag::err_mismatched_exception_spec;
- if (getLangOpts().MicrosoftExt)
+ if (getLangOpts().MSVCCompat)
DiagID = diag::ext_mismatched_exception_spec;
bool Result = CheckEquivalentExceptionSpecImpl(
*this, PDiag(DiagID), PDiag(diag::note_previous_declaration),
Old, OldLoc, New, NewLoc);
// In Microsoft mode, mismatching exception specifications just cause a warning.
- if (getLangOpts().MicrosoftExt)
+ if (getLangOpts().MSVCCompat)
return false;
return Result;
}
@@ -959,7 +959,7 @@ bool Sema::CheckOverridingFunctionExcept
}
unsigned DiagID = diag::err_override_exception_spec;
- if (getLangOpts().MicrosoftExt)
+ if (getLangOpts().MSVCCompat)
DiagID = diag::ext_override_exception_spec;
return CheckExceptionSpecSubset(PDiag(DiagID),
PDiag(diag::err_deep_exception_specs_differ),
Modified: cfe/trunk/test/CodeGenCXX/pr18661.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr18661.cpp?rev=370087&r1=370086&r2=370087&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/pr18661.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pr18661.cpp Tue Aug 27 10:52:03 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fcxx-exceptions -fms-extensions -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fcxx-exceptions -fms-compatibility -emit-llvm -o - | FileCheck %s
extern "C" {
void f();
Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=370087&r1=370086&r2=370087&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Tue Aug 27 10:52:03 2019
@@ -322,3 +322,47 @@ size_t ConfuseLookup<T>::m_val::ms_test
void instantiate() { ConfuseLookup<int>::m_val::ms_test = 1; }
}
+
+// Microsoft doesn't validate exception specification.
+namespace microsoft_exception_spec {
+
+void foo(); // expected-note {{previous declaration}}
+void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
+
+void r6() throw(...); // expected-note {{previous declaration}}
+void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
+
+struct Base {
+ virtual void f2();
+ virtual void f3() throw(...);
+};
+
+struct Derived : Base {
+ virtual void f2() throw(...);
+ virtual void f3();
+};
+
+class A {
+ virtual ~A() throw();
+#if __cplusplus <= 199711L
+ // expected-note at -2 {{overridden virtual function is here}}
+#endif
+};
+
+class B : public A {
+ virtual ~B();
+#if __cplusplus <= 199711L
+ // expected-warning at -2 {{exception specification of overriding function is more lax than base version}}
+#endif
+};
+
+}
+
+namespace PR25265 {
+struct S {
+ int fn() throw(); // expected-note {{previous declaration is here}}
+};
+
+int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
+}
+
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=370087&r1=370086&r2=370087&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Aug 27 10:52:03 2019
@@ -6,41 +6,6 @@
#if TEST1
-// Microsoft doesn't validate exception specification.
-namespace microsoft_exception_spec {
-
-void foo(); // expected-note {{previous declaration}}
-void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
-
-void r6() throw(...); // expected-note {{previous declaration}}
-void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
-
-struct Base {
- virtual void f2();
- virtual void f3() throw(...);
-};
-
-struct Derived : Base {
- virtual void f2() throw(...);
- virtual void f3();
-};
-
-class A {
- virtual ~A() throw();
-#if __cplusplus <= 199711L
- // expected-note at -2 {{overridden virtual function is here}}
-#endif
-};
-
-class B : public A {
- virtual ~B();
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{exception specification of overriding function is more lax than base version}}
-#endif
-};
-
-}
-
// MSVC allows type definition in anonymous union and struct
struct A
{
@@ -495,14 +460,6 @@ template <typename TX> struct A {
};
}
-namespace PR25265 {
-struct S {
- int fn() throw(); // expected-note {{previous declaration is here}}
-};
-
-int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
-}
-
class PR34109_class {
PR34109_class() {}
virtual ~PR34109_class() {}
Modified: cfe/trunk/test/SemaCXX/ms-exception-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-exception-spec.cpp?rev=370087&r1=370086&r2=370087&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ms-exception-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-exception-spec.cpp Tue Aug 27 10:52:03 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
void f() throw(...) { }
More information about the cfe-commits
mailing list