Clang Flag: -Wc++1y-extensions / -Wno-c++1y-extensions

From emmtrix Wiki
Jump to navigation Jump to search
This MediaWiki article details the usage and implications of two Clang compiler flags, -Wc++1y-extensions and -Wno-c++1y-extensions, concerning C++14 (formerly known as C++1y) language extension warnings. These flags facilitate developers in managing warnings about language features that were introduced in C++14 and are not part of C++11.

The -Wc++1y-extensions flag, when active, enables warnings for code constructs that are permissible in C++14 but are extensions relative to C++11. This is useful for developers aiming to maintain compatibility with C++11 or who wish to be explicitly aware of when they are using features that go beyond C++11. As per the document, activating this flag will emit warnings for features such as binary integer literals and the use of certain C++14 attributes which are not active by default.

On the other hand, the -Wno-c++1y-extensions flag suppresses warnings about the use of C++14 extensions. This flag is particularly useful for projects that have fully adopted C++14 (or later) and do not require notifications about the use of C++14 extensions. The document lists multiple specific cases where this flag suppresses warnings, including the use of extended constexpr functions, variable templates, initialized lambda captures, and several others.

Both flags offer developers fine-grained control over the adoption of C++14 features in their projects, allowing for a smoother transition from C++11 or for maintaining strict compatibility with C++11 standards while still allowing certain extensions.

 
AI Generated

Supergroups

Subroups

Warnings/Remarks

Default Active (Deactivate with -Wno-c++1y-extensions)

ext_constexpr_body_invalid_stmt
warning: use of this statement in a constexpr
function
constructor
is a C++14 extension

ext_constexpr_body_multiple_return warning: multiple return statements in constexpr function is a C++14 extension
ext_constexpr_local_var
warning: variable declaration in a constexpr
function
constructor
is a C++14 extension

ext_constexpr_type_definition
warning: type definition in a constexpr
function
constructor
is a C++14 extension

ext_decltype_auto_type_specifier warning: 'decltype(auto)' type specifier is a C++14 extension
ext_init_capture warning: initialized lambda captures are a C++14 extension
ext_variable_template warning: variable templates are a C++14 extension

Default Inactive (Activate with -Wc++1y-extensions)

ext_binary_literal_cxx14 warning: binary integer literals are a C++14 extension
ext_cxx14_attr warning: use of the A attribute is a C++14 extension