[cfe-commits] r114762 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td lib/Lex/PPMacroExpansion.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp test/Lexer/has_feature_cxx0x.cpp test/SemaCXX/deleted-function-extension.cpp
Anders Carlsson
andersca at mac.com
Fri Sep 24 14:25:25 PDT 2010
Author: andersca
Date: Fri Sep 24 16:25:25 2010
New Revision: 114762
URL: http://llvm.org/viewvc/llvm-project?rev=114762&view=rev
Log:
Allow the use of C++0x deleted functions as an extension in C++98.
Added:
cfe/trunk/test/SemaCXX/deleted-function-extension.cpp
Modified:
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Fri Sep 24 16:25:25 2010
@@ -2039,6 +2039,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Sep 24 16:25:25 2010
@@ -226,6 +226,10 @@
def NonGCC : DiagGroup<"non-gcc",
[SignCompare, Conversion, LiteralRange]>;
+// A warning group for warnings about using C++0x features as extensions in
+// earlier C++ versions.
+def CXX0x : DiagGroup<"c++0x-extensions">;
+
// A warning group for warnings about GCC extensions.
def GNU : DiagGroup<"gnu", [GNUDesignator, VLA]>;
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep 24 16:25:25 2010
@@ -374,7 +374,10 @@
// C++ declarations
def err_friend_decl_defines_class : Error<
"cannot define a type in a friend declaration">;
-
+
+def warn_deleted_function_accepted_as_extension: ExtWarn<
+ "deleted function definition accepted as a C++0x extension">, InGroup<CXX0x>;
+
// Language specific pragmas
// - Generic warnings
def warn_pragma_expected_lparen : Warning<
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 24 16:25:25 2010
@@ -1466,7 +1466,8 @@
def ext_template_spec_decl_out_of_scope_global : ExtWarn<
"%select{class template|class template partial|function template|member "
"function|static data member|member class}0 specialization of %1 must "
- "originally be declared in the global scope; accepted as a C++0x extension">;
+ "originally be declared in the global scope; accepted as a C++0x extension">,
+ InGroup<CXX0x>;
def err_template_spec_decl_out_of_scope : Error<
"%select{class template|class template partial|function template|member "
"function|static data member|member class}0 specialization of %1 must "
@@ -1474,7 +1475,8 @@
def ext_template_spec_decl_out_of_scope : ExtWarn<
"%select{class template|class template partial|function template|member "
"function|static data member|member class}0 specialization of %1 must "
- "originally be declared in namespace %2; accepted as a C++0x extension">;
+ "originally be declared in namespace %2; accepted as a C++0x extension">,
+ InGroup<CXX0x>;
def err_template_spec_redecl_out_of_scope : Error<
"%select{class template|class template partial|function template|member "
"function|static data member|member class}0 specialization of %1 not in a "
@@ -1618,7 +1620,8 @@
"previous explicit instantiation is here">;
def ext_explicit_instantiation_after_specialization : Extension<
"explicit instantiation of %0 that occurs after an explicit "
- "specialization will be ignored (C++0x extension)">;
+ "specialization will be ignored (C++0x extension)">,
+ InGroup<CXX0x>;
def note_previous_template_specialization : Note<
"previous template specialization is here">;
def err_explicit_instantiation_enum : Error<
@@ -2464,7 +2467,8 @@
"enumeration type">;
def ext_array_size_conversion : Extension<
"implicit conversion from array size expression of type %0 to "
- "%select{integral|enumeration}1 type %2 is a C++0x extension">;
+ "%select{integral|enumeration}1 type %2 is a C++0x extension">,
+ InGroup<CXX0x>;
def err_default_init_const : Error<
"default initialization of an object of const type %0"
@@ -2878,7 +2882,7 @@
"static data member of type %0 must be initialized out of line">;
def ext_in_class_initializer_float_type : ExtWarn<
"in-class initializer for static data member of type %0 "
- "is a C++0x extension">;
+ "is a C++0x extension">, InGroup<CXX0x>;
def err_in_class_initializer_non_constant : Error<
"in-class initializer is not a constant expression">;
@@ -3042,7 +3046,7 @@
// C++0x explicit conversion operators
def warn_explicit_conversion_functions : Warning<
- "explicit conversion functions are a C++0x extension">;
+ "explicit conversion functions are a C++0x extension">, InGroup<CXX0x>;
def warn_printf_write_back : Warning<
"use of '%%n' in format string discouraged (potentially insecure)">,
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Sep 24 16:25:25 2010
@@ -514,7 +514,7 @@
.Case("cxx_attributes", LangOpts.CPlusPlus0x)
.Case("cxx_auto_type", LangOpts.CPlusPlus0x)
.Case("cxx_decltype", LangOpts.CPlusPlus0x)
- .Case("cxx_deleted_functions", LangOpts.CPlusPlus0x)
+ .Case("cxx_deleted_functions", true) // Accepted as an extension.
.Case("cxx_exceptions", LangOpts.Exceptions)
.Case("cxx_rtti", LangOpts.RTTI)
.Case("cxx_static_assert", LangOpts.CPlusPlus0x)
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Sep 24 16:25:25 2010
@@ -589,8 +589,12 @@
// Parse declarator '=' initializer.
if (Tok.is(tok::equal)) {
ConsumeToken();
- if (getLang().CPlusPlus0x && Tok.is(tok::kw_delete)) {
+ if (Tok.is(tok::kw_delete)) {
SourceLocation DelLoc = ConsumeToken();
+
+ if (!getLang().CPlusPlus0x)
+ Diag(DelLoc, diag::warn_deleted_function_accepted_as_extension);
+
Actions.SetDeclDeleted(ThisDecl, DelLoc);
} else {
if (getLang().CPlusPlus && D.getCXXScopeSpec().isSet()) {
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Sep 24 16:25:25 2010
@@ -1443,7 +1443,9 @@
// '=' 'delete'
if (Tok.is(tok::equal)) {
ConsumeToken();
- if (getLang().CPlusPlus0x && Tok.is(tok::kw_delete)) {
+ if (Tok.is(tok::kw_delete)) {
+ if (!getLang().CPlusPlus0x)
+ Diag(Tok, diag::warn_deleted_function_accepted_as_extension);
ConsumeToken();
Deleted = true;
} else {
Modified: cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_cxx0x.cpp?rev=114762&r1=114761&r2=114762&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_cxx0x.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_cxx0x.cpp Fri Sep 24 16:25:25 2010
@@ -70,7 +70,7 @@
// CHECK-0X: has_static_assert
// CHECK-NO-0X: no_static_assert
-
+// We accept this as an extension.
#if __has_feature(cxx_deleted_functions)
int deleted_functions();
#else
@@ -78,7 +78,7 @@
#endif
// CHECK-0X: deleted_functions
-// CHECK-NO-0X: no_deleted_functions
+// CHECK-NO-0X: deleted_functions
#if __has_feature(cxx_rvalue_references)
Added: cfe/trunk/test/SemaCXX/deleted-function-extension.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-function-extension.cpp?rev=114762&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/deleted-function-extension.cpp (added)
+++ cfe/trunk/test/SemaCXX/deleted-function-extension.cpp Fri Sep 24 16:25:25 2010
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+
+struct A {
+ A(const A&) = delete; // expected-warning {{deleted function definition accepted as a C++0x extension}}
+ A& operator=(const A&) = delete; // expected-warning {{deleted function definition accepted as a C++0x extension}}
+};
+
+void f() = delete; // expected-warning {{deleted function definition accepted as a C++0x extension}}
More information about the cfe-commits
mailing list