diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/clang.xcodeproj/project.pbxproj | 1 | ||||
-rw-r--r-- | clang/include/clang/Basic/DiagnosticGroups.td | 4 | ||||
-rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 5 | ||||
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 16 | ||||
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 4 | ||||
-rw-r--r-- | clang/test/Lexer/has_feature_cxx0x.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/deleted-function-extension.cpp | 8 |
9 files changed, 38 insertions, 12 deletions
diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj index 2a256450887..def722b45e4 100644 --- a/clang/clang.xcodeproj/project.pbxproj +++ b/clang/clang.xcodeproj/project.pbxproj @@ -2039,6 +2039,7 @@ isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index c7585e1ee0a..6894f795247 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -226,6 +226,10 @@ def : DiagGroup<"comments", [Comment]>; // -Wcomments = -Wcomment 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]>; diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 427bae20950..1c4a226b85c 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -374,7 +374,10 @@ def err_ctor_init_missing_comma : Error< // 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< diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a00dc0ec11d..e3699ab7d5d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1466,7 +1466,8 @@ def err_template_spec_decl_out_of_scope_global : Error< 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 err_template_spec_decl_out_of_scope : Error< 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 @@ def note_previous_explicit_instantiation : Note< "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 @@ def err_array_size_ambiguous_conversion : Error< "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 @@ def err_in_class_initializer_bad_type : Error< "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 @@ def warn_not_compound_assign : Warning< // 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)">, diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 9015c278fc9..46b671da199 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -514,7 +514,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .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) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index bef9f9585da..5ed22e27537 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -589,8 +589,12 @@ Decl *Parser::ParseDeclarationAfterDeclarator(Declarator &D, // 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()) { diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 56fee66fcdf..092268c8215 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1443,7 +1443,9 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // '=' '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 { diff --git a/clang/test/Lexer/has_feature_cxx0x.cpp b/clang/test/Lexer/has_feature_cxx0x.cpp index cc2ae28c58b..c6c7787276a 100644 --- a/clang/test/Lexer/has_feature_cxx0x.cpp +++ b/clang/test/Lexer/has_feature_cxx0x.cpp @@ -70,7 +70,7 @@ int no_static_assert(); // 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 @@ int no_deleted_functions(); #endif // CHECK-0X: deleted_functions -// CHECK-NO-0X: no_deleted_functions +// CHECK-NO-0X: deleted_functions #if __has_feature(cxx_rvalue_references) diff --git a/clang/test/SemaCXX/deleted-function-extension.cpp b/clang/test/SemaCXX/deleted-function-extension.cpp new file mode 100644 index 00000000000..fdf5ac8bd58 --- /dev/null +++ b/clang/test/SemaCXX/deleted-function-extension.cpp @@ -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}} |