[clang] [Clang] Make most C++98 extension warnings pedantic (PR #246759)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 08:22:09 PST 2026
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/246759
>From a4edcf641a182642b09400aef07fcaef478aa14a Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Fri, 27 Nov 2026 22:46:46 +0100
Subject: [PATCH 1/2] [Clang] Make most C++98 extension warnings pedantic
---
clang/include/clang/Basic/Diagnostic.td | 2 +-
.../include/clang/Basic/DiagnosticLexKinds.td | 3 +-
.../clang/Basic/DiagnosticParseKinds.td | 11 +-
.../clang/Basic/DiagnosticSemaKinds.td | 5 +-
clang/test/AST/ByteCode/cxx03.cpp | 3 +-
.../basic.lookup.qual/namespace.qual/p2.cpp | 3 -
.../class.access/class.friend/p2-cxx03.cpp | 9 +-
clang/test/CXX/class/class.friend/p2.cpp | 3 -
clang/test/CXX/class/class.union/p1.cpp | 6 +-
.../CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp | 12 +-
.../CXX/temp/temp.arg/temp.arg.nontype/p5.cpp | 3 -
clang/test/CXX/temp/temp.param/p9.cpp | 10 +-
clang/test/Parser/cxx-ext-delete-default.cpp | 2 +-
clang/test/Parser/cxx-friend.cpp | 5 +-
clang/test/Parser/cxx-reference.cpp | 5 +-
clang/test/Parser/cxx0x-in-cxx98.cpp | 2 +-
clang/test/SemaCXX/MicrosoftCompatibility.cpp | 16 +-
clang/test/SemaCXX/PR10458.cpp | 2 +-
clang/test/SemaCXX/PR9572.cpp | 3 -
.../SemaCXX/addr-of-overloaded-function.cpp | 3 -
clang/test/SemaCXX/aggregate-init-cxx98.cpp | 4 +-
clang/test/SemaCXX/anonymous-struct.cpp | 4 +-
clang/test/SemaCXX/class.cpp | 9 +-
clang/test/SemaCXX/const-cast.cpp | 6 -
clang/test/SemaCXX/convert-to-bool.cpp | 11 +-
clang/test/SemaCXX/copy-initialization.cpp | 3 -
clang/test/SemaCXX/cxx0x-return-init-list.cpp | 4 +-
clang/test/SemaCXX/cxx11-compat.cpp | 35 +-
clang/test/SemaCXX/cxx14-compat.cpp | 6 +
.../test/SemaCXX/cxx1z-constexpr-lambdas.cpp | 28 +-
clang/test/SemaCXX/cxx20-compat.cpp | 8 +
.../cxx2d-defaulted-postfix-operators.cpp | 17 +-
clang/test/SemaCXX/cxx98-compat-pedantic.cpp | 81 ---
clang/test/SemaCXX/cxx98-compat.cpp | 517 +++++++++++-------
clang/test/SemaCXX/member-expr.cpp | 3 -
clang/test/SemaCXX/nested-name-spec.cpp | 2 +-
clang/test/SemaCXX/pre-cxx14-compat.cpp | 55 ++
clang/test/SemaCXX/undefined-internal.cpp | 10 -
clang/test/SemaCXX/unknown-type-name.cpp | 3 -
clang/test/SemaObjCXX/crash.mm | 9 +-
clang/test/SemaObjCXX/message.mm | 11 +-
.../test/SemaTemplate/class-template-spec.cpp | 18 -
clang/test/SemaTemplate/default-arguments.cpp | 6 -
.../SemaTemplate/instantiate-function-2.cpp | 3 -
.../SemaTemplate/instantiate-member-class.cpp | 5 +-
.../SemaTemplate/instantiate-using-decl.cpp | 3 -
.../test/SemaTemplate/overload-candidates.cpp | 22 +-
clang/test/SemaTemplate/temp_arg_nontype.cpp | 6 +-
clang/test/SemaTemplate/template-id-expr.cpp | 3 -
.../SemaTemplate/typename-specifier-4.cpp | 4 -
.../test/SemaTemplate/typename-specifier.cpp | 18 -
51 files changed, 456 insertions(+), 566 deletions(-)
create mode 100644 clang/test/SemaCXX/cxx20-compat.cpp
delete mode 100644 clang/test/SemaCXX/cxx98-compat-pedantic.cpp
create mode 100644 clang/test/SemaCXX/pre-cxx14-compat.cpp
diff --git a/clang/include/clang/Basic/Diagnostic.td b/clang/include/clang/Basic/Diagnostic.td
index c6146f8cca7167..017888a58d99b3 100644
--- a/clang/include/clang/Basic/Diagnostic.td
+++ b/clang/include/clang/Basic/Diagnostic.td
@@ -251,7 +251,7 @@ multiclass CompatWarning<
// - compat_c(xx)11_inline_variable: 'inline variables are incompatible with C(++) standards before C(++)11'
// - compat_pre_c(xx)11_inline_variable: 'inline variables are a C(++)11 extension'
//
-multiclass CXX11Compat<string message, bit ext_warn = true> : CompatWarning<message, 11, /*cxx=*/true, ext_warn>;
+multiclass CXX11Compat<string message, bit ext_warn = false> : CompatWarning<message, 11, /*cxx=*/true, ext_warn>;
multiclass CXX14Compat<string message, bit ext_warn = true> : CompatWarning<message, 14, /*cxx=*/true, ext_warn>;
multiclass CXX17Compat<string message, bit ext_warn = true> : CompatWarning<message, 17, /*cxx=*/true, ext_warn>;
multiclass CXX20Compat<string message, bit ext_warn = true> : CompatWarning<message, 20, /*cxx=*/true, ext_warn>;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index a75c7ddd66cb87..886d36a124ffbd 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -17,8 +17,7 @@ defm c23_pp_directive : C23Compat<
defm c23_pp_embed_directive : C23Compat<"#embed is", /*ext_warn*/true>;
// C++11 compatibility with C++98.
-defm empty_fnmacro_arg : CXX11Compat<
- "empty macro arguments are", /*ext_warn*/false>;
+defm empty_fnmacro_arg : CXX11Compat<"empty macro arguments are">;
// C++17 compatibility with C++14 and earlier.
defm hex_literal : CXX17Compat<
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c15abf61fb01f0..06878dea03084e 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -31,15 +31,14 @@ defm generic_with_type_arg : C2yCompat<
// C++11 compatibility with C++98.
defm cxx_enum_fixed_underlying_type : CXX11Compat<
- "enumeration types with a fixed underlying type are",
- /*ext_warn=*/false>;
+ "enumeration types with a fixed underlying type are">;
defm for_range : CXX11Compat<"range-based for loop is">;
defm scoped_enum : CXX11Compat<"scoped enumerations are">;
defm rvalue_reference : CXX11Compat<"rvalue references are">;
defm ref_qualifier : CXX11Compat<"reference qualifiers on functions are">;
defm generalized_initializer_lists : CXX11Compat<
- "generalized initializer lists are">;
-defm cxx11_attributes : CXX11Compat<"[[]] attributes are", /*ext_warn*/false>;
+ "generalized initializer lists are", /*ext_warn*/true>;
+defm cxx11_attributes : CXX11Compat<"[[]] attributes are">;
defm defaulted_deleted_function : CXX11Compat<
"%select{defaulted|deleted}0 function definitions are">;
defm nonstatic_member_init : CXX11Compat<
@@ -47,9 +46,9 @@ defm nonstatic_member_init : CXX11Compat<
defm alias_declaration : CXX11Compat<"alias declarations are">;
defm override_control_keyword : CXX11Compat<"'%0' keyword is">;
defm inline_namespace : CXX11Compat<"inline namespaces are">;
-defm extern_template : CXX11Compat<"extern templates are", /*ext_warn*/false>;
+defm extern_template : CXX11Compat<"extern templates are">;
defm cxx_enumerator_list_comma : CXX11Compat<
- "commas at the end of enumerator lists are", /*ext_warn*/false>;
+ "commas at the end of enumerator lists are">;
// C++14 compatibility with C++11 and earlier.
defm decltype_auto_type_specifier : CXX14Compat<
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 11028e276f0161..a0cf425f6540f5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -39,11 +39,10 @@ defm template_outside_of_template : CXX11Compat<
defm explicit_conversion_functions : CXX11Compat<
"explicit conversion functions are">;
defm cast_fn_obj : CXX11Compat<
- "cast between pointer-to-function and pointer-to-object is",
- /*ext_warn*/false>;
+ "cast between pointer-to-function and pointer-to-object is">;
defm array_size_conversion : CXX11Compat<
"implicit conversion from array size expression of type %0 to "
- "%select{integral|enumeration}1 type %2 is", /*ext_warn*/false>;
+ "%select{integral|enumeration}1 type %2 is">;
// C++14 compatibility with C++11 and earlier.
defm constexpr_type_definition : CXX14Compat<
diff --git a/clang/test/AST/ByteCode/cxx03.cpp b/clang/test/AST/ByteCode/cxx03.cpp
index 224e2e5d60ba71..a3bd64ed6a2b7a 100644
--- a/clang/test/AST/ByteCode/cxx03.cpp
+++ b/clang/test/AST/ByteCode/cxx03.cpp
@@ -51,8 +51,7 @@ const int s = S().w[1];
namespace NullRecord {
struct S {
int arr[1024 * 1024 * 1024];
- s = {1, {2}}; // both-error {{a type specifier is required for all declarations}} \
- // both-warning {{default member initializer for non-static data member is a C++11 extension}}
+ s = {1, {2}}; // both-error {{a type specifier is required for all declarations}}
};
S s[2] = {};
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
index 49ff4c7fa0ccfa..75c57772f1a8d5 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
@@ -73,9 +73,6 @@ void test3() {
namespace inline_ns {
int x; // expected-note 2{{found}}
inline namespace A {
-#if __cplusplus <= 199711L // C++03 or earlier
- // expected-warning at -2 {{inline namespaces are a C++11 extension}}
-#endif
int x; // expected-note 2{{found}}
int y; // expected-note 2{{found}}
diff --git a/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp b/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp
index 88b2ea3a9b7321..01de66787af081 100644
--- a/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp
+++ b/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp
@@ -1,14 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// expected-no-diagnostics
+
template<typename T>
class X0 {
friend T;
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2{{non-class friend type 'T' is a C++11 extension}}
-#else
- // expected-no-diagnostics
-#endif
};
class X1 { };
@@ -17,4 +15,3 @@ X0<X1> x0a;
X0<X1 *> x0b;
X0<int> x0c;
X0<E1> x0d;
-
diff --git a/clang/test/CXX/class/class.friend/p2.cpp b/clang/test/CXX/class/class.friend/p2.cpp
index e4a46b30e78881..f49185f4319ad9 100644
--- a/clang/test/CXX/class/class.friend/p2.cpp
+++ b/clang/test/CXX/class/class.friend/p2.cpp
@@ -7,9 +7,6 @@ struct B0;
class A {
friend class B {}; // expected-error {{cannot define a type in a friend declaration}}
friend int;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{non-class friend type 'int' is a C++11 extension}}
-#endif
friend B0;
#if __cplusplus <= 199711L
// expected-warning at -2 {{unelaborated friend declaration is a C++11 extension; specify 'struct' to befriend 'B0'}}
diff --git a/clang/test/CXX/class/class.union/p1.cpp b/clang/test/CXX/class/class.union/p1.cpp
index bf7f2ad24f98dc..8139a4f4399c9f 100644
--- a/clang/test/CXX/class/class.union/p1.cpp
+++ b/clang/test/CXX/class/class.union/p1.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
void abort() __attribute__((noreturn));
@@ -92,12 +92,12 @@ union U3 {
struct s7 : Okay {
} m7;
struct s8 {
- s8(...) = delete; // expected-note {{because it is a variadic function}} expected-warning {{C++11}}
+ s8(...) = delete; // expected-note {{because it is a variadic function}}
} m8; // expected-error {{union member 'm8' has a non-trivial default constructor}}
};
union U4 {
- static int i1; // expected-warning {{static data member 'i1' in union is a C++11 extension}}
+ static int i1;
};
int U4::i1 = 10;
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp
index 08b22c118685a9..d57c40fe55758a 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp
@@ -5,23 +5,17 @@
class A {
public:
explicit A();
-
+
explicit operator int();
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2 {{explicit conversion functions are a C++11 extension}}
-#endif
explicit void f0(); // expected-error {{'explicit' can only be applied to a constructor or conversion function}}
-
+
operator bool();
};
explicit A::A() { } // expected-error {{'explicit' can only be specified inside the class definition}}
explicit A::operator bool() { return false; }
-#if __cplusplus <= 199711L // C++03 or earlier modes
-// expected-warning at -2 {{explicit conversion functions are a C++11 extension}}
-#endif
-// expected-error at -4 {{'explicit' can only be specified inside the class definition}}
+// expected-error at -1 {{'explicit' can only be specified inside the class definition}}
class B {
friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}}
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
index 4b93d865c8b19b..d3941be82d50ad 100644
--- a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
@@ -63,9 +63,6 @@ namespace pointer_to_object_parameters {
A2<array_of_Xs> *a13;
A2<&an_X> *a13_2;
A2<(&an_X)> *a13_3;
-#if __cplusplus < 201103L
- // expected-warning at -2 {{parentheses around address non-type template argument are a C++11 extension}}
-#endif
// PR6244
struct X1 {} X1v;
diff --git a/clang/test/CXX/temp/temp.param/p9.cpp b/clang/test/CXX/temp/temp.param/p9.cpp
index b2318c275e44cb..77e4816bd44e36 100644
--- a/clang/test/CXX/temp/temp.param/p9.cpp
+++ b/clang/test/CXX/temp/temp.param/p9.cpp
@@ -2,10 +2,10 @@
// A default template-argument shall not be specified in a function
// template declaration or a function template definition
-template<typename T = int> // expected-warning{{default template arguments for a function template are a C++11 extension}}
- void foo0(T);
-template<typename T = int> // expected-warning{{default template arguments for a function template are a C++11 extension}}
- void foo1(T) { }
+template<typename T = int>
+ void foo0(T);
+template<typename T = int>
+ void foo1(T) { }
// [...] nor in the template-parameter-list of the definition of a
// member of a class template.
@@ -15,7 +15,7 @@ struct X0 {
};
template<int N = 0> // expected-error{{cannot add a default template argument}}
-void X0<N>::f() { }
+void X0<N>::f() { }
class X1 {
template<template<int> class TT = X0> // expected-error{{not permitted on a friend template}}
diff --git a/clang/test/Parser/cxx-ext-delete-default.cpp b/clang/test/Parser/cxx-ext-delete-default.cpp
index af8b6d6d34711e..58b3dfa82e06ea 100644
--- a/clang/test/Parser/cxx-ext-delete-default.cpp
+++ b/clang/test/Parser/cxx-ext-delete-default.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -Wc++11-extensions
struct A {
A(const A&) = delete; // expected-warning {{C++11 extension}}
diff --git a/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp
index a4492ba1a7ab94..398604a07996c5 100644
--- a/clang/test/Parser/cxx-friend.cpp
+++ b/clang/test/Parser/cxx-friend.cpp
@@ -20,7 +20,7 @@ union U {
};
class B {
- // 'A' here should refer to the declaration above.
+ // 'A' here should refer to the declaration above.
friend class A;
friend C;
@@ -34,9 +34,6 @@ class B {
#endif
friend int;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{non-class friend type 'int' is a C++11 extension}}
-#endif
friend void myfunc();
diff --git a/clang/test/Parser/cxx-reference.cpp b/clang/test/Parser/cxx-reference.cpp
index 58bd7ab607276e..977178e9554a3d 100644
--- a/clang/test/Parser/cxx-reference.cpp
+++ b/clang/test/Parser/cxx-reference.cpp
@@ -20,7 +20,4 @@ int & volatile Y = val; // expected-error {{'volatile' qualifier may not be appl
int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \
expected-error {{'volatile' qualifier may not be applied}} */
-typedef int && RV;
-#if __cplusplus <= 199711L
-// expected-warning at -2 {{rvalue references are a C++11 extension}}
-#endif
+typedef int && RV;
diff --git a/clang/test/Parser/cxx0x-in-cxx98.cpp b/clang/test/Parser/cxx0x-in-cxx98.cpp
index 90496df13b6558..01581dabef51e0 100644
--- a/clang/test/Parser/cxx0x-in-cxx98.cpp
+++ b/clang/test/Parser/cxx0x-in-cxx98.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s -Wc++11-extensions
inline namespace N { // expected-warning{{inline namespaces are a C++11 extension}}
struct X {
diff --git a/clang/test/SemaCXX/MicrosoftCompatibility.cpp b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
index b8cd22ad350a5e..0372b5d9ecfca5 100644
--- a/clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -89,7 +89,7 @@ void jump_over_var_with_dtor() {
}
}
-
+
void exception_jump() {
goto l2; // expected-error {{cannot jump}}
try { // expected-note {{jump bypasses initialization of try block}}
@@ -105,7 +105,7 @@ int jump_over_indirect_goto() {
a0:
return 0;
}
-
+
}
namespace PR11826 {
@@ -150,20 +150,20 @@ namespace PR11826_for_symmetry {
namespace ms_using_declaration_bug {
class A {
-public:
- int f();
+public:
+ int f();
};
class B : public A {
-private:
+private:
using A::f;
void g() {
f(); // no diagnostic
}
};
-class C : public B {
-private:
+class C : public B {
+private:
using B::f; // expected-warning {{using declaration referring to inaccessible member 'ms_using_declaration_bug::B::f' (which refers to accessible member 'ms_using_declaration_bug::A::f') is a Microsoft compatibility extension}}
};
@@ -238,7 +238,7 @@ template void function_missing_typename<D>(const D::Type param);
//MSVC allows forward enum declaration
enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-ENUM *var = 0;
+ENUM *var = 0;
ENUM var2 = (ENUM)0;
enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
diff --git a/clang/test/SemaCXX/PR10458.cpp b/clang/test/SemaCXX/PR10458.cpp
index 57588ebcf1f02a..ef56ae7df032c4 100644
--- a/clang/test/SemaCXX/PR10458.cpp
+++ b/clang/test/SemaCXX/PR10458.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wc++11-extensions
void f() {
int arr[] = { 1, 2, 3 };
diff --git a/clang/test/SemaCXX/PR9572.cpp b/clang/test/SemaCXX/PR9572.cpp
index d0ba32eb1ab101..d1da9a42cc5ea5 100644
--- a/clang/test/SemaCXX/PR9572.cpp
+++ b/clang/test/SemaCXX/PR9572.cpp
@@ -20,9 +20,6 @@ struct Foo : public Base {
#endif
const int kBlah = 3;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
-#endif
Foo();
};
diff --git a/clang/test/SemaCXX/addr-of-overloaded-function.cpp b/clang/test/SemaCXX/addr-of-overloaded-function.cpp
index 5568bec2b7910a..738ef7f2649be8 100644
--- a/clang/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/clang/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -82,9 +82,6 @@ struct C {
template<typename T1, typename T2>
void q4(); // expected-note{{possible target for call}}
template<typename T1 = int>
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2{{default template arguments for a function template are a C++11 extension}}
-#endif
void q5(); // expected-note{{possible target for call}}
void h() {
diff --git a/clang/test/SemaCXX/aggregate-init-cxx98.cpp b/clang/test/SemaCXX/aggregate-init-cxx98.cpp
index 332801f0822cb5..207ee76dc79c2b 100644
--- a/clang/test/SemaCXX/aggregate-init-cxx98.cpp
+++ b/clang/test/SemaCXX/aggregate-init-cxx98.cpp
@@ -1,7 +1,9 @@
// RUN: %clang_cc1 -std=c++98 -verify %s
+// expected-no-diagnostics
+
struct A {
- A() = default; // expected-warning {{C++11}}
+ A() = default;
int n;
};
A a = {0};
diff --git a/clang/test/SemaCXX/anonymous-struct.cpp b/clang/test/SemaCXX/anonymous-struct.cpp
index 7800434165cd77..07c8dbd5329297 100644
--- a/clang/test/SemaCXX/anonymous-struct.cpp
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -210,9 +210,7 @@ A GetA() {
namespace ForwardDeclaredMember {
struct A;
struct A {
- int x = 0;
- // cxx98-warning at -1 {{default member initializer for non-static data member is a C++11 extension}}
- // cxx98-note at -2 {{because field 'x' has an initializer}}
+ int x = 0; // cxx98-note {{because field 'x' has an initializer}}
};
struct B {
struct {
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp
index f1e02d5158aac5..e3dacf2ceacaa7 100644
--- a/clang/test/SemaCXX/class.cpp
+++ b/clang/test/SemaCXX/class.cpp
@@ -43,9 +43,6 @@ class C {
enum E1 { en1, en2 };
int i = 0;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{default member initializer for non-static data member is a C++11 extension}}
-#endif
static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
static const NestedC ci = 0; // expected-error {{static data member of type 'const NestedC' must be initialized out of line}}
static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}} \
@@ -170,7 +167,7 @@ namespace PR7153 {
public:
struct A { } mutable *member;
};
-
+
void f(const EnclosingClass &ec) {
ec.member = 0;
}
@@ -223,6 +220,6 @@ void f() {
}
}
-struct PR9989 {
- static int const PR9989_Member = sizeof PR9989_Member;
+struct PR9989 {
+ static int const PR9989_Member = sizeof PR9989_Member;
};
diff --git a/clang/test/SemaCXX/const-cast.cpp b/clang/test/SemaCXX/const-cast.cpp
index a9268660f1ea4b..3765322925b14d 100644
--- a/clang/test/SemaCXX/const-cast.cpp
+++ b/clang/test/SemaCXX/const-cast.cpp
@@ -41,9 +41,6 @@ char ***good_const_cast_test(ccvpcvpp var)
int const A::* const A::*icapcap = 0;
int A::* A::* iapap = const_cast<int A::* A::*>(icapcap);
(void)const_cast<A&&>(A());
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2 {{rvalue references are a C++11 extension}}
-#endif
return var4;
}
@@ -72,9 +69,6 @@ short *bad_const_cast_test(char const *volatile *const volatile *var)
void (A::*mfn)() = 0;
(void)const_cast<void (A::*)()>(mfn); // expected-error-re {{const_cast to 'void (A::*)(){{( __attribute__\(\(thiscall\)\))?}}', which is not a reference, pointer-to-object, or pointer-to-data-member}}
(void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}}
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2 {{rvalue references are a C++11 extension}}
-#endif
return **var3;
}
diff --git a/clang/test/SemaCXX/convert-to-bool.cpp b/clang/test/SemaCXX/convert-to-bool.cpp
index 94d994143922ec..ea8a0c006531f6 100644
--- a/clang/test/SemaCXX/convert-to-bool.cpp
+++ b/clang/test/SemaCXX/convert-to-bool.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
@@ -12,9 +12,6 @@ struct ConvToInt {
struct ExplicitConvToBool {
explicit operator bool(); // expected-note {{explicit}}
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2{{explicit conversion functions are a C++11 extension}}
-#endif
};
void test_conv_to_bool(ConvToBool ctb, ConvToInt cti, ExplicitConvToBool ecb) {
@@ -46,9 +43,6 @@ void accepts_bool(bool) { } // expected-note{{candidate function}}
struct ExplicitConvToRef {
explicit operator int&(); // expected-note {{explicit}}
-#if (__cplusplus <= 199711L) // C++03 or earlier modes
- // expected-warning at -2{{explicit conversion functions are a C++11 extension}}
-#endif
};
void test_explicit_bool(ExplicitConvToBool ecb) {
@@ -66,9 +60,6 @@ struct A { };
struct B { };
struct C {
explicit operator A&(); // expected-note {{explicit}}
-#if __cplusplus <= 199711L // C++03 or earlier modes
-// expected-warning at -2{{explicit conversion functions are a C++11 extension}}
-#endif
operator B&(); // expected-note{{candidate}}
};
diff --git a/clang/test/SemaCXX/copy-initialization.cpp b/clang/test/SemaCXX/copy-initialization.cpp
index 68ccc3014e8b67..098827cbff5196 100644
--- a/clang/test/SemaCXX/copy-initialization.cpp
+++ b/clang/test/SemaCXX/copy-initialization.cpp
@@ -63,9 +63,6 @@ namespace DR5 {
namespace Ex2 {
struct S {
S(S&&);
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2 {{rvalue references are a C++11 extension}}
-#endif
S(int);
};
const S a(0);
diff --git a/clang/test/SemaCXX/cxx0x-return-init-list.cpp b/clang/test/SemaCXX/cxx0x-return-init-list.cpp
index 2aeec7bff7c85f..fcee5b795cb8af 100644
--- a/clang/test/SemaCXX/cxx0x-return-init-list.cpp
+++ b/clang/test/SemaCXX/cxx0x-return-init-list.cpp
@@ -4,12 +4,12 @@
// required for libstdc++ 4.5) is supported in C++98.
int test0(int i) {
- return { i }; // expected-warning{{generalized initializer lists are a C++11 extension}} expected-warning {{scalar}}
+ return { i }; // expected-warning {{scalar}}
}
template<typename T, typename U>
T test1(U u) {
- return { u }; // expected-warning{{generalized initializer lists are a C++11 extension}}
+ return { u };
}
template int test1(char);
diff --git a/clang/test/SemaCXX/cxx11-compat.cpp b/clang/test/SemaCXX/cxx11-compat.cpp
index f17c900201f762..7f37c432d1e4c2 100644
--- a/clang/test/SemaCXX/cxx11-compat.cpp
+++ b/clang/test/SemaCXX/cxx11-compat.cpp
@@ -1,7 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat-pedantic -verify %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++11-compat-pedantic -verify %s
-
-#if __cplusplus < 201103L
namespace N {
template<typename T> void f(T) {} // expected-note 2{{here}}
@@ -41,36 +38,6 @@ void h(size_t foo, size_t bar) {
#define _x + 1
char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}}
-template<int ...N> int f() { // expected-warning {{C++11 extension}}
+template<int ...N> int f() {
return (N + ...); // expected-warning {{C++17 extension}}
}
-
-#else
-
-decltype(auto) x = 0; // expected-warning {{'decltype(auto)' type specifier is incompatible}}
-
-auto init_capture = [a(0)] {}; // expected-warning {{initialized lambda captures are incompatible with C++ standards before C++14}}
-
-auto generic_lambda =
- [](
- auto // expected-warning {{generic lambdas are incompatible}}
- *a) {};
-
-auto deduced_return_type(); // expected-warning {{incompatible with C++ standards before C++14}}
-auto *another_deduced_return_type(); // expected-warning {{incompatible with C++ standards before C++14}}
-decltype(auto) also_deduced_return_type(); // expected-warning {{return type deduction}} expected-warning {{'decltype(auto)' type specifier is incompatible}}
-int f();
-auto (*not_deduced_return_type)() = f;
-
-auto deduced_lambda_return_type = []() ->
- auto // expected-warning {{return type deduction is incompatible}}
-{};
-
-auto trailing_non_deduced_return_type() -> int;
-auto trailing_deduced_return_type() -> auto; // expected-warning {{incompatible with C++ standards before C++14}}
-
-struct A {
- operator auto(); // expected-warning {{return type deduction is incompatible}}
-};
-
-#endif
diff --git a/clang/test/SemaCXX/cxx14-compat.cpp b/clang/test/SemaCXX/cxx14-compat.cpp
index d6396a7de4df71..262e9954c1ca32 100644
--- a/clang/test/SemaCXX/cxx14-compat.cpp
+++ b/clang/test/SemaCXX/cxx14-compat.cpp
@@ -31,4 +31,10 @@ template<typename T> void g(T t) {
struct A { template<typename T> struct X { X(T); }; };
void h(A a) { g(a); } // expected-note {{in instantiation of}}
+template<class T> struct CTAD {};
+void ctad_test() {
+ CTAD<int> s;
+ CTAD t = s; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}}
+}
+
#endif
diff --git a/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp b/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
index 20922f2fdaa4f4..b4ddcfd5d3809a 100644
--- a/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ b/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -85,7 +85,7 @@ namespace ns3 {
//expected-note at -7{{subexpression not valid in a constant expression}}
//expected-note at -6{{in call to}}
#endif
-}
+}
} // end ns test_constexpr_call
@@ -95,7 +95,7 @@ void f() {
auto L = [] { return c; };
constexpr char C = L();
}
-
+
void f(char c) { //expected-note{{declared here}}
auto L = [] { return c; }; //expected-error{{cannot be implicitly captured}} expected-note{{lambda expression begins here}} expected-note 2 {{capture 'c' by}} expected-note 2 {{default capture by}}
int I = L();
@@ -122,7 +122,7 @@ static_assert(fp4(Str) == Str);
auto NCL = [](int i) { static int j; return j; }; //expected-note{{declared here}}
constexpr int (*fp5)(int) = NCL;
constexpr int I = //expected-error{{must be initialized by a constant expression}}
- fp5(5); //expected-note{{non-constexpr function}}
+ fp5(5); //expected-note{{non-constexpr function}}
namespace test_dont_always_instantiate_constexpr_templates {
@@ -133,7 +133,7 @@ auto deduced_return_type = [](auto x) { return x.get(); }; //expected-error{{not
decltype(deduced_return_type(0)) d; //expected-note{{requested here}}
-
+
} // end ns test_dont_always_instantiate_constexpr_templates
} // end ns1
@@ -145,7 +145,7 @@ namespace ns1_simple_lambda {
namespace ns0 {
constexpr int I = [](auto a) { return a; }(10);
-static_assert(I == 10);
+static_assert(I == 10);
static_assert(10 == [](auto a) { return a; }(10));
static_assert(3.14 == [](auto a) { return a; }(3.14));
@@ -154,9 +154,9 @@ static_assert(3.14 == [](auto a) { return a; }(3.14));
namespace ns1 {
constexpr auto f(int i) {
double d = 3.14;
- auto L = [=](auto a) {
+ auto L = [=](auto a) {
int Isz = sizeof(i);
- return sizeof(i) + sizeof(a) + sizeof(d);
+ return sizeof(i) + sizeof(a) + sizeof(d);
};
int I = L("abc") + L(nullptr);
return L;
@@ -184,14 +184,14 @@ constexpr auto f(int i) {
auto L = [=](auto a) {
int Isz = sizeof(i);
asm("hello");
- return sizeof(i) + sizeof(a) + sizeof(d);
+ return sizeof(i) + sizeof(a) + sizeof(d);
};
return L;
}
constexpr auto L = f(3);
-constexpr auto M = // expected-error{{must be initialized by}}
+constexpr auto M = // expected-error{{must be initialized by}}
L("abc");
#if __cpp_constexpr < 201907L
//expected-note at -2{{non-constexpr function}}
@@ -210,12 +210,12 @@ namespace test_captures_1 {
namespace ns1 {
constexpr auto f(int i) {
struct S { int x; } s = { i * 2 };
- auto L = [=](auto a) {
+ auto L = [=](auto a) {
return i + s.x + a;
};
return L;
}
-constexpr auto M = f(3);
+constexpr auto M = f(3);
static_assert(M(10) == 19);
@@ -233,7 +233,7 @@ constexpr auto foo(int n) {
auto M = L([n](int p) { return p == n; });
M(); M();
L([n](int p) { return p == n + 2; });
-
+
return L;
}
@@ -254,7 +254,7 @@ constexpr auto foo(int n) {
auto M = L([n](int p) { return p == n; });
M()(); M()();
L([n](int p) { return p == n; });
-
+
return L;
}
@@ -315,7 +315,7 @@ namespace ns1_test_lvalue_type {
volatile int n;
constexpr bool B = [&]{ return &n; }() == &n; // should be accepted
}
-} // end ns1_unimplemented
+} // end ns1_unimplemented
} // end ns test_lambda_is_cce
diff --git a/clang/test/SemaCXX/cxx20-compat.cpp b/clang/test/SemaCXX/cxx20-compat.cpp
new file mode 100644
index 00000000000000..e0dae34a412584
--- /dev/null
+++ b/clang/test/SemaCXX/cxx20-compat.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wpre-c++20-compat-pedantic -verify %s
+
+namespace GH161702 {
+struct S {
+ enum E { A };
+ using E::A; // expected-warning {{member using declaration naming non-class ''E'' enumerator is incompatible with C++ standards before C++20}}
+};
+}
diff --git a/clang/test/SemaCXX/cxx2d-defaulted-postfix-operators.cpp b/clang/test/SemaCXX/cxx2d-defaulted-postfix-operators.cpp
index 618a0ff955fa6a..24b8ffc967faf8 100644
--- a/clang/test/SemaCXX/cxx2d-defaulted-postfix-operators.cpp
+++ b/clang/test/SemaCXX/cxx2d-defaulted-postfix-operators.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -std=c++03 -verify=expected,cxx03,pre14,pre20,pre23,pre2d %s
-// RUN: %clang_cc1 -std=c++11 -verify=expected,pre14,pre20,pre23,pre2d %s
-// RUN: %clang_cc1 -std=c++14 -verify=expected,pre20,pre23,pre2d %s
-// RUN: %clang_cc1 -std=c++17 -verify=expected,pre20,pre23,pre2d %s
-// RUN: %clang_cc1 -std=c++20 -verify=expected,cxx20,pre23,pre2d %s
+// RUN: %clang_cc1 -std=c++03 -verify=expected,pre20,pre2d %s
+// RUN: %clang_cc1 -std=c++11 -verify=expected,pre20,pre2d %s
+// RUN: %clang_cc1 -std=c++14 -verify=expected,pre20,pre2d %s
+// RUN: %clang_cc1 -std=c++17 -verify=expected,pre20,pre2d %s
+// RUN: %clang_cc1 -std=c++20 -verify=expected,cxx20,pre2d %s
// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20,pre2d %s
// RUN: %clang_cc1 -std=c++26 -verify=expected,cxx20,pre2d %s
// RUN: %clang_cc1 -std=c++2d -verify=expected,cxx2d %s
@@ -18,11 +18,9 @@ struct S {
S operator++(int) = default;
// pre2d-warning at -1 {{defaulted postfix increment and decrement operators are a C++2d extension}}
// compat-warning at -2 {{defaulted postfix increment and decrement operators are incompatible with C++ standards before C++2d}}
- // cxx03-warning at -3 {{defaulted function definitions are a C++11 extension}}
S operator--(int) = default;
// pre2d-warning at -1 {{defaulted postfix increment and decrement operators are a C++2d extension}}
// compat-warning at -2 {{defaulted postfix increment and decrement operators are incompatible with C++ standards before C++2d}}
- // cxx03-warning at -3 {{defaulted function definitions are a C++11 extension}}
};
void use_s(S s) {
s++;
@@ -35,7 +33,6 @@ struct N {
N operator++(N &, int) = default;
// pre2d-warning at -1 {{defaulted postfix increment and decrement operators are a C++2d extension}}
// compat-warning at -2 {{defaulted postfix increment and decrement operators are incompatible with C++ standards before C++2d}}
-// cxx03-warning at -3 {{defaulted function definitions are a C++11 extension}}
void use_n(N n) { n++; }
// The warning is produced once for a class template, not again for each
@@ -46,7 +43,6 @@ template <typename T> struct W {
W operator++(int) = default;
// pre2d-warning at -1 {{defaulted postfix increment and decrement operators are a C++2d extension}}
// compat-warning at -2 {{defaulted postfix increment and decrement operators are incompatible with C++ standards before C++2d}}
- // cxx03-warning at -3 {{defaulted function definitions are a C++11 extension}}
};
void use_w(W<int> w, W<long> x) {
w++;
@@ -59,10 +55,8 @@ struct Other {
// pre20-error at -1 {{only special member functions may be defaulted}}
// cxx20-error at -2 {{only special member functions and comparison operators may be defaulted}}
// cxx2d-error at -3 {{only special member functions, comparison operators, and postfix increment and decrement operators may be defaulted}}
- // cxx03-warning at -4 {{defaulted function definitions are a C++11 extension}}
Other &operator++() = default;
// expected-error at -1 {{only the postfix form of 'operator++' can be defaulted}}
- // cxx03-warning at -2 {{defaulted function definitions are a C++11 extension}}
};
// An implicitly deleted defaulted postfix operator.
@@ -74,7 +68,6 @@ struct Deleted {
// expected-note@#Deleted {{explicitly defaulted function was implicitly deleted here}}
// pre2d-warning@#Deleted {{defaulted postfix increment and decrement operators are a C++2d extension}}
// compat-warning@#Deleted {{defaulted postfix increment and decrement operators are incompatible with C++ standards before C++2d}}
- // cxx03-warning@#Deleted {{defaulted function definitions are a C++11 extension}}
};
void use_deleted(Deleted d) {
d++; // expected-error {{object of type 'Deleted' cannot be incremented because its defaulted postfix increment operator is implicitly deleted}}
diff --git a/clang/test/SemaCXX/cxx98-compat-pedantic.cpp b/clang/test/SemaCXX/cxx98-compat-pedantic.cpp
deleted file mode 100644
index 328ca2b074b590..00000000000000
--- a/clang/test/SemaCXX/cxx98-compat-pedantic.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s -DCXX1Y2
-// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98
-
-// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-pre-c++14-compat-pedantic -DCXX1Y2
-
-// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
-// warning in C++98 mode.
-
-#line 32767 // ok
-#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
-
-#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
-VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}
-
-; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
-
-enum Enum {
- Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
-};
-
-enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}}
-};
-
-void *dlsym();
-void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
-void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
-
-struct ConvertToInt {
- operator int();
-};
-int *ArraySizeConversion = new int[ConvertToInt()];
-#ifdef CXX1Y2
-// expected-warning at -2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
-#else
-// expected-warning at -4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
-#endif
-
-template<typename T> class ExternTemplate {};
-extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
-
-long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
- -42LL; // expected-warning {{'long long' is incompatible with C++98}}
-unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
- 42ULL; // expected-warning {{'long long' is incompatible with C++98}}
-
-int k = 0b1001;
-#ifdef CXX1Y
-// expected-warning at -2 {{binary integer literals are incompatible with C++ standards before C++14}}
-#endif
-
-namespace CopyCtorIssues {
- struct Private {
- Private();
- private:
- Private(const Private&); // expected-note {{declared private here}}
- };
- struct NoViable {
- NoViable(); // expected-note {{not viable}}
- NoViable(NoViable&); // expected-note {{not viable}}
- };
- struct Ambiguous {
- Ambiguous();
- Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
- Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
- };
- struct Deleted {
- Private p; // expected-note {{implicitly deleted}}
- };
-
- const Private &a = Private(); // expected-warning {{copying variable of type 'Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
- const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
-#if !CXX98
- const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
-#endif
- const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
-}
-
-int with_attribute [[ ]]; // expected-warning {{[[]] attributes are incompatible with C++98}}
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
index 3034de07e66896..2807cba6d74d8d 100644
--- a/clang/test/SemaCXX/cxx98-compat.cpp
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -1,11 +1,27 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify=expected,not-cpp20 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify=expected,not-cpp20 %s -DCXX14COMPAT
-// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-compat -verify=expected,not-cpp20 %s -DCXX14COMPAT -DCXX17COMPAT
-// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++98-compat -verify=expected,cpp20 %s -DCXX14COMPAT -DCXX17COMPAT
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Wno-c++14-extensions -verify=expected,compat,until-cxx14 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -Wno-pre-c++14-compat-pedantic -verify=expected,compat,until-cxx14 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-compat -Wno-pre-c++14-compat-pedantic -verify=expected,compat %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++98-compat -Wno-pre-c++14-compat-pedantic -verify=expected,compat %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wc++98-compat -Wno-pre-c++14-compat-pedantic -verify=expected,compat %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++26 -Wc++98-compat -Wno-pre-c++14-compat-pedantic -verify=expected,compat %s
+
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -Wno-c++14-extensions -verify=expected,compat,pedantic,pedantic-until-cxx14,pedantic-cxx11,until-cxx14 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat-pedantic -Wno-pre-c++14-compat-pedantic -verify=expected,compat,pedantic,pedantic-until-cxx14,until-cxx14 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-compat-pedantic -Wno-pre-c++14-compat-pedantic -verify=expected,compat,pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++98-compat-pedantic -Wno-pre-c++14-compat-pedantic -verify=expected,compat,pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++23 -Wc++98-compat-pedantic -Wno-pre-c++14-compat-pedantic -verify=expected,compat,pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++26 -Wc++98-compat-pedantic -Wno-pre-c++14-compat-pedantic -verify=expected,compat,pedantic %s
+
+// Make sure that non-pedantic warnings are actually errors in C++03
+// RUN: %clang_cc1 -fsyntax-only -std=c++03 -verify=expected,cxx03 %s
+
+// FIXME: This test shows a few bugs:
+// - Most places matching the regex 'compat-warning[^\n]*\n^((?!cxx03-error)[^\n])*\n': The warning should be pedantic
+// - The 'pedantic-until-cxx14' 'until-cxx14' verify flags: The warning should be in all standards modes
namespace std {
struct type_info;
- using size_t = decltype(sizeof(0)); // expected-warning {{decltype}} expected-warning {{alias}}
+ using size_t = __decltype(sizeof(0)); // pedantic-warning {{alias}}
template<typename T> struct initializer_list {
initializer_list(const T*, size_t);
const T *p;
@@ -17,49 +33,61 @@ namespace std {
void test_other_auto_spellings() {
__auto_type x = 0; // Ok
- decltype(auto) y = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}}
-#ifndef CXX14COMPAT
- // expected-warning at -2 {{'decltype(auto)' type specifier is a C++14 extension}}
-#else
- // expected-warning at -4 {{'decltype(auto)' type specifier is incompatible with C++ standards before C++14}}
-#endif
+ decltype(auto) y = 0; // compat-warning {{'decltype' type specifier is incompatible with C++98}} \
+ // cxx03-error 2 {{expected}} cxx03-error {{use of undeclared identifier}} \
+ // cxx03-warning {{'auto' type specifier is a C++11 extension}}
}
-template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}}
+template<typename ...T> // pedantic-warning {{variadic templates are incompatible with C++98}}
class Variadic1 {};
-template<template<typename> class ...T> // expected-warning {{variadic templates are incompatible with C++98}}
+template<template<typename> class ...T> // pedantic-warning {{variadic templates are incompatible with C++98}}
class Variadic2 {};
-template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}}
+template<int ...I> // pedantic-warning {{variadic templates are incompatible with C++98}}
class Variadic3 {};
-alignas(8) int with_alignas; // expected-warning {{'alignas' is incompatible with C++98}}
+alignas(8) int with_alignas; // compat-warning {{'alignas' is incompatible with C++98}} \
+ // cxx03-error {{a type specifier}} cxx03-error {{expected}}
void Literals() {
- (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}}
- (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}}
- (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}}
- (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}}
- (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}}
-
- (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
- (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
- (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
- (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
- (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
+ (void)u8"str"; // compat-warning {{unicode literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)u"str"; // compat-warning {{unicode literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)U"str"; // compat-warning {{unicode literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)u'x'; // compat-warning {{unicode literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)U'x'; // compat-warning {{unicode literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+
+ (void)u8R"X(str)X"; // compat-warning {{raw string literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)uR"X(str)X"; // compat-warning {{raw string literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)UR"X(str)X"; // compat-warning {{raw string literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)R"X(str)X"; // compat-warning {{raw string literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
+ (void)LR"X(str)X"; // compat-warning {{raw string literals are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier}}
}
template<typename T> struct S {};
namespace TemplateParsing {
- S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}}
- S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}}
+ S<::S<void> > s; // compat-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}} \
+ // cxx03-error {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ S< ::S<void>> t; // compat-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}} \
+ // cxx03-error {{a space is required between consecutive right angle brackets (use '> >')}}
}
void Lambda() {
- []{}(); // expected-warning {{lambda expressions are incompatible with C++98}}
+ []{}(); // compat-warning {{lambda expressions are incompatible with C++98}} \
+ // cxx03-warning {{lambdas are a C++11 extension}}
// Don't warn about implicit "-> auto" here.
- [](){}(); // expected-warning {{lambda expressions are incompatible with C++98}}
+ [](){}(); // compat-warning {{lambda expressions are incompatible with C++98}} \
+ // cxx03-warning {{lambdas are a C++11 extension}}
}
struct Ctor {
@@ -70,136 +98,184 @@ struct InitListCtor {
InitListCtor(std::initializer_list<bool>);
};
-int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \
- // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
- (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
- // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
- (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
- // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
- int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+int InitList(int i = {}) { // compat-warning {{generalized initializer lists are incompatible with C++98}} \
+ // compat-warning {{scalar initialized from empty initializer list is incompatible with C++98}} \
+ // cxx03-error {{expected expression}}
+ (void)new int {}; // compat-warning {{generalized initializer lists are incompatible with C++98}} \
+ // compat-warning {{scalar initialized from empty initializer list is incompatible with C++98}} \
+ // cxx03-error {{expected}}
+ (void)int{}; // compat-warning {{generalized initializer lists are incompatible with C++98}} \
+ // compat-warning {{scalar initialized from empty initializer list is incompatible with C++98}} \
+ // cxx03-error {{expected}}
+ int x { 0 }; // compat-warning {{generalized initializer lists are incompatible with C++98}} \
+ // cxx03-error {{expected}}
S<int> s = {}; // ok, aggregate
- s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
- std::initializer_list<int> xs = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}}
- auto ys = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} \
- // expected-warning {{'auto' type specifier is incompatible with C++98}}
- Ctor c1 = { 1, 2 }; // expected-warning {{constructor call from initializer list is incompatible with C++98}}
- Ctor c2 = { 3.0, 4l }; // expected-warning {{constructor call from initializer list is incompatible with C++98}}
- InitListCtor ilc = { true, false }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}}
- const int &r = { 0 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}}
- struct { int a; const int &r; } rr = { 0, {0} }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}}
- return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} expected-warning {{scalar}}
+ s = {}; // compat-warning {{generalized initializer lists are incompatible with C++98}} \
+ // cxx03-error {{expected expression}}
+ std::initializer_list<int> xs = { 1, 2, 3 }; // compat-warning {{initialization of initializer_list object is incompatible with C++98}} \
+ // cxx03-error {{cannot be initialized}}
+
+ auto ys = { 1, 2, 3 }; // compat-warning {{initialization of initializer_list object is incompatible with C++98}} \
+ // cxx03-error {{cannot be initialized}} \
+ // compat-warning {{'auto' type specifier is incompatible with C++98}} \
+ // cxx03-warning {{'auto' type specifier is a C++11 extension}}
+
+ Ctor c1 = { 1, 2 }; // compat-warning {{constructor call from initializer list is incompatible with C++98}} \
+ // cxx03-error {{cannot be initialized}}
+
+ Ctor c2 = { 3.0, 4l }; // compat-warning {{constructor call from initializer list is incompatible with C++98}} \
+ // cxx03-error {{cannot be initialized}}
+
+ InitListCtor ilc = { true, false }; // compat-warning {{initialization of initializer_list object is incompatible with C++98}} \
+ // cxx03-error {{cannot be initialized}}
+
+ const int &r = { 0 }; // compat-warning {{reference initialized from initializer list is incompatible with C++98}} \
+ // cxx03-error {{cannot bind}}
+ struct { int a; const int &r; } rr = { 0, {0} }; // compat-warning {{reference initialized from initializer list is incompatible with C++98}} \
+ // cxx03-error {{initialization of non-aggregate type}}
+
+ return { 0 }; // compat-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar}} \
+ // cxx03-warning {{generalized initializer lists are a C++11 extension}}
}
struct DelayedDefaultArgumentParseInitList {
- void f(int i = {1}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} expected-warning {{scalar}}
+ void f(int i = {1}) { // compat-warning {{generalized initializer lists are incompatible with C++98}} compat-warning {{scalar}} \
+ // cxx03-error {{expected expression}}
}
};
-int operator""_hello(const char *); // expected-warning {{literal operators are incompatible with C++98}}
+int operator""_hello(const char *); // compat-warning {{literal operators are incompatible with C++98}} \
+ // cxx03-error {{expected a type}}
-enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}}
+enum class EnumScoped { // pedantic-warning {{scoped enumerations are incompatible with C++98}}
};
-void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}}
+void Deleted() = delete; // pedantic-warning {{deleted function definitions are incompatible with C++98}}
struct Defaulted {
- Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}}
+ Defaulted() = default; // pedantic-warning {{defaulted function definitions are incompatible with C++98}}
};
-int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}}
+int &&RvalueReference = 0; // pedantic-warning {{rvalue references are incompatible with C++98}}
struct RefQualifier {
- void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}}
+ void f() &; // pedantic-warning {{reference qualifiers on functions are incompatible with C++98}}
};
-auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
-#ifdef CXX14COMPAT
-auto ff() { return 5; } // expected-warning {{'auto' type specifier is incompatible with C++98}}
-// expected-warning at -1 {{return type deduction is incompatible with C++ standards before C++14}}
-#endif
+auto f() -> int; // compat-warning {{trailing return types are incompatible with C++98}} \
+ // cxx03-error {{expected function body after function declarator}} \
+ // cxx03-warning {{'auto' type specifier is a C++11 extension}}
void RangeFor() {
int xs[] = {1, 2, 3};
- for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}}
+ for (int &a : xs) { // pedantic-warning {{range-based for loop is incompatible with C++98}}
}
for (auto &b : {1, 2, 3}) {
- // expected-warning at -1 {{range-based for loop is incompatible with C++98}}
- // expected-warning at -2 {{'auto' type specifier is incompatible with C++98}}
- // expected-warning at -3 {{initialization of initializer_list object is incompatible with C++98}}
- // expected-warning at -4 {{reference initialized from initializer list is incompatible with C++98}}
+ // pedantic-warning at -1 {{range-based for loop is incompatible with C++98}}
+ // compat-warning at -2 {{'auto' type specifier is incompatible with C++98}}
+ // compat-warning at -3 {{initialization of initializer_list object is incompatible with C++98}}
+ // cxx03-error at -4 {{reference to type 'std::initializer_list<int>' cannot bind to an initializer list}}
+ // compat-warning at -5 {{reference initialized from initializer list is incompatible with C++98}}
+ // cxx03-error at -6 {{invalid range expression}}
+ // cxx03-warning at -7 {{'auto' type specifier is a C++11 extension}}
}
- struct Agg { int a, b; } const &agg = { 1, 2 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}}
+ struct Agg { int a, b; } const &agg = { 1, 2 }; // compat-warning {{reference initialized from initializer list is incompatible with C++98}} \
+ // cxx03-error {{cannot bind to an initializer list}}
}
struct InClassInit {
- int n = 0; // expected-warning {{default member initializer for non-static data member is incompatible with C++98}}
+ int n = 0; // pedantic-warning {{default member initializer for non-static data member is incompatible with C++98}}
};
struct OverrideControlBase {
virtual void f();
virtual void g();
};
-struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}}
- virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}}
- virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}}
+struct OverrideControl final : OverrideControlBase { // pedantic-warning {{'final' keyword is incompatible with C++98}}
+ virtual void f() override; // pedantic-warning {{'override' keyword is incompatible with C++98}}
+ virtual void g() final; // pedantic-warning {{'final' keyword is incompatible with C++98}}
};
-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}}
+using AliasDecl = int; // pedantic-warning {{alias declarations are incompatible with C++98}}
+template<typename T> using AliasTemplate = T; // pedantic-warning {{alias declarations are incompatible with C++98}}
-inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}}
+inline namespace InlineNS { // pedantic-warning {{inline namespaces are incompatible with C++98}}
}
-auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}}
-int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}}
+auto auto_deduction = 0; // compat-warning {{'auto' type specifier is incompatible with C++98}} \
+ // cxx03-warning {{'auto' type specifier is a C++11 extension}}
+int *p = new auto(0); // compat-warning {{'auto' type specifier is incompatible with C++98}} \
+ // cxx03-warning 2 {{'auto' type specifier is a C++11 extension}}
+
+const int align_of = alignof(int); // compat-warning {{alignof expressions are incompatible with C++98}} \
+ // cxx03-error {{expected}}
+
+char16_t c16 = 0; // compat-warning {{'char16_t' type specifier is incompatible with C++98}} \
+ // cxx03-error {{unknown type name}}
+
+char32_t c32 = 0; // compat-warning {{'char32_t' type specifier is incompatible with C++98}} \
+ // cxx03-error {{unknown type name}}
+
+constexpr int const_expr = 0; // compat-warning {{'constexpr' specifier is incompatible with C++98}} \
+ // cxx03-error {{unknown type name}}
+
+decltype(const_expr) decl_type = 0; // compat-warning {{'decltype' type specifier is incompatible with C++98}} \
+ // cxx03-error {{unknown type name}} cxx03-error {{expected}}
-const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}}
-char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}}
-char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}}
-constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}}
-decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}}
__decltype(const_expr) decl_type2 = 0; // ok
-void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}}
-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}}
+
+void no_except() noexcept; // compat-warning {{noexcept specifications are incompatible with C++98}} \
+ // cxx03-error {{expected}}
+
+bool no_except_expr = noexcept(1 + 1); // compat-warning {{noexcept expressions are incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier 'noexcept'}}
+
+void *null = nullptr; // compat-warning {{'nullptr' is incompatible with C++98}} \
+ // cxx03-error {{undeclared identifier 'nullptr'}}
+
+static_assert(true, "!"); // compat-warning {{'static_assert' declarations are incompatible with C++98}} \
+ // cxx03-error {{a type specifier}}
struct InhCtorBase {
InhCtorBase(int);
};
struct InhCtorDerived : InhCtorBase {
- using InhCtorBase::InhCtorBase; // expected-warning {{inheriting constructors are incompatible with C++98}}
+ using InhCtorBase::InhCtorBase; // compat-warning {{inheriting constructors are incompatible with C++98}} \
+ // cxx03-error {{using declaration cannot refer to a constructor}}
};
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}}
+ friend void FriendMember::MemberFn(); // compat-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}} \
+ // cxx03-error {{friends cannot be members of the declaring class}}
};
struct DelegCtor {
- DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}}
+ DelegCtor(int) : DelegCtor() {} // compat-warning {{delegating constructors are incompatible with C++98}} \
+ // cxx03-error {{delegating constructors are permitted only in C++11}}
DelegCtor();
};
-template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}}
+template<int n = 0> void DefaultFuncTemplateArg(); // pedantic-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}}
- // expected-note at -1 {{while substituting deduced template arguments}}
+ TemplateFn(S()); // compat-warning {{local type 'S' as template argument is incompatible with C++98}} \
+ // cxx03-warning {{template argument uses local type 'S'}} \
+ // expected-note {{while substituting deduced template arguments}}
}
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}}
- // expected-note at -1 {{while substituting deduced template arguments}}
+int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // compat-warning {{unnamed type as template argument is incompatible with C++98}} \
+ // cxx03-warning {{template argument uses unnamed type}} \
+ // expected-note {{while substituting deduced template arguments}}
// FIXME: We do not implement C++98 compatibility warnings for the C++17
// template argument evaluation rules.
-#ifndef CXX17COMPAT
namespace RedundantParensInAddressTemplateParam {
int n;
template<int*p> struct S {};
- S<(&n)> s; // expected-warning {{parentheses around address non-type template argument are incompatible with C++98}}
- S<(((&n)))> t; // expected-warning {{parentheses around address non-type template argument are incompatible with C++98}}
+ S<(&n)> s; // pedantic-until-cxx14-warning {{parentheses around address non-type template argument are incompatible with C++98}}
+ S<(((&n)))> t; // pedantic-until-cxx14-warning {{parentheses around address non-type template argument are incompatible with C++98}}
}
-#endif
namespace TemplateSpecOutOfScopeNs {
template<typename T> struct S {};
@@ -209,8 +285,8 @@ template<> struct TemplateSpecOutOfScopeNs::S<char> {};
struct Typename {
template<typename T> struct Inner {};
};
-typename ::Typename TypenameOutsideTemplate(); // expected-warning {{'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}}
+typename ::Typename TypenameOutsideTemplate(); // pedantic-warning {{'typename' outside of a template is incompatible with C++98}}
+Typename::template Inner<int> TemplateOutsideTemplate(); // pedantic-warning {{use of 'template' keyword outside of a template is incompatible with C++98}}
struct TrivialButNonPOD {
int f(int);
@@ -219,32 +295,40 @@ struct TrivialButNonPOD {
};
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}}
+ Ellipsis(1, TrivialButNonPOD()); // compat-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}} \
+ // cxx03-error {{cannot pass object of non-POD type 'TrivialButNonPOD' through variadic function; call will abort at runtime}}
}
struct HasExplicitConversion {
- explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
+ explicit operator bool(); // pedantic-warning {{explicit conversion functions are incompatible with C++98}}
};
struct Struct {};
-enum Enum { enum_val = 0 };
+enum Enum {
+ enum_val = 0, // pedantic-warning {{commas at the end of enumerator lists are incompatible with C++98}}
+};
struct BadFriends {
- friend enum ::Enum; // expected-warning {{elaborated enum specifier cannot be declared as a friend}}
- // expected-note at -1 {{remove 'enum' to befriend an enum}}
- friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}}
- friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}}
+ friend enum ::Enum; // compat-warning {{elaborated enum specifier cannot be declared as a friend}} \
+ // cxx03-warning {{elaborated enum specifier cannot be declared as a friend}} \
+ // expected-note {{remove 'enum' to befriend an enum}}
+ friend int; // pedantic-warning {{non-class friend type 'int' is incompatible with C++98}}
+ friend Struct; // compat-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}} \
+ // cxx03-warning {{unelaborated friend declaration is a C++11 extension; specify 'struct' to befriend 'Struct'}}
};
-int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+int n = {}; // compat-warning {{scalar initialized from empty initializer list is incompatible with C++98}} \
+ // cxx03-error {{scalar initializer cannot be empty}}
class PrivateMember {
- struct ImPrivate {};
+ struct ImPrivate {}; // cxx03-note {{implicitly declared private here}}
};
-template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}}
- return typename T::ImPrivate();
+template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // compat-warning {{substitution failure due to access control is incompatible with C++98}} \
+ // cxx03-error {{'ImPrivate' is a private member of 'PrivateMember'}}
+ return typename T::ImPrivate(); // cxx03-error {{'ImPrivate' is a private member of 'PrivateMember'}}
}
int SFINAEAccessControl(...) { return 0; }
-int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); // expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
+int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); // expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}} \
+ // cxx03-error {{no viable conversion}} cxx03-note {{in instantiation}}
namespace UnionOrAnonStructMembers {
struct NonTrivCtor {
@@ -257,43 +341,60 @@ namespace UnionOrAnonStructMembers {
~NonTrivDtor(); // expected-note 2{{user-provided destructor}}
};
union BadUnion {
- NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial default constructor is incompatible with C++98}}
- NonTrivCopy ntcp; // expected-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
- NonTrivDtor ntd; // expected-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}}
+ NonTrivCtor ntc; // compat-warning {{union member 'ntc' with a non-trivial default constructor is incompatible with C++98}} \
+ // cxx03-error {{non-trivial default constructor}}
+ NonTrivCopy ntcp; // compat-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}} \
+ // cxx03-error {{non-trivial copy constructor}}
+ NonTrivDtor ntd; // compat-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}} \
+ // cxx03-error {{non-trivial destructor}}
};
struct Wrap {
struct {
- NonTrivCtor ntc; // expected-warning {{anonymous struct member 'ntc' with a non-trivial default constructor is incompatible with C++98}}
- NonTrivCopy ntcp; // expected-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
- NonTrivDtor ntd; // expected-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}}
+ NonTrivCtor ntc; // compat-warning {{anonymous struct member 'ntc' with a non-trivial default constructor is incompatible with C++98}} \
+ // cxx03-error {{non-trivial default constructor}}
+ NonTrivCopy ntcp; // compat-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}} \
+ // cxx03-error {{non-trivial copy constructor}}
+ NonTrivDtor ntd; // compat-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}} \
+ // cxx03-error {{non-trivial destructor}}
};
};
union WithStaticDataMember {
- static constexpr double d = 0.0; // expected-warning {{static data member 'd' in union is incompatible with C++98}} expected-warning {{'constexpr' specifier is incompatible with C++98}}
- static const int n = 0; // expected-warning {{static data member 'n' in union is incompatible with C++98}}
- static int k; // expected-warning {{static data member 'k' in union is incompatible with C++98}}
+ static constexpr double d = 0.0; // pedantic-warning {{static data member 'd' in union is incompatible with C++98}} \
+ // compat-warning {{'constexpr' specifier is incompatible with C++98}} \
+ // cxx03-error {{unknown type name 'constexpr'}}
+ static const int n = 0; // pedantic-warning {{static data member 'n' in union is incompatible with C++98}}
+ static int k; // pedantic-warning {{static data member 'k' in union is incompatible with C++98}}
};
}
-int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+int EnumNNS = Enum::enum_val; // compat-warning {{enumeration type in nested name specifier is incompatible with C++98}} \
+ // cxx03-warning {{use of enumeration in a nested name specifier is a C++11 extension}}
template<typename T> void EnumNNSFn() {
- int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
-};
+ int k = T::enum_val; // compat-warning {{enumeration type in nested name specifier is incompatible with C++98}} \
+ // cxx03-error {{type 'Enum' cannot be used prior to '::' because it has no members}}
+}
template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
void JumpDiagnostics(int n) {
- goto DirectJump; // expected-warning {{jump from this goto statement to its label is incompatible with C++98}}
+ goto DirectJump; // compat-warning {{jump from this goto statement to its label is incompatible with C++98}} \
+ // cxx03-error {{cannot jump from this goto statement to its label}}
TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
DirectJump:
void *Table[] = {&&DirectJump, &&Later};
- goto *Table[n]; // expected-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++98}}
+ goto *Table[n]; // compat-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++98}} \
+ // cxx03-error {{cannot jump from this indirect goto statement to one of its possible targets}}
+
+ asm goto (""::::Later); // compat-warning {{jump from this asm goto statement to one of its possible targets is incompatible with C++98}} \
+ // cxx03-error {{cannot jump from this asm goto statement to one of its possible targets}}
- TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
-Later: // expected-note {{possible target of indirect goto statement}}
+ TrivialButNonPOD tnp2; // expected-note 2 {{jump bypasses initialization of non-POD variable}}
+Later: // expected-note {{possible target of indirect goto statement}} \
+ // expected-note {{possible target of asm goto statement}}
switch (n) {
TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
- default: // expected-warning {{jump from switch statement to this case label is incompatible with C++98}}
+ default: // compat-warning {{jump from switch statement to this case label is incompatible with C++98}} \
+ // cxx03-error {{cannot jump from switch statement to this case label}}
return;
}
}
@@ -303,36 +404,42 @@ namespace UnevaluatedMemberAccess {
int n;
int f() { return sizeof(S::n); } // ok
};
- int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
- const std::type_info &ti = typeid(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+ int k = sizeof(S::n); // compat-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}} \
+ // cxx03-error {{invalid use of non-static data member 'n'}}
+ const std::type_info &ti = typeid(S::n); // compat-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}} \
+ // cxx03-error {{invalid use of non-static data member 'n'}}
}
namespace LiteralUCNs {
- char c1 = '\u001e'; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
- wchar_t c2 = L'\u0041'; // expected-warning {{specifying character 'A' with a universal character name is incompatible with C++98}}
- const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}}
- const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
+ char c1 = '\u001e'; // compat-warning {{universal character name referring to a control character is incompatible with C++98}} \
+ // cxx03-error {{universal character name refers to a control character}}
+ wchar_t c2 = L'\u0041'; // compat-warning {{specifying character 'A' with a universal character name is incompatible with C++98}} \
+ // cxx03-error {{character 'A' cannot be specified by a universal character name}}
+ const char *s1 = "foo\u0031"; // compat-warning {{specifying character '1' with a universal character name is incompatible with C++98}} \
+ // cxx03-error {{character '1' cannot be specified by a universal character name}}
+ const wchar_t *s2 = L"bar\u0085"; // compat-warning {{universal character name referring to a control character is incompatible with C++98}} \
+ // cxx03-error {{universal character name refers to a control character}}
}
// FIXME: We do not implement C++98 compatibility warnings for the C++17
// template argument evaluation rules.
-#ifndef CXX17COMPAT
namespace NonTypeTemplateArgs {
template<typename T, T v> struct S {};
- const int k = 5; // expected-note {{here}}
- static void f() {} // expected-note {{here}}
- S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}}
- S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
+ const int k = 5; // pedantic-until-cxx14-note {{here}}
+ static void f() {} // pedantic-until-cxx14-note {{here}}
+ S<const int&, k> s1; // pedantic-until-cxx14-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}}
+ S<void(&)(), f> s2; // pedantic-until-cxx14-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
}
namespace NullPointerTemplateArg {
struct A {};
- template<int*> struct X {};
+ template<int*> struct X {}; // cxx03-note {{template parameter is declared here}}
template<int A::*> struct Y {};
- X<(int*)0> x; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}}
- Y<(int A::*)0> y; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}}
+ X<(int*)0> x; // until-cxx14-warning {{use of null pointer as non-type template argument is incompatible with C++98}} \
+ // cxx03-error {{non-type template argument does not refer to any declaration}}
+ Y<(int A::*)0> y; // until-cxx14-warning {{use of null pointer as non-type template argument is incompatible with C++98}} \
+ // cxx03-error {{non-type template argument is not a pointer to member constant}}
}
-#endif
namespace PR13480 {
struct basic_iterator {
@@ -341,7 +448,8 @@ namespace PR13480 {
};
union test {
- basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}}
+ basic_iterator it; // compat-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}} \
+ // cxx03-error {{union member 'it' has a non-trivial copy constructor}}
};
}
@@ -356,83 +464,78 @@ namespace AssignOpUnion {
};
union test1 {
- a x; // expected-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}}
- b y; // expected-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}}
+ a x; // compat-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}} \
+ // cxx03-error {{union member 'x' has a non-trivial copy assignment operator}}
+ b y; // compat-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}} \
+ // cxx03-error {{union member 'y' has a non-trivial copy assignment operator}}
};
}
namespace rdar11736429 {
struct X { // expected-note {{because type 'rdar11736429::X' has no default constructor}}
- X(const X&) = delete; // expected-warning{{deleted function definitions are incompatible with C++98}} \
- // expected-note {{implicit default constructor suppressed by user-declared constructor}}
+ X(const X&) = delete; // pedantic-warning {{deleted function definitions are incompatible with C++98}} \
+ // expected-note {{implicit default constructor suppressed by user-declared constructor}}
};
union S {
- X x; // expected-warning{{union member 'x' with a non-trivial default constructor is incompatible with C++98}}
+ X x; // compat-warning {{union member 'x' with a non-trivial default constructor is incompatible with C++98}} \
+ // cxx03-error {{union member 'x' has a non-trivial default constructor}}
};
}
-template<typename T> T var = T(10);
-#ifdef CXX14COMPAT
-// expected-warning at -2 {{variable templates are incompatible with C++ standards before C++14}}
-#else
-// expected-warning at -4 {{variable templates are a C++14 extension}}
-#endif
-
-// No diagnostic for specializations of variable templates; we will have
-// diagnosed the primary template.
-template<typename T> T* var<T*> = new T();
-template<> int var<int> = 10;
-template char var<char>;
-float fvar = var<float>;
-
-class A {
- template<typename T> static T var = T(10);
-#ifdef CXX14COMPAT
-// expected-warning at -2 {{variable templates are incompatible with C++ standards before C++14}}
-#else
-// expected-warning at -4 {{variable templates are a C++14 extension}}
-#endif
-
- template<typename T> static T* var<T*> = new T();
+#define VA_MACRO(x, ...) x // pedantic-warning {{variadic macros are incompatible with C++98}}
+VA_MACRO(,x) // pedantic-warning {{empty macro arguments are incompatible with C++98}}
+
+; // pedantic-warning {{extra ';' outside of a function is incompatible with C++98}}
+
+enum EnumFixed : int { // pedantic-warning {{enumeration types with a fixed underlying type are incompatible with C++98}}
};
-struct B { template<typename T> static T v; };
-#ifdef CXX14COMPAT
-// expected-warning at -2 {{variable templates are incompatible with C++ standards before C++14}}
-#else
-// expected-warning at -4 {{variable templates are a C++14 extension}}
-#endif
-
-template<typename T> T B::v = T();
-#ifdef CXX14COMPAT
-// expected-warning at -2 {{variable templates are incompatible with C++ standards before C++14}}
-#else
-// expected-warning at -4 {{variable templates are a C++14 extension}}
-#endif
-
-template<typename T> T* B::v<T*> = new T();
-template<> int B::v<int> = 10;
-template char B::v<char>;
-float fsvar = B::v<float>;
-
-#ifdef CXX14COMPAT
-int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++14}}
-#endif
-
-#ifdef CXX17COMPAT
-template<class T> struct CTAD {};
-void ctad_test() {
- CTAD<int> s;
- CTAD t = s; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}}
-}
-#endif
-
-namespace GH161702 {
-struct S {
- enum E { A };
- using E::A; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
- // not-cpp20-error at -1 {{using declaration refers to its own class}}
- // cpp20-warning at -2 {{member using declaration naming non-class ''E'' enumerator is incompatible with C++ standards before C++20}}
+void *dlsym();
+void (*FnPtr)() = (void(*)())dlsym(); // pedantic-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
+void *FnVoidPtr = (void*)&dlsym; // pedantic-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
+
+struct ConvertToInt {
+ operator int();
};
+int *ArraySizeConversion = new int[ConvertToInt()];
+// pedantic-warning-re at -1 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type '{{(int|size_t)}}' is incompatible with C++98}}
+
+template<typename T> class ExternTemplate {};
+extern template class ExternTemplate<int>; // pedantic-warning {{extern templates are incompatible with C++98}}
+
+long long ll1 = // pedantic-warning {{'long long' is incompatible with C++98}}
+ -42LL; // pedantic-warning {{'long long' is incompatible with C++98}}
+unsigned long long ull1 = // pedantic-warning {{'long long' is incompatible with C++98}}
+ 42ULL; // pedantic-warning {{'long long' is incompatible with C++98}}
+
+namespace CopyCtorIssues {
+ struct Private {
+ Private();
+ private:
+ Private(const Private&); // pedantic-note {{declared private here}}
+ };
+ struct NoViable {
+ NoViable(); // pedantic-note {{not viable}}
+ NoViable(NoViable&); // pedantic-note {{not viable}}
+ };
+ struct Ambiguous {
+ Ambiguous();
+ Ambiguous(const Ambiguous &, int = 0); // pedantic-note {{candidate}} cxx03-note {{candidate}}
+ Ambiguous(const Ambiguous &, double = 0); // pedantic-note {{candidate}} cxx03-note {{candidate}}
+ };
+ struct Deleted {
+ Private p; // pedantic-note {{implicitly deleted}}
+ };
+
+ const Private &a = Private(); // pedantic-warning {{copying variable of type 'Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+ const NoViable &b = NoViable(); // pedantic-warning {{copying variable of type 'NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+ const Ambiguous &c = Ambiguous(); // pedantic-warning {{copying variable of type 'Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}} \
+ // cxx03-error {{ambiguous constructor call when copying variable of type 'Ambiguous'}}
+ const Deleted &d = Deleted(); // pedantic-warning {{copying variable of type 'Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
}
+
+int with_attribute [[ ]]; // pedantic-warning {{[[]] attributes are incompatible with C++98}}
+
+#line 32767 // ok
+#line 32768 // pedantic-warning {{#line number greater than 32767 is incompatible with C++98}}
diff --git a/clang/test/SemaCXX/member-expr.cpp b/clang/test/SemaCXX/member-expr.cpp
index 902b09097a1203..1ef8da8cfe4809 100644
--- a/clang/test/SemaCXX/member-expr.cpp
+++ b/clang/test/SemaCXX/member-expr.cpp
@@ -119,9 +119,6 @@ namespace rdar8231724 {
y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'Y'}}
y->Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'Y'}}
y->template Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'Y'}}
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2{{'template' keyword outside of a template}}
-#endif
}
}
diff --git a/clang/test/SemaCXX/nested-name-spec.cpp b/clang/test/SemaCXX/nested-name-spec.cpp
index 74012cebb2ae11..6a6014d20db60b 100644
--- a/clang/test/SemaCXX/nested-name-spec.cpp
+++ b/clang/test/SemaCXX/nested-name-spec.cpp
@@ -511,7 +511,7 @@ namespace ForwardDeclared {
}
namespace GH63254 {
-template <typename...> struct V {}; // cxx98-warning {{variadic templates are a C++11 extension}}
+template <typename...> struct V {};
struct S : V<> {
using S::V; // expected-error {{using declaration refers to its own class}}
V<> v; // no crash
diff --git a/clang/test/SemaCXX/pre-cxx14-compat.cpp b/clang/test/SemaCXX/pre-cxx14-compat.cpp
new file mode 100644
index 00000000000000..4f9b05db3abf61
--- /dev/null
+++ b/clang/test/SemaCXX/pre-cxx14-compat.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wpre-c++14-compat-pedantic -verify %s
+
+decltype(auto) x = 0; // expected-warning {{'decltype(auto)' type specifier is incompatible}}
+
+auto init_capture = [a(0)] {}; // expected-warning {{initialized lambda captures are incompatible with C++ standards before C++14}}
+
+auto generic_lambda =
+ [](
+ auto // expected-warning {{generic lambdas are incompatible}}
+ *a) {};
+
+auto deduced_return_type(); // expected-warning {{incompatible with C++ standards before C++14}}
+auto *another_deduced_return_type(); // expected-warning {{incompatible with C++ standards before C++14}}
+decltype(auto) also_deduced_return_type(); // expected-warning {{return type deduction}} expected-warning {{'decltype(auto)' type specifier is incompatible}}
+int f();
+auto (*not_deduced_return_type)() = f;
+
+auto deduced_lambda_return_type = []() ->
+ auto // expected-warning {{return type deduction is incompatible}}
+{};
+
+auto trailing_non_deduced_return_type() -> int;
+auto trailing_deduced_return_type() -> auto; // expected-warning {{incompatible with C++ standards before C++14}}
+
+struct A {
+ operator auto(); // expected-warning {{return type deduction is incompatible}}
+};
+
+template<typename T> T var = T(10); // expected-warning {{variable templates are incompatible with C++ standards before C++14}}
+
+// No diagnostic for specializations of variable templates; we will have
+// diagnosed the primary template.
+template<typename T> T* var<T*> = new T();
+template<> int var<int> = 10;
+template char var<char>;
+float fvar = var<float>;
+
+class B {
+ template<typename T> static T var = T(10); // expected-warning {{variable templates are incompatible with C++ standards before C++14}}
+
+ template<typename T> static T* var<T*> = new T();
+};
+
+struct C { template<typename T> static T v; }; // expected-warning {{variable templates are incompatible with C++ standards before C++14}}
+
+template<typename T> T C::v = T(); // expected-warning {{variable templates are incompatible with C++ standards before C++14}}
+
+template<typename T> T* C::v<T*> = new T();
+template<> int C::v<int> = 10;
+template char C::v<char>;
+float fsvar = C::v<float>;
+
+int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++14}}
+
+int k = 0b1001; // expected-warning {{binary integer literals are incompatible with C++ standards before C++14}}
diff --git a/clang/test/SemaCXX/undefined-internal.cpp b/clang/test/SemaCXX/undefined-internal.cpp
index 9cd27ee2c981bf..2fd0e58bdfa7a0 100644
--- a/clang/test/SemaCXX/undefined-internal.cpp
+++ b/clang/test/SemaCXX/undefined-internal.cpp
@@ -196,10 +196,6 @@ namespace OverloadUse {
void f();
void f(int); // expected-warning {{function 'OverloadUse::(anonymous namespace)::f' has internal linkage but is not defined}}
void f(int, int); // expected-warning {{function 'OverloadUse::(anonymous namespace)::f' has internal linkage but is not defined}}
-#if __cplusplus < 201103L
- // expected-note at -3 {{here}}
- // expected-note at -3 {{here}}
-#endif
}
template<void x()> void t() { x(); }
template<void x(int)> void t(int*) { x(10); }
@@ -207,12 +203,6 @@ namespace OverloadUse {
void g(int n) {
t<f>(&n); // expected-note {{used here}}
t<f>(&n, &n); // expected-note {{used here}}
-#if __cplusplus < 201103L
- // expected-warning at -3 {{non-type template argument referring to function 'f' with internal linkage}}
- // expected-note at -4 {{while substituting explicitly-specified template arguments}}
- // expected-warning at -4 {{non-type template argument referring to function 'f' with internal linkage}}
- // expected-note at -5 {{while substituting explicitly-specified template arguments}}
-#endif
}
}
diff --git a/clang/test/SemaCXX/unknown-type-name.cpp b/clang/test/SemaCXX/unknown-type-name.cpp
index 9ce8b69c5bd221..1dabaa0d5fac30 100644
--- a/clang/test/SemaCXX/unknown-type-name.cpp
+++ b/clang/test/SemaCXX/unknown-type-name.cpp
@@ -99,9 +99,6 @@ template<typename T> int junk1(T::junk);
#endif
template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}}
-#if __cplusplus <= 199711L
-//expected-warning at -2 {{deleted function definitions are a C++11 extension}}
-#endif
template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}
diff --git a/clang/test/SemaObjCXX/crash.mm b/clang/test/SemaObjCXX/crash.mm
index 89a62961f7e014..c3f7dfde338730 100644
--- a/clang/test/SemaObjCXX/crash.mm
+++ b/clang/test/SemaObjCXX/crash.mm
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 %s -verify
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 %s -verify
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
namespace std {
template<typename T, typename U> class pair;
@@ -20,9 +20,6 @@ @implementation Test
typedef std::pair<int, int> IntegerPair;
template<typename...Ts> void f(Ts); // expected-error {{unexpanded}}
-#if __cplusplus <= 199711L // C++03 or earlier modes
-// expected-warning at -2 {{variadic templates are a C++11 extension}}
-#endif
@end
struct OuterType {
diff --git a/clang/test/SemaObjCXX/message.mm b/clang/test/SemaObjCXX/message.mm
index 5c37135f1a59cf..914b56d369619b 100644
--- a/clang/test/SemaObjCXX/message.mm
+++ b/clang/test/SemaObjCXX/message.mm
@@ -66,9 +66,6 @@ + (int *)otherMethod {
if (false) {
if (true)
return [typename identity<I3>::type method];
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
return [::I3 method];
}
@@ -76,14 +73,8 @@ + (int *)otherMethod {
int* ip1 = {[super method]};
int* ip2 = {[::I3 method]};
int* ip3 = {[typename identity<I3>::type method]};
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
int* ip4 = {[typename identity<I2_holder>::type().get() method]};
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
int array[5] = {[3] = 2}; // expected-warning {{C99 extension}}
return [super method];
}
@@ -97,7 +88,7 @@ + (int *)otherMethod {
// C++-specific parameter types
@interface I5
-- method:(const String&)str1
+- method:(const String&)str1
other:(String&)str2; // expected-note{{passing argument to parameter 'str2' here}}
@end
diff --git a/clang/test/SemaTemplate/class-template-spec.cpp b/clang/test/SemaTemplate/class-template-spec.cpp
index 4a2f7c3efdb895..deda8e6a38a914 100644
--- a/clang/test/SemaTemplate/class-template-spec.cpp
+++ b/clang/test/SemaTemplate/class-template-spec.cpp
@@ -153,20 +153,11 @@ namespace PR18009 {
namespace PR16519 {
template<typename T, T...N> struct integer_sequence { typedef T value_type; };
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{variadic templates are a C++11 extension}}
-#endif
template<typename T> struct __make_integer_sequence;
template<typename T, T N> using make_integer_sequence = typename __make_integer_sequence<T>::template make<N, N % 2>::type;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{alias declarations are a C++11 extension}}
-#endif
template<typename T, typename T::value_type ...Extra> struct __make_integer_sequence_impl;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{variadic templates are a C++11 extension}}
-#endif
// Note that the following seemingly-equivalent template parameter list is
// not OK; it would result in a partial specialization that is not more
@@ -174,9 +165,6 @@ namespace PR16519 {
//
// template<typename T, T ...N, T ...Extra>
template<typename T, T ...N, typename integer_sequence<T, N...>::value_type ...Extra>
-#if __cplusplus <= 199711L
- // expected-warning at -2 2{{variadic templates are a C++11 extension}}
-#endif
struct __make_integer_sequence_impl<integer_sequence<T, N...>, Extra...> {
typedef integer_sequence<T, N..., sizeof...(N) + N..., Extra...> type;
};
@@ -190,14 +178,8 @@ namespace PR16519 {
};
using X = make_integer_sequence<int, 5>;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{alias declarations are a C++11 extension}}
-#endif
using X = integer_sequence<int, 0, 1, 2, 3, 4>;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{alias declarations are a C++11 extension}}
-#endif
}
namespace NTTPTypeVsPartialOrder {
diff --git a/clang/test/SemaTemplate/default-arguments.cpp b/clang/test/SemaTemplate/default-arguments.cpp
index 5ea34c0254ec1c..77d1911a1a6dfe 100644
--- a/clang/test/SemaTemplate/default-arguments.cpp
+++ b/clang/test/SemaTemplate/default-arguments.cpp
@@ -146,9 +146,6 @@ namespace PR16288 {
template<typename X>
struct S {
template<typename T = int, typename U>
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2 {{default template arguments for a function template are a C++11 extension}}
-#endif
void f();
};
template<typename X>
@@ -159,9 +156,6 @@ namespace PR16288 {
namespace DR1635 {
template <class T> struct X {
template <class U = typename T::type> static void f(int) {} // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
-#if __cplusplus <= 199711L // C++03 or earlier modes
- // expected-warning at -2 {{default template arguments for a function template are a C++11 extension}}
-#endif
static void f(...) {}
};
diff --git a/clang/test/SemaTemplate/instantiate-function-2.cpp b/clang/test/SemaTemplate/instantiate-function-2.cpp
index 40d4a19cd08125..a71cab7c251701 100644
--- a/clang/test/SemaTemplate/instantiate-function-2.cpp
+++ b/clang/test/SemaTemplate/instantiate-function-2.cpp
@@ -50,9 +50,6 @@ namespace AliasTagDef {
template<typename T>
T f() {
using S = struct { // expected-warning {{add a tag name}} expected-note {{}}
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{alias declarations are a C++11 extension}}
-#endif
T g() { // expected-note {{}}
return T();
}
diff --git a/clang/test/SemaTemplate/instantiate-member-class.cpp b/clang/test/SemaTemplate/instantiate-member-class.cpp
index efaa40036598e7..3c9d4082645adb 100644
--- a/clang/test/SemaTemplate/instantiate-member-class.cpp
+++ b/clang/test/SemaTemplate/instantiate-member-class.cpp
@@ -54,7 +54,7 @@ void test_instantiation(X<double>::C *x,
double &dr = x->foo();
float &fr = e->bar();
f->foo(); // expected-error{{implicit instantiation of undefined member 'X<float>::D::F'}}
-
+
}
@@ -109,9 +109,6 @@ namespace AliasTagDef {
template<typename T>
struct F {
using S = struct U {
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{alias declarations are a C++11 extension}}
-#endif
T g() {
return T();
}
diff --git a/clang/test/SemaTemplate/instantiate-using-decl.cpp b/clang/test/SemaTemplate/instantiate-using-decl.cpp
index 28d83764385131..c7badfd9645881 100644
--- a/clang/test/SemaTemplate/instantiate-using-decl.cpp
+++ b/clang/test/SemaTemplate/instantiate-using-decl.cpp
@@ -149,9 +149,6 @@ template class Derived<int>; // expected-note {{requested here}}
// template. As a result, we get slightly different behavior.
struct UnresolvedTemplateNames {
template <typename> void maybe_static();
-#if __cplusplus < 201103L
- // expected-warning at +2 {{default template arguments for a function template are a C++11 extension}}
-#endif
template <typename T, typename T::type = 0> static void maybe_static();
template <typename T>
diff --git a/clang/test/SemaTemplate/overload-candidates.cpp b/clang/test/SemaTemplate/overload-candidates.cpp
index 702cdb450de158..f5327189d92fb5 100644
--- a/clang/test/SemaTemplate/overload-candidates.cpp
+++ b/clang/test/SemaTemplate/overload-candidates.cpp
@@ -97,9 +97,6 @@ namespace PR15673 {
template<typename T,
typename Requires = typename std::enable_if<a_trait<T>::value>::type>
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{default template arguments for a function template are a C++11 extension}}
-#endif
// expected-note at +1 {{candidate template ignored: requirement 'PR15673::a_trait<int>::value' was not satisfied [with T = int]}}
void foo() {}
void bar() { foo<int>(); } // expected-error {{no matching function for call to 'foo'}}
@@ -114,9 +111,6 @@ namespace PR15673 {
template<typename T,
typename Requires = typename a_pony<T>::type>
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{default template arguments for a function template are a C++11 extension}}
-#endif
// FIXME: The source location here is poor.
void baz() { } // expected-note {{candidate template ignored: substitution failure [with T = int]: no type named 'type' in 'PR15673::a_pony<int>'}}
void quux() { baz<int>(); } // expected-error {{no matching function for call to 'baz'}}
@@ -125,26 +119,16 @@ namespace PR15673 {
// FIXME: This note doesn't make it clear which candidate we rejected.
template <typename T>
using unicorns = typename std::enable_if<some_trait<T>::value>::type;
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{alias declarations are a C++11 extension}}
-#endif
- // expected-note at +7 {{candidate template ignored: requirement 'PR15673::some_trait<int>::value' was not satisfied [with T = int]}}
+ // expected-note at +4 {{candidate template ignored: requirement 'PR15673::some_trait<int>::value' was not satisfied [with T = int]}}
template<typename T,
typename Requires = unicorns<T> >
-#if __cplusplus <= 199711L
- // expected-warning at -2 {{default template arguments for a function template are a C++11 extension}}
-#endif
void wibble() {}
void wobble() { wibble<int>(); } // expected-error {{no matching function for call to 'wibble'}}
template<typename T>
struct some_passing_trait : std::true_type {};
-#if __cplusplus <= 199711L
- // expected-warning at +4 {{default template arguments for a function template are a C++11 extension}}
- // expected-warning at +4 {{default template arguments for a function template are a C++11 extension}}
-#endif
template<typename T,
int n = 42,
typename std::enable_if<n == 43 || (some_passing_trait<T>::value && some_trait<T>::value), int>::type = 0>
@@ -155,10 +139,6 @@ namespace PR15673 {
int x = 42, \
typename std::enable_if<(x == 43) || (__VA_ARGS__)>::type = 0
-#if __cplusplus <= 199711L
- // expected-warning at +4 {{default template arguments for a function template are a C++11 extension}}
- // expected-warning at +3 {{default template arguments for a function template are a C++11 extension}}
-#endif
template<typename T,
CONCEPT_REQUIRES_(some_passing_trait<T>::value && some_trait<T>::value)>
void rangesv3(); // expected-note{{candidate template ignored: requirement 'PR15673::some_trait<int>::value' was not satisfied [with T = int, x = 42]}}
diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp
index bd0bf3cfdbc590..4c8ca7b84f34d1 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -90,7 +90,7 @@ template<int Z::*pm> struct A7c;
A7<&Z::int_member> *a18_1;
A7c<&Z::int_member> *a18_2;
A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float Z::*' cannot be converted to a value of type 'int Z::*'}}
-A7c<(&Z::int_member)> *a18_4; // expected-warning{{parentheses around address non-type template argument are a C++11 extension}}
+A7c<(&Z::int_member)> *a18_4;
A7c<&Z::union_member> *a18_5;
template<unsigned char C> struct Overflow; // expected-note{{template parameter is declared here}}
@@ -431,8 +431,8 @@ namespace partial_order_references {
}
namespace dependent_nested_partial_specialization {
- template<typename> using X = int; // expected-warning {{C++11}}
- template<typename T> using Y = T*; // expected-warning {{C++11}}
+ template<typename> using X = int;
+ template<typename T> using Y = T*;
int n;
template<template<typename> class X> struct A {
diff --git a/clang/test/SemaTemplate/template-id-expr.cpp b/clang/test/SemaTemplate/template-id-expr.cpp
index 0527af4cfd8874..ac4760be358908 100644
--- a/clang/test/SemaTemplate/template-id-expr.cpp
+++ b/clang/test/SemaTemplate/template-id-expr.cpp
@@ -181,9 +181,6 @@ class E {
template<> class D<C>; // expected-error {{cannot specialize a template template parameter}}
friend class D<C>; // expected-error {{alias template 'D' cannot be referenced with the 'class' specifier}}
};
-#if __cplusplus <= 199711L
-// expected-warning at +2 {{extension}}
-#endif
template<typename T> using D = int; // expected-note {{declared here}}
E<D> ed; // expected-note {{instantiation of}}
diff --git a/clang/test/SemaTemplate/typename-specifier-4.cpp b/clang/test/SemaTemplate/typename-specifier-4.cpp
index 8f9dce6e69fa0f..6d6307f6e20879 100644
--- a/clang/test/SemaTemplate/typename-specifier-4.cpp
+++ b/clang/test/SemaTemplate/typename-specifier-4.cpp
@@ -30,10 +30,6 @@ int a0[is_same<metafun_apply2<make_pair, int, float>::type,
pair<int, float> >::value? 1 : -1];
int a1[is_same<
typename make_pair::template apply<int, float>,
-#if __cplusplus <= 199711L // C++03 and earlier modes
- // expected-warning at -2 {{'template' keyword outside of a template}}
- // expected-warning at -3 {{'typename' outside of a template is a C++11 extension}}
-#endif
make_pair::apply<int, float>
>::value? 1 : -1];
diff --git a/clang/test/SemaTemplate/typename-specifier.cpp b/clang/test/SemaTemplate/typename-specifier.cpp
index 3c88d0806ffd87..b449b8b67e0b31 100644
--- a/clang/test/SemaTemplate/typename-specifier.cpp
+++ b/clang/test/SemaTemplate/typename-specifier.cpp
@@ -21,37 +21,19 @@ namespace N {
int i;
typename N::A::type *ip1 = &i;
-#if __cplusplus <= 199711L // C++03 or earlier modes
-// expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}}
-#if __cplusplus <= 199711L
-// expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}}
-#if __cplusplus <= 199711L
-// expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
void test(double d) {
typename N::A::type f(typename N::A::type(a)); // expected-warning{{disambiguated as a function declaration}}
// expected-note at -1 {{add a pair of parentheses}}
-#if __cplusplus <= 199711L
- // expected-warning at -3 2{{'typename' outside of a template is a C++11 extension}}
-#endif
int five = f(5);
using namespace N;
for (typename A::type i = 0; i < 10; ++i)
-#if __cplusplus <= 199711L
-// expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
five += 1;
const typename N::A::type f2(d);
-#if __cplusplus <= 199711L
-// expected-warning at -2 {{'typename' outside of a template is a C++11 extension}}
-#endif
}
namespace N {
>From 6b8b019449422bf87409920eda6d99f83bb68e76 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 29 Nov 2026 17:21:56 +0100
Subject: [PATCH 2/2] Fix test
---
clang/test/SemaCXX/cxx0x-return-init-list.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/SemaCXX/cxx0x-return-init-list.cpp b/clang/test/SemaCXX/cxx0x-return-init-list.cpp
index fcee5b795cb8af..2aeec7bff7c85f 100644
--- a/clang/test/SemaCXX/cxx0x-return-init-list.cpp
+++ b/clang/test/SemaCXX/cxx0x-return-init-list.cpp
@@ -4,12 +4,12 @@
// required for libstdc++ 4.5) is supported in C++98.
int test0(int i) {
- return { i }; // expected-warning {{scalar}}
+ return { i }; // expected-warning{{generalized initializer lists are a C++11 extension}} expected-warning {{scalar}}
}
template<typename T, typename U>
T test1(U u) {
- return { u };
+ return { u }; // expected-warning{{generalized initializer lists are a C++11 extension}}
}
template int test1(char);
More information about the cfe-commits
mailing list