C++ and C++'0x Support in Clang

Last updated: $Date$

Clang currently implements all of the ISO C++ 1998 standard (including the defects addressed in the ISO C++ 2003 standard) except for 'export' (which has been removed from the C++'0x draft) and is considered a production-quality C++ compiler. The LLVM bug tracker contains a Clang C++ component that tracks known Clang C++ bugs.

C++0x Implementation status

Clang provides support for a number of features included in the upcoming ISO C++ Standard, C++0x. This section tracks the status of various C++0x features, and a number of other C++0x features are under active development.

You can use Clang in C++0x mode either with libc++ or with gcc's libstdc++. libstdc++-4.4 requires a patch to work with clang; other versions have not been tested.

The following table is used to help track our implementation progress toward implementing the complete C++'0x standard. We use a simple, somewhat arbitrary color-coding scheme to describe the relative completeness of features:

Not started/not evaluated Not Applicable Broken Some examples work Many examples work Nearly everything works Complete
N/A rXXXXXX

In addition, boxes marked with ✓ have complete and passing tests. Similarly, boxes marked with ✗ have complete tests, some of which are failing, and a ? indicates partial tests while not making any statement about passing status.

A feature is "complete" when the appropriate Clang component (Parse, AST, Sema, CodeGen) implements the behavior described in all of the paragraphs in the relevant C++'0x draft standard. The major components are:

Parse
Clang is able to parse the grammar of this feature (or the grammar described by this section), but does not necessarily do anything with the parsed result. Use Clang's -fsyntax-only option to parse C++ programs.
AST
Clang builds an abstract syntax tree (AST) for the feature, but does not necessarily perform any type-checking. Use Clang's -ast-print option to print the resulting ASTs.
Sema
Clang parses and type-checks this feature and provides a well-formed AST annotated with types. Use Clang's -fsyntax-only to type-check code.
CodeGen
Clang parses, type-checks, and generates code for this feature, allowing one to compile and execute programs.

Updates to this table are welcome! Tests for the various features are also welcome!

C++0x Features (current draft report here)
Feature Parse AST Sema CodeGen Standard Sections Notes
Control Flow Modifications
Range-based for loop 6.5.4 N2243 N3271
Type System Modifications
rvalue references 8.3.2 N2118, N2831 N2439
decltype 7.1.6.2 N2343 N1478 N1978
auto type deduction 7.1.6.2, 7.1.6.4 N1984
nullptr 2.14.7, 4.10, 4.11 N2431 N1488 N2214
enum classes 7.2 N1513 N2347 N2499 Includes forward declaration capability
long long 3.9.1 C99 N1811
constexpr 3.6.2, 3.9, 5.19, 7.1.5 N1521 N2235
char16_t/char32_t N2249
Unicode string literal types 2.14.3, 2.14.5
Raw string literal types 2.14.5 N2053 N2442 N2378
user-defined literal types 2.14.8 N2378
POD definition changes 3.9, 9 N2294
Unrestricted unions 9.5 N2544
Tighter narrowing rules 8.5.4 N1890 N2215 N2640
Class Modifications
delegating constructors 12.6.2 N1986
inheriting constructors 12.9 N1890 N1898 N2512
In-declaration member initialization N2628
Changes to implicitly generated methods Includes implicit generation of move operations
defaulted methods N1717 N2326
destructor defaults to noexcept
sizeof on members without object instance N2150
Explicit override controls
Explicit conversion operators N/A 12.3 N2437 N2333 Does not implement DR899
Template Modifications
Right angle brackets N/A N/A N/A N1757
variadic templates 14.6.3 N2080 N2087 N2242 N2488 N2555
template aliases 7.1.3, 14.6.7 N1489 N2258
Removal of export N/A N/A N/A This was never implemented in C++03
extern templates 14.8.2 N1987
Local classes as template parameters N2402 N2657
Exception Modifications
Deprecation of exception specifications 15.4
noexcept N/A 5.3.7, 15.4 N3050
Preprocessor Modifications
__STDC_HOSTED__ N/A N/A N/A 16.8 C99 N1568
_Pragma N/A N/A N/A 16.9 C99 N1568
Variable argument macros N/A N/A N/A 16.3 C99 N1568
Empty macro arguments N/A N/A N/A 16.3 C99 N1568
__func__ N/A N/A N/A 8.4.1 C99 N1568
__cplusplus N/A N/A N/A 16.8
Things Completely New
Late-specified return type N/A 8.3.5 N2445
lambda expressions 5.1.2 N1968 N2550 N2859
Uniform initializers 12.6 N2215 N2640
Memory model 1.7 N2556
Miscellania
Standard attribute syntax N2418
alignment control
Deleted functions N/A 8.4.3 N2326
This also includes class methods.
static_assert N/A 7 N1381 N1720
Inline namespaces N/A 7.3.1 N2535
thread_local storage 3.7.2, 7.1.1 N2660
Standard Library Modifications, see libc++ or libstdc++ or VC++ 2010