C++ Support in Clang

Last updated: $Date$

This page tracks the status of C++ support in Clang.
Clang implements the majority of C++ features, although there are many bugs remaining and Clang is not yet generally useful as a C++ compiler. If you are looking to get involved with Clang development to help work on support for C++, please also look at our Open Projects page and the LLVM bug tracker for some specific ideas.

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

Not started/not evaluated Not Applicable Broken Some examples work Many examples work Nearly everything works Complete Complete (with tests for each paragraph)
N/A

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++ standard. Note that many C++ features are actually described in several different sections within the 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! Since Clang already supports much of C, and therefore much C++, many of the currently-white cells could be filled in. If you wish to do so, please compare Clang's implementation against the C++ standard and provide a patch that updates the table accordingly. Tests for the various features are also welcome!

Section Parse AST Sema CodeGen Notes
2 [lex] N/A N/A N/A
  2.1 [lex.phases] N/A N/A N/A Extended characters aren't handled.
  2.2 [lex.charset] N/A N/A N/A No support for extended characters.
  2.3 [lex.trigraph] N/A N/A N/A
  2.4 [lex.pptoken] N/A N/A N/A
  2.5 [lex.digraph] N/A N/A N/A
  2.6 [lex.token] N/A N/A N/A
  2.7 [lex.comment] N/A N/A NDR "form feed or vtab in comment" is not diagnosed.
  2.8 [lex.header] N/A N/A N/A
  2.9 [lex.ppnumber] N/A N/A N/A
  2.10 [lex.name] N/A N/A N/A No support for extended characters
  2.11 [lex.key] N/A N/A N/A
  2.12 [lex.operators] N/A N/A N/A
  2.13 [lex.literal] N/A N/A N/A
    2.13.1 [lex.icon] N/A N/A N/A
    2.13.2 [lex.ccon] N/A N/A N/A Poor support for extended characters
    2.13.3 [lex.fcon] N/A N/A N/A
    2.13.4 [lex.string] N/A N/A N/A Poor support for extended characters
    2.13.5 [lex.bool] N/A N/A N/A
3 [basic] N/A N/A N/A N/A
  3.1 [basic.def] N/A
  3.2 [basic.def.odr]
  3.3 [basic.scope] N/A N/A N/A
    3.3.1 [basic.scope.pdecl] N/A N/A N/A
    3.3.2 [basic.scope.local] N/A N/A N/A
    3.3.3 [basic.scope.proto] N/A N/A N/A
    3.3.4 [basic.funscope] N/A N/A N/A
    3.3.5 [basic.scope.namespace] N/A N/A N/A
    3.3.6 [basic.scope.class] N/A N/A N/A Does not check that reordering the members of a class maintains semantics.
    3.3.7 [basic.scope.hiding] N/A N/A N/A
  3.4 [basic.lookup] N/A N/A N/A
    3.4.1 [basic.lookup.unqual] N/A N/A N/A
    3.4.2 [basic.lookup.argdep] N/A N/A N/A
    3.4.3 [basic.lookup.qual] N/A N/A N/A
      3.4.3.1 [class.qual] N/A N/A N/A
      3.4.3.2 [namespace.qual] N/A N/A N/A
    3.4.4 [basic.lookup.elab]
    3.4.5 [basic.lookup.classref] N/A N/A N/A Missing ambiguity/consistency checks for paragraphs 3 (~type-name) and 7 (conversion-type-id)
    3.4.6 [basic.lookup.udir] N/A N/A N/A
  3.5 [basic.link]
  3.6 [basic.start]
    3.6.1 [basic.start.main]
    3.6.2 [basic.start.init]
    3.6.3 [basic.start.term]
  3.7 [basic.stc]
    3.7.1 [basic.stc.static]
    3.7.2 [basic.stc.auto]
    3.7.3 [basic.stc.dynamic]
      3.7.3.1 [basic.stc.dynamic.allocation]
      3.7.3.2 [basic.stc.dynamic.deallocation]
    3.7.4 [basic.stc.inherit]
  3.8 [basic.life]
  3.9 [basic.types]
    3.9.1 [basic.fundamental]
    3.9.2 [basic.compound]
    3.9.3 [basic.type.qualifier]
  3.10 [basic.lval]
