summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-10-19 00:07:01 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-10-19 00:07:01 +0000
commit38c0e0417ccbc522a43962f9955d839300bb61ff (patch)
tree8c78597581e51721c9dce020d999fa30df719bee /clang/lib
parent20a04e74e3837638e3a2d42c66ce80bb66fb7fa4 (diff)
downloadbcm5719-llvm-38c0e0417ccbc522a43962f9955d839300bb61ff.tar.gz
bcm5719-llvm-38c0e0417ccbc522a43962f9955d839300bb61ff.zip
-Wc++98-compat: warn if a SFINAE substitution in C++11 suppresses an access
control diagnostic. llvm-svn: 142463
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/Sema.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 4a9d8a5efbf..8346cc475ff 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -625,10 +625,19 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
if (llvm::Optional<TemplateDeductionInfo*> Info = SemaRef.isSFINAEContext()) {
switch (DiagnosticIDs::getDiagnosticSFINAEResponse(getDiagID())) {
case DiagnosticIDs::SFINAE_Report:
- // Fall through; we'll report the diagnostic below.
+ // We'll report the diagnostic below.
break;
- case DiagnosticIDs::SFINAE_AccessControl:
+ case DiagnosticIDs::SFINAE_SubstitutionFailure:
+ // Count this failure so that we know that template argument deduction
+ // has failed.
+ ++SemaRef.NumSFINAEErrors;
+ SemaRef.Diags.setLastDiagnosticIgnored();
+ SemaRef.Diags.Clear();
+ Clear();
+ return;
+
+ case DiagnosticIDs::SFINAE_AccessControl: {
// Per C++ Core Issue 1170, access control is part of SFINAE.
// Additionally, the AccessCheckingSFINAE flag can be used to temporary
// make access control a part of SFINAE for the purposes of checking
@@ -636,16 +645,25 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
if (!SemaRef.AccessCheckingSFINAE &&
!SemaRef.getLangOptions().CPlusPlus0x)
break;
-
- case DiagnosticIDs::SFINAE_SubstitutionFailure:
- // Count this failure so that we know that template argument deduction
- // has failed.
+
+ SourceLocation Loc = getLocation();
+
+ // Suppress this diagnostic.
++SemaRef.NumSFINAEErrors;
SemaRef.Diags.setLastDiagnosticIgnored();
SemaRef.Diags.Clear();
Clear();
+
+ // Now the diagnostic state is clear, produce a C++98 compatibility
+ // warning.
+ SemaRef.Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
+
+ // The last diagnostic which Sema produced was ignored. Suppress any
+ // notes attached to it.
+ SemaRef.Diags.setLastDiagnosticIgnored();
return;
-
+ }
+
case DiagnosticIDs::SFINAE_Suppress:
// Make a copy of this suppressed diagnostic and store it with the
// template-deduction information;
OpenPOWER on IntegriCloud