diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-18 20:49:44 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-18 20:49:44 +0000 |
commit | ebaf0e6ab743394dda086a01b457838cb6e589a8 (patch) | |
tree | 731d496e1c1d0b3247aea91eaf79c4aee5be86fc /test/SemaCXX/cxx98-compat.cpp | |
parent | 024f4be866d13dd2b0ec062e694a62ca84c37191 (diff) |
-Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx98-compat.cpp')
-rw-r--r-- | test/SemaCXX/cxx98-compat.cpp | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp index a2e98e4743..123dd4f637 100644 --- a/test/SemaCXX/cxx98-compat.cpp +++ b/test/SemaCXX/cxx98-compat.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}} class Variadic1 {}; @@ -85,7 +86,7 @@ struct OverrideControl final : OverrideControlBase { // expected-warning {{'fina using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}} template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}} -inline namespace N { // expected-warning {{inline namespaces are incompatible with C++98}} +inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}} } auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}} @@ -100,3 +101,62 @@ void no_except() noexcept; // expected-warning {{noexcept specifications are inc bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}} void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}} + +struct InhCtorBase { + InhCtorBase(int); +}; +struct InhCtorDerived : InhCtorBase { + using InhCtorBase::InhCtorBase; // expected-warning {{inherited constructors are incompatible with C++98}} +}; + +struct FriendMember { + static void MemberFn(); + friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}} +}; + +struct DelegCtor { + DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}} + DelegCtor(); +}; + +template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}} + +template<typename T> int TemplateFn(T) { return 0; } +void LocalTemplateArg() { + struct S {}; + TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} +} +struct {} obj_of_unnamed_type; // expected-note {{here}} +int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} + +namespace RedundantParensInAddressTemplateParam { + int n; + template<int*p> struct S {}; + S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} + S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} +} + +namespace TemplateSpecOutOfScopeNs { + template<typename T> struct S {}; // expected-note {{here}} +} +template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}} + +struct Typename { + template<typename T> struct Inner {}; +}; +typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}} +Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}} + +struct TrivialButNonPOD { + int f(int); +private: + int k; +}; +void Ellipsis(int n, ...); +void TrivialButNonPODThroughEllipsis() { + Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}} +} + +struct HasExplicitConversion { + explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}} +}; |