4 [conv]
  4.1 [conv.lval]
  4.2 [conv.array]
  4.3 [conv.func]
  4.4 [conv.qual]
  4.5 [conv.prom]
  4.6 [conv.fpprom]
  4.7 [conv.integral]
  4.8 [conv.double]
  4.9 [conv.fpint]
  4.10 [conv.ptr]
  4.11 [conv.mem]
  4.12 [conv.bool]
5 [expr] N/A N/A N/A
  5.1 [expr.prim]
  5.2 [expr.post]
    5.2.1 [expr.sub]
    5.2.2 [expr.call]
    5.2.3 [expr.type.conv]
    5.2.4 [expr.pseudo]
    5.2.5 [expr.ref]
    5.2.6 [expr.post.incr]
    5.2.7 [expr.dynamic.cast]
    5.2.8 [expr.typeid]
    5.2.9 [expr.static.cast]
    5.2.10 [expr.reinterpret.cast]
    5.2.11 [expr.const.cast]
  5.3 [expr.unary]
    5.3.1 [expr.unary.op]
      5.3.1p1 Unary *
      5.3.1p2-5 Unary &
      5.3.1p6 Unary +
      5.3.1p7 Unary -
      5.3.1p8 Unary !
      5.3.1p9 Unary ~
    5.3.2 [expr.pre.incr]
    5.3.3 [expr.sizeof]
    5.3.4 [expr.new] operator delete is not looked up, initialization not quite correct
    5.3.5 [expr.delete]
  5.4 [expr.cast]
  5.5 [expr.mptr.oper] Dereferenced member function pointers have the wrong type(see FIXME in CheckPointerToMemberOperands).
  5.6 [expr.mul]
  5.7 [expr.add]
  5.8 [expr.shift]
  5.9 [expr.rel]
  5.10 [expr.eq]
  5.11 [expr.bit.and]
  5.12 [expr.xor]
  5.13 [expr.or]
  5.14 [expr.log.and]
  5.15 [expr.log.or]
  5.16 [expr.cond] some invalid hierarchy casts still accepted, but that's a general problem
  5.17 [expr.ass]
  5.18 [expr.comma]
  5.19 [expr.const] Uses C semantics
6 [stmt.stmt]
  6.1 [stmt.label]
  6.2 [stmt.expr]
  6.3 [stmt.block]
  6.4 [stmt.select] Conversion of declarations to required types not really supported.
    6.4.1 [stmt.if]
    6.4.2 [stmt.switch]
  6.5 [stmt.iter] Conversion of declarations to required types not really supported.
    6.5.1 [stmt.while]
    6.5.2 [stmt.do]
    6.5.3 [stmt.for]
  6.6 [stmt.jump]
    6.6.1 [stmt.break]
    6.6.2 [stmt.cont]
    6.6.3 [stmt.return]
    6.6.4 [stmt.goto]
  6.7 [stmt.dcl] Existence and accessibility of destructors is not tested for.
  6.8 [stmt.ambig]
7 [dcl.dcl]
  7.1 [dcl.spec]
    7.1.1 [dcl.stc] Linkage merging has some errors.
    7.1.2 [dcl.fct.spec]
    7.1.3 [dcl.typedef]
    7.1.4 [dcl.friend]
    7.1.5 [dcl.type]
      7.1.5.1 [dcl.type.cv]
      7.1.5.2 [dcl.type.simple]
      7.1.5.3 [dcl.type.elab]
  7.2 [dcl.enum]
  7.3 [basic.namespace]
    7.3.1 [namespace.def]
      7.3.1.1 [namespace.unnamed]
      7.3.1.2 [namespace.memdef]
    7.3.2 [namespace.alias] N/A
    7.3.3 [namespace.udecl] N/A
    7.3.4[namespace.udir] Example in p4 fails.
  7.4 [dcl.asm]
  7.5 [dcl.link]
8 [dcl.decl]
  8.1 [dcl.name] N/A
  8.2 [dcl.ambig.res] N/A N/A
  8.3 [dcl.meaning] N/A
    8.3.1 [dcl.ptr] N/A
    8.3.2 [dcl.ref] N/A
    8.3.3 [dcl.mptr] N/A
    8.3.4 [dcl.array] N/A
    8.3.5 [dcl.fct] N/A
    8.3.6 [dcl.fct.default] N/A Partial support for default arguments of templates.
  8.4 [dcl.fct.def]
  8.5 [dcl.init]
    8.5.1[dcl.init.aggr] No CodeGen for dynamic initialization.
    8.5.2[dcl.init.string]
    8.5.3 [dcl.init.ref]
