[cfe-commits] r124441 - in /cfe/trunk: include/clang/AST/ASTDiagnostic.h include/clang/Analysis/AnalysisDiagnostic.h include/clang/Basic/Diagnostic.td include/clang/Basic/DiagnosticIDs.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Driver/DriverDiagnostic.h include/clang/Frontend/FrontendDiagnostic.h include/clang/Lex/LexDiagnostic.h include/clang/Parse/ParseDiagnostic.h include/clang/Sema/SemaDiagnostic.h lib/Basic/DiagnosticIDs.cpp lib/Sema/Sema.cpp
Douglas Gregor
dgregor at apple.com
Thu Jan 27 13:06:28 PST 2011
Author: dgregor
Date: Thu Jan 27 15:06:28 2011
New Revision: 124441
URL: http://llvm.org/viewvc/llvm-project?rev=124441&view=rev
Log:
Separate the access-control diagnostics from other diagnostics that do not have SFINAE behavior.
Modified:
cfe/trunk/include/clang/AST/ASTDiagnostic.h
cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
cfe/trunk/include/clang/Basic/Diagnostic.td
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Driver/DriverDiagnostic.h
cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
cfe/trunk/include/clang/Lex/LexDiagnostic.h
cfe/trunk/include/clang/Parse/ParseDiagnostic.h
cfe/trunk/include/clang/Sema/SemaDiagnostic.h
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/lib/Sema/Sema.cpp
Modified: cfe/trunk/include/clang/AST/ASTDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define ASTSTART
#include "clang/Basic/DiagnosticASTKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define ANALYSISSTART
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Basic/Diagnostic.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.td?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.td (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.td Thu Jan 27 15:06:28 2011
@@ -56,6 +56,7 @@
string Text = text;
DiagClass Class = DC;
bit SFINAE = 1;
+ bit AccessControl = 0;
DiagMapping DefaultMapping = defaultmapping;
DiagGroup Group;
string CategoryName = "";
@@ -74,6 +75,7 @@
class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; }
class NoSFINAE { bit SFINAE = 0; }
+class AccessControl { bit AccessControl = 1; }
// Definitions for Diagnostics.
include "DiagnosticASTKinds.td"
Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Thu Jan 27 15:06:28 2011
@@ -42,7 +42,7 @@
// Get typedefs for common diagnostics.
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#include "clang/Basic/DiagnosticCommonKinds.inc"
NUM_BUILTIN_COMMON_DIAGNOSTICS
#undef DIAG
@@ -157,7 +157,11 @@
///
/// The diagnostic should be reported. Various fatal errors (e.g.,
/// template instantiation depth exceeded) fall into this category.
- SFINAE_Report
+ SFINAE_Report,
+
+ /// \brief The diagnostic is an access-control diagnostic, which will be
+ /// substitution failures in some contexts and reported in others.
+ SFINAE_AccessControl
};
/// \brief Determines whether the given built-in diagnostic ID is
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 27 15:06:28 2011
@@ -541,65 +541,67 @@
def err_class_redeclared_with_different_access : Error<
"%0 redeclared with '%1' access">;
def err_access : Error<
- "%1 is a %select{private|protected}0 member of %3">, NoSFINAE;
+ "%1 is a %select{private|protected}0 member of %3">, AccessControl;
def err_access_ctor : Error<
- "calling a %select{private|protected}0 constructor of class %2">, NoSFINAE;
+ "calling a %select{private|protected}0 constructor of class %2">,
+ AccessControl;
def ext_rvalue_to_reference_access_ctor : ExtWarn<
"C++98 requires an accessible copy constructor for class %2 when binding "
"a reference to a temporary; was %select{private|protected}0">,
- NoSFINAE, InGroup<BindToTemporaryCopy>;
+ AccessControl, InGroup<BindToTemporaryCopy>;
def err_access_base : Error<
"%select{base class|inherited virtual base class}0 %1 has %select{private|"
"protected}3 %select{constructor|copy constructor|copy assignment operator|"
- "destructor}2">, NoSFINAE;
+ "destructor}2">, AccessControl;
def err_access_field: Error<
"field of type %0 has %select{private|protected}2 %select{constructor|copy "
- "constructor|copy assignment operator|destructor}1">, NoSFINAE;
+ "constructor|copy assignment operator|destructor}1">, AccessControl;
def err_access_ctor_field :
Error<"field of type %1 has %select{private|protected}2 constructor">,
- NoSFINAE;
+ AccessControl;
def err_access_dtor_base :
Error<"base class %0 has %select{private|protected}1 destructor">,
- NoSFINAE;
+ AccessControl;
def err_access_dtor_vbase :
Error<"inherited virtual base class %0 has "
"%select{private|protected}1 destructor">,
- NoSFINAE;
+ AccessControl;
def err_access_dtor_temp :
Error<"temporary of type %0 has %select{private|protected}1 destructor">,
- NoSFINAE;
+ AccessControl;
def err_access_dtor_exception :
Error<"exception object of type %0 has %select{private|protected}1 "
- "destructor">, NoSFINAE;
+ "destructor">, AccessControl;
def err_access_dtor_field :
Error<"field of type %1 has %select{private|protected}2 destructor">,
- NoSFINAE;
+ AccessControl;
def err_access_dtor_var :
Error<"variable of type %1 has %select{private|protected}2 destructor">,
- NoSFINAE;
+ AccessControl;
def err_access_assign_field :
Error<"field of type %1 has %select{private|protected}2 copy assignment"
" operator">,
- NoSFINAE;
+ AccessControl;
def err_access_assign_base :
Error<"base class %0 has %select{private|protected}1 copy assignment"
" operator">,
- NoSFINAE;
+ AccessControl;
def err_access_copy_field :
Error<"field of type %1 has %select{private|protected}2 copy constructor">,
- NoSFINAE;
+ AccessControl;
def err_access_copy_base :
Error<"base class %0 has %select{private|protected}1 copy constructor">,
- NoSFINAE;
+ AccessControl;
def err_access_dtor_ivar :
Error<"instance variable of type %0 has %select{private|protected}1 "
"destructor">,
- NoSFINAE;
+ AccessControl;
def note_previous_access_declaration : Note<
"previously declared '%1' here">;
def err_access_outside_class : Error<
- "access to %select{private|protected}0 member outside any class context">;
+ "access to %select{private|protected}0 member outside any class context">,
+ AccessControl;
def note_access_natural : Note<
"%select{|implicitly }1declared %select{private|protected}0 here">;
def note_access_constrained_by_path : Note<
@@ -707,7 +709,7 @@
def err_covariant_return_inaccessible_base : Error<
"invalid covariant return for virtual function: %1 is a "
- "%select{private|protected}2 base class of %0">, NoSFINAE;
+ "%select{private|protected}2 base class of %0">, AccessControl;
def err_covariant_return_ambiguous_derived_to_base_conv : Error<
"return type of virtual function %3 is not covariant with the return type of "
"the function it overrides (ambiguous conversion from derived class "
@@ -3197,7 +3199,7 @@
// C++ access control
def err_conv_to_inaccessible_base : Error<
- "conversion from %0 to inaccessible base class %1">, NoSFINAE;
+ "conversion from %0 to inaccessible base class %1">, AccessControl;
def note_inheritance_specifier_here : Note<
"'%0' inheritance specifier here">;
def note_inheritance_implicitly_private_here : Note<
@@ -3566,9 +3568,9 @@
def error_ivar_use_in_class_method : Error<
"instance variable %0 accessed in class method">;
def error_private_ivar_access : Error<"instance variable %0 is private">,
- NoSFINAE;
+ AccessControl;
def error_protected_ivar_access : Error<"instance variable %0 is protected">,
- NoSFINAE;
+ AccessControl;
def warn_maynot_respond : Warning<"%0 may not respond to %1">;
def warn_attribute_method_def : Warning<
"method attribute can only be specified on method declarations">;
Modified: cfe/trunk/include/clang/Driver/DriverDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/DriverDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/DriverDiagnostic.h (original)
+++ cfe/trunk/include/clang/Driver/DriverDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define DRIVERSTART
#include "clang/Basic/DiagnosticDriverKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define FRONTENDSTART
#include "clang/Basic/DiagnosticFrontendKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Lex/LexDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LexDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LexDiagnostic.h (original)
+++ cfe/trunk/include/clang/Lex/LexDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define LEXSTART
#include "clang/Basic/DiagnosticLexKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Parse/ParseDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/ParseDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/ParseDiagnostic.h (original)
+++ cfe/trunk/include/clang/Parse/ParseDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define PARSESTART
#include "clang/Basic/DiagnosticParseKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Sema/SemaDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaDiagnostic.h?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/SemaDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/SemaDiagnostic.h Thu Jan 27 15:06:28 2011
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
#define SEMASTART
#include "clang/Basic/DiagnosticSemaKinds.inc"
#undef DIAG
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Jan 27 15:06:28 2011
@@ -42,7 +42,8 @@
unsigned short DiagID;
unsigned Mapping : 3;
unsigned Class : 3;
- bool SFINAE : 1;
+ unsigned SFINAE : 1;
+ unsigned AccessControl : 1;
unsigned Category : 5;
const char *Description;
@@ -56,8 +57,8 @@
}
static const StaticDiagInfoRec StaticDiagInfo[] = {
-#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP,SFINAE, CATEGORY) \
- { diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, CATEGORY, DESC, GROUP },
+#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) \
+ { diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, ACCESS, CATEGORY, DESC, GROUP },
#include "clang/Basic/DiagnosticCommonKinds.inc"
#include "clang/Basic/DiagnosticDriverKinds.inc"
#include "clang/Basic/DiagnosticFrontendKinds.inc"
@@ -66,7 +67,7 @@
#include "clang/Basic/DiagnosticASTKinds.inc"
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
- { 0, 0, 0, 0, 0, 0, 0}
+ { 0, 0, 0, 0, 0, 0, 0, 0}
};
#undef DIAG
@@ -92,7 +93,7 @@
#endif
// Search the diagnostic table with a binary search.
- StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0, 0 };
+ StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0, 0, 0 };
const StaticDiagInfoRec *Found =
std::lower_bound(StaticDiagInfo, StaticDiagInfo + NumDiagEntries, Find);
@@ -150,6 +151,9 @@
DiagnosticIDs::SFINAEResponse
DiagnosticIDs::getDiagnosticSFINAEResponse(unsigned DiagID) {
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) {
+ if (Info->AccessControl)
+ return SFINAE_AccessControl;
+
if (!Info->SFINAE)
return SFINAE_Report;
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=124441&r1=124440&r2=124441&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Jan 27 15:06:28 2011
@@ -452,10 +452,12 @@
if (TemplateDeductionInfo *Info = SemaRef.isSFINAEContext()) {
switch (DiagnosticIDs::getDiagnosticSFINAEResponse(getDiagID())) {
+ case DiagnosticIDs::SFINAE_AccessControl:
case DiagnosticIDs::SFINAE_Report:
// Fall through; we'll report the diagnostic below.
break;
+
case DiagnosticIDs::SFINAE_SubstitutionFailure:
// Count this failure so that we know that template argument deduction
// has failed.
More information about the cfe-commits
mailing list