aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hunt <scshunt@csclub.uwaterloo.ca>2011-05-05 00:05:47 +0000
committerSean Hunt <scshunt@csclub.uwaterloo.ca>2011-05-05 00:05:47 +0000
commitc1598700010cea9364a58a65e967b0b56361b6aa (patch)
tree84b34b76ede8fe385130720052715283f926daeb
parente74c25c5c0375004bd84945bda53c3a96f443da8 (diff)
Change cycle detection to be based off of a warning flag.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130898 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticGroups.td2
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td11
-rw-r--r--include/clang/Basic/LangOptions.h5
-rw-r--r--include/clang/Driver/CC1Options.td2
-rw-r--r--lib/Frontend/CompilerInvocation.cpp5
-rw-r--r--lib/Sema/Sema.cpp5
-rw-r--r--lib/Sema/SemaDeclCXX.cpp5
7 files changed, 13 insertions, 22 deletions
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index c85acc5107..72afc3d616 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -271,6 +271,8 @@ def NonGCC : DiagGroup<"non-gcc",
def CXX0xStaticNonIntegralInitializer :
DiagGroup<"c++0x-static-nonintegral-init">;
def CXX0x : DiagGroup<"c++0x-extensions", [CXX0xStaticNonIntegralInitializer]>;
+def DelegatingCtorCycles :
+ DiagGroup<"delegating-ctor-cycles">;
// A warning group for warnings about GCC extensions.
def GNU : DiagGroup<"gnu", [GNUDesignator, VLA]>;
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 771a68177a..9eee67da58 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1009,16 +1009,15 @@ def err_enum_redeclare_scoped_mismatch : Error<
// C++0x delegating constructors
def err_delegation_0x_only : Error<
"delegating constructors are permitted only in C++0x">;
-def err_delegation_unimplemented : Error<
- "delegating constructors are not fully implemented">;
def err_delegating_initializer_alone : Error<
"an initializer for a delegating constructor must appear alone">;
-def err_delegating_ctor_cycle : Error<
- "constructor for %0 creates a delegation cycle">;
+def warn_delegating_ctor_cycle : Warning<
+ "constructor for %0 creates a delegation cycle">, DefaultError,
+ InGroup<DelegatingCtorCycles>;
def note_it_delegates_to : Note<
- "it delegates to">;
+ "it delegates to">, InGroup<DelegatingCtorCycles>;
def note_which_delegates_to : Note<
- "which delegates to">;
+ "which delegates to">, InGroup<DelegatingCtorCycles>;
def err_delegating_codegen_not_implemented : Error<
"code generation for delegating constructors not implemented">;
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h
index 92af3c19f5..a5f6789b7d 100644
--- a/include/clang/Basic/LangOptions.h
+++ b/include/clang/Basic/LangOptions.h
@@ -134,9 +134,6 @@ public:
unsigned MRTD : 1; // -mrtd calling convention
unsigned DelayedTemplateParsing : 1; // Delayed template parsing
- // Do we try to detect cycles in delegating constructors?
- unsigned CheckDelegatingCtorCycles : 1;
-
private:
// We declare multibit enums as unsigned because MSVC insists on making enums
// signed. Set/Query these values using accessors.
@@ -235,8 +232,6 @@ public:
MRTD = 0;
DelayedTemplateParsing = 0;
ParseUnknownAnytype = 0;
-
- CheckDelegatingCtorCycles = 1;
}
GCMode getGCMode() const { return (GCMode) GC; }
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 9f4ada4b3c..7908b8f106 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -550,8 +550,6 @@ def fdeprecated_macro : Flag<"-fdeprecated-macro">,
HelpText<"Defines the __DEPRECATED macro">;
def fno_deprecated_macro : Flag<"-fno-deprecated-macro">,
HelpText<"Undefines the __DEPRECATED macro">;
-def fno_check_delegating_ctor_cycles : Flag<"-fno-check-delegating-ctor-cycles">,
- HelpText<"Turns off delegating constructor cycle detection">;
//===----------------------------------------------------------------------===//
// Header Search Options
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 7a7692f377..180ce3efcb 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -698,9 +698,6 @@ static void LangOptsToArgs(const LangOptions &Opts,
Res.push_back("-fdelayed-template-parsing");
if (Opts.Deprecated)
Res.push_back("-fdeprecated-macro");
-
- if (Opts.CheckDelegatingCtorCycles)
- Res.push_back("-fcheck-delegating-ctor-cycles");
}
static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts,
@@ -1569,8 +1566,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.MRTD = Args.hasArg(OPT_mrtd);
Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
- Opts.CheckDelegatingCtorCycles
- = !Args.hasArg(OPT_fno_check_delegating_ctor_cycles);
// Record whether the __DEPRECATED define was requested.
Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index ec2c739228..c47827153d 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -474,7 +474,10 @@ void Sema::ActOnEndOfTranslationUnit() {
}
- if (LangOpts.CPlusPlus0x && LangOpts.CheckDelegatingCtorCycles)
+ if (LangOpts.CPlusPlus0x &&
+ Diags.getDiagnosticLevel(diag::warn_delegating_ctor_cycle,
+ SourceLocation())
+ != Diagnostic::Ignored)
CheckDelegatingCtorCycles();
// If there were errors, disable 'unused' warnings since they will mostly be
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index bb732e2c9f..7b28696814 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2085,8 +2085,7 @@ Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
}
- if (LangOpts.CheckDelegatingCtorCycles)
- DelegatingCtorDecls.push_back(Constructor);
+ DelegatingCtorDecls.push_back(Constructor);
return false;
}
@@ -7984,7 +7983,7 @@ void DelegatingCycleHelper(CXXConstructorDecl* Ctor,
// If we haven't diagnosed this cycle yet, do so now.
if (!Invalid.count(TCanonical)) {
S.Diag((*Ctor->init_begin())->getSourceLocation(),
- diag::err_delegating_ctor_cycle)
+ diag::warn_delegating_ctor_cycle)
<< Ctor;
// Don't add a note for a function delegating directo to itself.