9 [class]
  9.1 [class.name] N/A
  9.2 [class.mem]
  9.3 [class.mfct]
    9.3.1 [class.mfct.non-static]
    9.3.2 [class.this]
  9.4 [class.static]
    9.4.1 [class.static.mfct]
    9.4.2 [class.static.data]
  9.5 [class.union]
  9.6 [class.bit]
  9.7 [class.nest] N/A
  9.8 [class.local] N/A
  9.9 [class.nested.type] N/A
10 [class.derived]
  10.1 [class.mi]
  10.2 [class.member.lookup] N/A
  10.3 [class.virtual]
  10.4 [class.abstract] N/A
11 [class.access] N/A
  11.1 [class.access.spec] N/A
  11.2 [class.access.base] N/A
  11.3 [class.access.dcl] N/A
  11.4 [class.friend] N/A
  11.5 [class.protected] N/A
  11.6 [class.access.virt] N/A
  11.7 [class.paths] N/A
  11.8 [class.access.nest] N/A
12 [special]
  12.1 [class.ctor]
  12.2 [class.temporary] N/A
  12.3 [class.conv]
    12.3.1 [class.conv.ctor]
    12.3.2 [class.conv.fct]
  12.4 [class.dtor]
  12.5 [class.free]
  12.6 [class.init]
    12.6.1 [class.expl.init]
    12.6.2 [class.base.init] Most of the semantics of base initializations are implemented.
  12.7 [class.cdtor]
  12.8 [class.copy] Most of the semantics of copy constructors are implemented.
13 [over]
  13.1 [over.load] N/A
  13.2 [over.dcl] N/A N/A
  13.3 [over.match] N/A N/A
    13.3.1 [over.match.funcs] N/A N/A
      13.3.1.1 [over.match.call] N/A N/A
        13.3.1.1.1 [over.call.func] N/A N/A
        13.3.1.1.2 [over.call.object] N/A N/A
      13.3.1.2 [over.match.oper] N/A N/A
      13.3.1.3 [over.match.ctor] N/A N/A
      13.3.1.4 [over.match.copy] N/A N/A
      13.3.1.5 [over.match.conv] N/A N/A
      13.3.1.6 [over.match.ref] N/A N/A
    13.3.2 [over.match.viable] N/A N/A
    13.3.3 [over.match.best] N/A N/A
      13.3.3.1 [over.best.ics] N/A N/A
        13.3.3.1.1 [over.ics.scs] N/A N/A
        13.3.3.1.2 [over.ics.user] N/A N/A
        13.3.3.1.3 [over.ics.ellipsis] N/A N/A
        13.3.3.1.4 [over.ics.ref] N/A N/A
      13.3.3.2 [over.ics.rank] N/A N/A
  13.4 [over.over] N/A N/A
  13.5 [over.oper] N/A
    13.5.1 [over.unary] N/A N/A
    13.5.2 [over.binary] N/A N/A
    13.5.3 [over.ass] N/A N/A
    13.5.4 [over.call] N/A N/A
    13.5.5 [over.sub] N/A N/A
    13.5.6 [over.ref] N/A N/A
    13.5.7 [over.inc] N/A N/A
  13.6 [over.built] N/A N/A Missing support for the ternary operator (p24, p25).
14 [temp]
  14.1 [temp.param] N/A
  14.2 [temp.names] N/A
  14.3 [temp.arg] N/A
    14.3.1 [temp.arg.type] N/A Paragraph 3 will be tested elsewhere
    14.3.2 [temp.arg.nontype] N/A
    14.3.3 [temp.arg.template] N/A
  14.4 [temp.type] N/A N/A
  14.5 [temp.decls]
    14.5.1 [temp.class]
      14.5.1.1 [temp.mem.func]
      14.5.1.2 [temp.mem.class]
      14.5.1.3 [temp.static]
    14.5.2 [temp.mem]
    14.5.3 [temp.friend] N/A
    14.5.4 [temp.class.spec] N/A
      14.5.4.1 [temp.class.spec.match] N/A N/A N/A
      14.5.4.2 [temp.class.order] N/A
      14.5.5.3 [temp.class.spec.mfunc] N/A
    14.5.5 [temp.fct]
      14.5.5.1 [temp.over.link] N/A
      14.5.5.2 [temp.func.order] N/A
  14.6 [temp.res]
    14.6.1 [temp.local]
    14.6.2 [temp.dep] N/A
      14.6.2.1 [temp.dep.type] N/A
      14.6.2.2 [temp.dep.expr] N/A
      14.6.2.3 [temp.dep.constexpr] N/A
      14.6.2.4 [temp.dep.temp] N/A
    14.6.3 [temp.nondep] N/A
    14.6.4 [temp.dep.res] N/A
      14.6.4.1 [temp.point] N/A
      14.6.4.2 [temp.dep.candidate] N/A Not restricted to functions with external linkage
    14.6.5 [temp.inject] N/A
  14.7 [temp.spec]
    14.7.1 [temp.inst] N/A
    14.7.2 [temp.explicit] Cannot test paragraph 11 until access control is implemented.
