[all-commits] [llvm/llvm-project] 60727d: [C2x] implement typeof and typeof_unqual

Aaron Ballman via All-commits all-commits at lists.llvm.org
Wed Sep 28 10:28:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60727d856927383daf304fcf8f19fcc8ade828ad
      https://github.com/llvm/llvm-project/commit/60727d856927383daf304fcf8f19fcc8ade828ad
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2022-09-28 (Wed, 28 Sep 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/ASTContext.h
    M clang/include/clang/AST/CanonicalType.h
    M clang/include/clang/AST/PropertiesBase.td
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/include/clang/AST/Type.h
    M clang/include/clang/AST/TypeLoc.h
    M clang/include/clang/AST/TypeProperties.td
    M clang/include/clang/Basic/DiagnosticParseKinds.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Basic/Specifiers.h
    M clang/include/clang/Basic/TokenKinds.def
    M clang/include/clang/Sema/DeclSpec.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/AST/ASTImporter.cpp
    M clang/lib/AST/ASTStructuralEquivalence.cpp
    M clang/lib/AST/ODRHash.cpp
    M clang/lib/AST/Type.cpp
    M clang/lib/AST/TypeLoc.cpp
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Sema/DeclSpec.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaTemplateVariadic.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    A clang/test/C/C2x/n2927.c
    A clang/test/C/C2x/n2927_2.c
    A clang/test/C/C2x/n2930.c
    M clang/test/Lexer/keywords_test.c
    A clang/test/Parser/c2x-typeof-ext-warns.c
    A clang/test/Parser/c2x-typeof.c
    A clang/test/Sema/c2x-typeof.c
    M clang/tools/libclang/CIndex.cpp
    M clang/www/c_status.html

  Log Message:
  -----------
  [C2x] implement typeof and typeof_unqual

This implements WG14 N2927 and WG14 N2930, which together define the
feature for typeof and typeof_unqual, which get the type of their
argument as either fully qualified or fully unqualified. The argument
to either operator is either a type name or an expression. If given a
type name, the type information is pulled directly from the given name.
If given an expression, the type information is pulled from the
expression. Recursive use of these operators is allowed and has the
expected behavior (the innermost operator is resolved to a type, and
that's used to resolve the next layer of typeof specifier, until a
fully resolved type is determined.

Note, we already supported typeof in GNU mode as a non-conforming
extension and we are *not* exposing typeof_unqual as a non-conforming
extension in that mode, nor are we exposing typeof or typeof_unqual as
a nonconforming extension in other language modes. The GNU variant of
typeof supports a form where the parentheses are elided from the
operator when given an expression (e.g., typeof 0 i = 12;). When in C2x
mode, we do not support this extension.

Differential Revision: https://reviews.llvm.org/D134286




More information about the All-commits mailing list