[clang] [Clang] Make most C++98 extension warnings pedantic (PR #246759)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 27 13:47:47 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
---
Patch is 104.69 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/246759.diff
51 Files Affected:
- (modified) clang/include/clang/Basic/Diagnostic.td (+1-1)
- (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+1-2)
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+5-6)
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2-3)
- (modified) clang/test/AST/ByteCode/cxx03.cpp (+1-2)
- (modified) clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp (-3)
- (modified) clang/test/CXX/class.access/class.friend/p2-cxx03.cpp (+3-6)
- (modified) clang/test/CXX/class/class.friend/p2.cpp (-3)
- (modified) clang/test/CXX/class/class.union/p1.cpp (+3-3)
- (modified) clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp (+3-9)
- (modified) clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp (-3)
- (modified) clang/test/CXX/temp/temp.param/p9.cpp (+5-5)
- (modified) clang/test/Parser/cxx-ext-delete-default.cpp (+1-1)
- (modified) clang/test/Parser/cxx-friend.cpp (+1-4)
- (modified) clang/test/Parser/cxx-reference.cpp (+1-4)
- (modified) clang/test/Parser/cxx0x-in-cxx98.cpp (+1-1)
- (modified) clang/test/SemaCXX/MicrosoftCompatibility.cpp (+8-8)
- (modified) clang/test/SemaCXX/PR10458.cpp (+1-1)
- (modified) clang/test/SemaCXX/PR9572.cpp (-3)
- (modified) clang/test/SemaCXX/addr-of-overloaded-function.cpp (-3)
- (modified) clang/test/SemaCXX/aggregate-init-cxx98.cpp (+3-1)
- (modified) clang/test/SemaCXX/anonymous-struct.cpp (+1-3)
- (modified) clang/test/SemaCXX/class.cpp (+3-6)
- (modified) clang/test/SemaCXX/const-cast.cpp (-6)
- (modified) clang/test/SemaCXX/convert-to-bool.cpp (+1-10)
- (modified) clang/test/SemaCXX/copy-initialization.cpp (-3)
- (modified) clang/test/SemaCXX/cxx0x-return-init-list.cpp (+2-2)
- (modified) clang/test/SemaCXX/cxx11-compat.cpp (+1-34)
- (modified) clang/test/SemaCXX/cxx14-compat.cpp (+6)
- (modified) clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp (+14-14)
- (added) clang/test/SemaCXX/cxx20-compat.cpp (+8)
- (modified) clang/test/SemaCXX/cxx2d-defaulted-postfix-operators.cpp (+5-12)
- (removed) clang/test/SemaCXX/cxx98-compat-pedantic.cpp (-81)
- (modified) clang/test/SemaCXX/cxx98-compat.cpp (+310-207)
- (modified) clang/test/SemaCXX/member-expr.cpp (-3)
- (modified) clang/test/SemaCXX/nested-name-spec.cpp (+1-1)
- (added) clang/test/SemaCXX/pre-cxx14-compat.cpp (+55)
- (modified) clang/test/SemaCXX/undefined-internal.cpp (-10)
- (modified) clang/test/SemaCXX/unknown-type-name.cpp (-3)
- (modified) clang/test/SemaObjCXX/crash.mm (+3-6)
- (modified) clang/test/SemaObjCXX/message.mm (+1-10)
- (modified) clang/test/SemaTemplate/class-template-spec.cpp (-18)
- (modified) clang/test/SemaTemplate/default-arguments.cpp (-6)
- (modified) clang/test/SemaTemplate/instantiate-function-2.cpp (-3)
- (modified) clang/test/SemaTemplate/instantiate-member-class.cpp (+1-4)
- (modified) clang/test/SemaTemplate/instantiate-using-decl.cpp (-3)
- (modified) clang/test/SemaTemplate/overload-candidates.cpp (+1-21)
- (modified) clang/test/SemaTemplate/temp_arg_nontype.cpp (+3-3)
- (modified) clang/test/SemaTemplate/template-id-expr.cpp (-3)
- (modified) clang/test/SemaTemplate/typename-specifier-4.cpp (-4)
- (modified) clang/test/SemaTemplate/typename-specifier.cpp (-18)
``````````diff
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...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/246759
More information about the cfe-commits
mailing list