ASTs do not carry enough information to reproduce source code accurately.
    14.7.3 [temp.expl.spec] ASTs do not carry enough information to reproduce source code accurately
  14.8 [temp.fct.spec]
    14.8.1 [temp.arg.explicit]
    14.8.2 [temp.deduct] N/A N/A N/A
      14.8.2.1 [temp.deduct.call]
      14.8.2.2 [temp.deduct.funcaddr] N/A N/A
      14.8.2.3 [temp.deduct.conv]
      14.8.2.4 [temp.deduct.type] N/A N/A
    14.8.3 [temp.over]
15 [except]
  15.1 [except.throw] N/A N/A
  15.2 [except.ctor] N/A N/A N/A
  15.3 [except.handle] N/A N/A Not all constraints are checked
  15.4 [except.spec]
  15.5 [except.special] N/A N/A N/A N/A
    15.5.1 [except.terminate] N/A N/A N/A N/A
    15.5.2 [except.unexpected] N/A N/A N/A N/A
    15.5.3 [except.uncaught] N/A N/A N/A N/A
  15.6 [except.access] N/A N/A N/A N/A Redundant - struck from C++0x
16 [cpp]
  16.1 [cpp.cond]
  16.2 [cpp.include]
  16.3 [cpp.replace]
    16.3.1 [cpp.subst]
    16.3.2 [cpp.stringize]
    16.3.3 [cpp.concat]
    16.3.4 [cpp.rescan]
    16.3.5 [cpp.scope]
  16.4 [cpp.line]
  16.5 [cpp.error]
  16.6 [cpp.pragma]
  16.7 [cpp.null]
  16.8 [cpp.predefined]
A [gram]
  A.1 [gram.key]
  A.2 [gram.lex]
  A.3 [gram.basic]
  A.4 [gram.expr]
  A.5 [gram.stmt]
  A.6 [gram.dcl]
  A.7 [gram.decl]
  A.8 [gram.class]
  A.9 [gram.derived]
  A.10 [gram.special]
  A.11 [gram.over]
  A.12 [gram.temp]
  A.13 [gram.except]
  A.14 [gram.cpp]
B [implimits]
C [diff]
  C.1 [diff.iso]
    C.1.1 [diff.lex]
    C.1.2 [diff.basic]
    C.1.3 [diff.expr]
    C.1.4 [diff.stat]
    C.1.5 [diff.dcl]
    C.1.6 [diff.decl]
    C.1.7 [diff.class]
    C.1.8 [diff.special]
    C.1.9 [diff.cpp]
  C.2 [diff.library]
    C.2.1 [diff.mods.to.headers]
    C.2.2 [diff.mods.to.definitions]
      C.2.2.2 [diff.wchar.t]
      C.2.2.3 [diff.header.iso646.h]
      C.2.2.4 [diff.null]
    C.2.3 [diff.mods.to.declarations]
    C.2.4 [diff.mods.to.behavior]
      C.2.4.1 [diff.offsetof]
      C.2.4.2 [diff.malloc]
D [depr]
  D.1 [depr.incr.bool]
  D.2 [depr.static]
  D.3 [depr.access.dcl]
  D.4 [depr.string]
  D.5 [depr.c.headers]
E [extendid]
C++0x Features
Explicit conversion operators (N2437) No name mangling; ASTs don't contain calls to conversion operators
Static assertions (N1720) N/A
Deleted functions (N2346) N/A
Rvalue references (N2118 + N2831)
nullptr (N2431)
Right angle brackets (N1757) N/A N/A N/A
Decltype (N2343) N/A