148 changes: 148 additions & 0 deletions clang/include/clang/Basic/BuiltinsRISCV.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//==- BuiltinsRISCV.td - RISC-V Builtin function database ---*- tablegen -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the RISC-V-specific builtin function database.
//
//===----------------------------------------------------------------------===//

include "clang/Basic/BuiltinsBase.td"

class RISCVBuiltin<string prototype, string features = ""> : TargetBuiltin {
let Spellings = ["__builtin_riscv_" # NAME];
let Prototype = prototype;
let Features = features;
}

let Attributes = [NoThrow, Const] in {
//===----------------------------------------------------------------------===//
// Zbb extension.
//===----------------------------------------------------------------------===//
def orc_b_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbb">;
def orc_b_64 : RISCVBuiltin<"uint64_t(uint64_t)", "zbb,64bit">;
def clz_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbb|xtheadbb">;
def clz_64 : RISCVBuiltin<"unsigned int(uint64_t)", "zbb|xtheadbb,64bit">;
def ctz_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbb">;
def ctz_64 : RISCVBuiltin<"unsigned int(uint64_t)", "zbb,64bit">;

//===----------------------------------------------------------------------===//
// Zbc or Zbkc extension.
//===----------------------------------------------------------------------===//
def clmul_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)", "zbc|zbkc">;
def clmul_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)", "zbc|zbkc,64bit">;
def clmulh_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)", "zbc|zbkc,32bit">;
def clmulh_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)", "zbc|zbkc,64bit">;
def clmulr_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)", "zbc,32bit">;
def clmulr_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)", "zbc,64bit">;

//===----------------------------------------------------------------------===//
// Zbkx extension.
//===----------------------------------------------------------------------===//
let Features = "zbkx,32bit" in {
def xperm4_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
def xperm8_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
} // Features = "zbkx,32bit"

let Features = "zbkx,64bit" in {
def xperm4_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
def xperm8_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
} // Features = "zbkx,64bit"

//===----------------------------------------------------------------------===//
// Zbkb extension.
//===----------------------------------------------------------------------===//
def brev8_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbkb">;
def brev8_64 : RISCVBuiltin<"uint64_t(uint64_t)", "zbkb,64bit">;
def zip_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbkb,32bit">;
def unzip_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbkb,32bit">;

//===----------------------------------------------------------------------===//
// Zknd extension.
//===----------------------------------------------------------------------===//
let Features = "zknd,32bit" in {
def aes32dsi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">;
def aes32dsmi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">;
} // Features = "zknd,32bit"

let Features = "zknd,64bit" in {
def aes64ds : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
def aes64dsm : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
def aes64im : RISCVBuiltin<"uint64_t(uint64_t)">;
} // Features = "zknd,64bit"

//===----------------------------------------------------------------------===//
// Zknd & Zkne extension.
//===----------------------------------------------------------------------===//
let Features = "zknd|zkne,64bit" in {
def aes64ks1i : RISCVBuiltin<"uint64_t(uint64_t, _Constant unsigned int)">;
def aes64ks2 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
} // Features = "zknd|zkne,64bit"

//===----------------------------------------------------------------------===//
// Zkne extension.
//===----------------------------------------------------------------------===//
let Features = "zkne,32bit" in {
def aes32esi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">;
def aes32esmi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">;
} // Features = "zkne,32bit"

let Features = "zkne,64bit" in {
def aes64es : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
def aes64esm : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">;
} // Features = "zkne,64bit"

//===----------------------------------------------------------------------===//
// Zknh extension.
//===----------------------------------------------------------------------===//
let Features = "zknh" in {
def sha256sig0 : RISCVBuiltin<"unsigned int(unsigned int)">;
def sha256sig1 : RISCVBuiltin<"unsigned int(unsigned int)">;
def sha256sum0 : RISCVBuiltin<"unsigned int(unsigned int)">;
def sha256sum1 : RISCVBuiltin<"unsigned int(unsigned int)">;
} // Features = "zknh"

let Features = "zknh,32bit" in {
def sha512sig0h : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
def sha512sig0l : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
def sha512sig1h : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
def sha512sig1l : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
def sha512sum0r : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
def sha512sum1r : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">;
} // Features = "zknh,32bit"

let Features = "zknh,64bit" in {
def sha512sig0 : RISCVBuiltin<"uint64_t(uint64_t)">;
def sha512sig1 : RISCVBuiltin<"uint64_t(uint64_t)">;
def sha512sum0 : RISCVBuiltin<"uint64_t(uint64_t)">;
def sha512sum1 : RISCVBuiltin<"uint64_t(uint64_t)">;
} // Features = "zknh,64bit"

//===----------------------------------------------------------------------===//
// Zksed extension.
//===----------------------------------------------------------------------===//
let Features = "zksed" in {
def sm4ed : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int )">;
def sm4ks : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">;
} // Features = "zksed"

//===----------------------------------------------------------------------===//
// Zksh extension.
//===----------------------------------------------------------------------===//
let Features = "zksh" in {
def sm3p0 : RISCVBuiltin<"unsigned int(unsigned int)">;
def sm3p1 : RISCVBuiltin<"unsigned int(unsigned int)">;
} // Features = "zksh"

} // Attributes = [Const, NoThrow]

//===----------------------------------------------------------------------===//
// Zihintntl extension.
//===----------------------------------------------------------------------===//
let Features = "zihintntl", Attributes = [CustomTypeChecking] in {
def ntl_load : RISCVBuiltin<"void(...)">;
def ntl_store : RISCVBuiltin<"void(...)">;
} // Features = "zihintntl", Attributes = [CustomTypeChecking]
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ clang_tablegen(BuiltinsBPF.inc -gen-clang-builtins
SOURCE BuiltinsBPF.td
TARGET ClangBuiltinsBPF)

clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
SOURCE BuiltinsRISCV.td
TARGET ClangBuiltinsRISCV)

# ARM NEON and MVE
clang_tablegen(arm_neon.inc -gen-arm-neon-sema
SOURCE arm_neon.td
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/TargetBuiltins.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace clang {
FirstRVVBuiltin = clang::Builtin::FirstTSBuiltin,
LastRVVBuiltin = RISCVVector::FirstTSBuiltin - 1,
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
#include "clang/Basic/BuiltinsRISCV.def"
#include "clang/Basic/BuiltinsRISCV.inc"
LastTSBuiltin
};
} // namespace RISCV
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Tooling/Inclusions/IncludeStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct IncludeStyle {

/// When guessing whether a #include is the "main" include, only the include
/// directives that use the specified character are considered.
/// \version 18
/// \version 19
MainIncludeCharDiscriminator MainIncludeChar;
};

Expand Down
1 change: 0 additions & 1 deletion clang/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ module Clang_Basic {
textual header "clang/Basic/BuiltinsNEON.def"
textual header "clang/Basic/BuiltinsNVPTX.def"
textual header "clang/Basic/BuiltinsPPC.def"
textual header "clang/Basic/BuiltinsRISCV.def"
textual header "clang/Basic/BuiltinsRISCVVector.def"
textual header "clang/Basic/BuiltinsSME.def"
textual header "clang/Basic/BuiltinsSVE.def"
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3537,10 +3537,19 @@ bool FunctionDecl::isTargetMultiVersion() const {
(hasAttr<TargetAttr>() || hasAttr<TargetVersionAttr>());
}

bool FunctionDecl::isTargetMultiVersionDefault() const {
return isMultiVersion() && hasAttr<TargetVersionAttr>() &&
getAttr<TargetVersionAttr>()->isDefaultVersion();
}

bool FunctionDecl::isTargetClonesMultiVersion() const {
return isMultiVersion() && hasAttr<TargetClonesAttr>();
}

bool FunctionDecl::isTargetVersionMultiVersion() const {
return isMultiVersion() && hasAttr<TargetVersionAttr>();
}

void
FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
redeclarable_base::setPreviousDecl(PrevDecl);
Expand Down
12 changes: 9 additions & 3 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
// Special case for C++'s three-way/spaceship operator <=>, which
// returns a std::{strong,weak,partial}_ordering (which is a class, so doesn't
// have a PrimType).
if (!T && Ctx.getLangOpts().CPlusPlus) {
if (!T && BO->getOpcode() == BO_Cmp) {
if (DiscardResult)
return true;
const ComparisonCategoryInfo *CmpInfo =
Expand Down Expand Up @@ -1750,8 +1750,7 @@ bool ByteCodeExprGen<Emitter>::VisitPredefinedExpr(const PredefinedExpr *E) {
if (DiscardResult)
return true;

assert(!Initializing);
return this->visit(E->getFunctionName());
return this->delegate(E->getFunctionName());
}

template <class Emitter>
Expand Down Expand Up @@ -2051,6 +2050,13 @@ bool ByteCodeExprGen<Emitter>::VisitCXXInheritedCtorInitExpr(
return this->emitCall(F, E);
}

template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitExpressionTraitExpr(
const ExpressionTraitExpr *E) {
assert(Ctx.getLangOpts().CPlusPlus);
return this->emitConstBool(E->getValue(), E);
}

template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
if (E->containsErrors())
return false;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
bool VisitChooseExpr(const ChooseExpr *E);
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E);
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E);

protected:
bool visitExpr(const Expr *E) override;
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/Interp/ByteCodeStmtGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ bool ByteCodeStmtGen<Emitter>::visitFunc(const FunctionDecl *F) {

auto emitFieldInitializer = [&](const Record::Field *F, unsigned FieldOffset,
const Expr *InitExpr) -> bool {
// We don't know what to do with these, so just return false.
if (InitExpr->getType().isNull())
return false;

if (std::optional<PrimType> T = this->classify(InitExpr)) {
if (!this->visit(InitExpr))
return false;
Expand Down
11 changes: 8 additions & 3 deletions clang/lib/AST/Interp/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
const Pointer &Ptr = S.Stk.peek<Pointer>();

if (!CheckDummy(S, OpPC, Ptr))
return false;
return true;

if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
return false;
Expand All @@ -1869,8 +1869,10 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
const T &Offset = S.Stk.pop<T>();
const Pointer &Ptr = S.Stk.pop<Pointer>();

if (!CheckDummy(S, OpPC, Ptr))
return false;
if (!CheckDummy(S, OpPC, Ptr)) {
S.Stk.push<Pointer>(Ptr);
return true;
}

if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
return false;
Expand All @@ -1891,6 +1893,9 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
const Pointer &Ptr = S.Stk.pop<Pointer>();

if (Ptr.isDummy())
return false;

if (!Ptr.isUnknownSizeArray()) {
S.Stk.push<Pointer>(Ptr.atIndex(0));
return true;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static constexpr Builtin::Info BuiltinInfo[] = {
{#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
{#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsRISCV.def"
#include "clang/Basic/BuiltinsRISCV.inc"
};

ArrayRef<Builtin::Info> RISCVTargetInfo::getTargetBuiltins() const {
Expand Down
16 changes: 14 additions & 2 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
Expand Down Expand Up @@ -4212,7 +4213,8 @@ void CodeGenModule::emitMultiVersionFunctions() {
llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
if (auto *IFunc = dyn_cast<llvm::GlobalIFunc>(ResolverConstant)) {
ResolverConstant = IFunc->getResolver();
if (FD->isTargetClonesMultiVersion()) {
if (FD->isTargetClonesMultiVersion() ||
FD->isTargetVersionMultiVersion()) {
const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
std::string MangledName = getMangledNameImpl(
Expand Down Expand Up @@ -4393,8 +4395,18 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
// a separate resolver).
std::string ResolverName = MangledName;
if (getTarget().supportsIFunc()) {
if (!FD->isTargetClonesMultiVersion())
switch (FD->getMultiVersionKind()) {
case MultiVersionKind::None:
llvm_unreachable("unexpected MultiVersionKind::None for resolver");
case MultiVersionKind::Target:
case MultiVersionKind::CPUSpecific:
case MultiVersionKind::CPUDispatch:
ResolverName += ".ifunc";
break;
case MultiVersionKind::TargetClones:
case MultiVersionKind::TargetVersion:
break;
}
} else if (FD->isTargetMultiVersion()) {
ResolverName += ".resolver";
}
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
"TVOS_DEPLOYMENT_TARGET",
"WATCHOS_DEPLOYMENT_TARGET",
"DRIVERKIT_DEPLOYMENT_TARGET",
"XROS_DEPLOYMENT_TARGET"
};
static_assert(std::size(EnvVars) == Darwin::LastDarwinPlatform + 1,
"Missing platform");
Expand All @@ -1914,14 +1915,15 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
// default platform.
if (!Targets[Darwin::MacOS].empty() &&
(!Targets[Darwin::IPhoneOS].empty() ||
!Targets[Darwin::WatchOS].empty() || !Targets[Darwin::TvOS].empty())) {
!Targets[Darwin::WatchOS].empty() || !Targets[Darwin::TvOS].empty() ||
!Targets[Darwin::XROS].empty())) {
if (Triple.getArch() == llvm::Triple::arm ||
Triple.getArch() == llvm::Triple::aarch64 ||
Triple.getArch() == llvm::Triple::thumb)
Targets[Darwin::MacOS] = "";
else
Targets[Darwin::IPhoneOS] = Targets[Darwin::WatchOS] =
Targets[Darwin::TvOS] = "";
Targets[Darwin::TvOS] = Targets[Darwin::XROS] = "";
} else {
// Don't allow conflicts in any other platform.
unsigned FirstTarget = std::size(Targets);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
WatchOS,
DriverKit,
XROS,
LastDarwinPlatform = DriverKit
LastDarwinPlatform = XROS
};
enum DarwinEnvironmentKind {
NativeEnvironment,
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,8 @@ void Sema::ActOnEndOfTranslationUnit() {
Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
<< /*function=*/0 << DiagD << DiagRange;
}
} else {
} else if (!FD->isTargetMultiVersion() ||
FD->isTargetMultiVersionDefault()) {
if (FD->getDescribedFunctionTemplate())
Diag(DiagD->getLocation(), diag::warn_unused_template)
<< /*function=*/0 << DiagD << DiagRange;
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5998,6 +5998,10 @@ void Sema::ActOnDefaultCtorInitializers(Decl *CDtorDecl) {

if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
if (CXXRecordDecl *ClassDecl = Constructor->getParent();
!ClassDecl || ClassDecl->isInvalidDecl()) {
return;
}
SetCtorInitializers(Constructor, /*AnyErrors=*/false);
DiagnoseUninitializedFields(*this, Constructor);
}
Expand Down Expand Up @@ -14038,6 +14042,9 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,

CXXRecordDecl *ClassDecl = Constructor->getParent();
assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");
if (ClassDecl->isInvalidDecl()) {
return;
}

SynthesizedFunctionScope Scope(*this, Constructor);

Expand Down
263 changes: 101 additions & 162 deletions clang/test/AST/Interp/arrays.cpp

Large diffs are not rendered by default.

49 changes: 16 additions & 33 deletions clang/test/AST/Interp/c.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify -std=c11 %s
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -pedantic -verify=pedantic-expected -std=c11 %s
// RUN: %clang_cc1 -verify=ref -std=c11 %s
// RUN: %clang_cc1 -pedantic -verify=pedantic-ref -std=c11 %s
// RUN: %clang_cc1 -triple x86_64-linux -fexperimental-new-constant-interpreter -verify=expected,all -std=c11 %s
// RUN: %clang_cc1 -triple x86_64-linux -fexperimental-new-constant-interpreter -pedantic -verify=pedantic-expected,all -std=c11 %s
// RUN: %clang_cc1 -triple x86_64-linux -verify=ref,all -std=c11 %s
// RUN: %clang_cc1 -triple x86_64-linux -pedantic -verify=pedantic-ref,all -std=c11 %s

typedef __INTPTR_TYPE__ intptr_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
Expand All @@ -22,10 +22,7 @@ _Static_assert(!!1.0, ""); // pedantic-ref-warning {{not an integer constant exp
_Static_assert(!!1, "");

int a = (1 == 1 ? 5 : 3);
_Static_assert(a == 5, ""); // ref-error {{not an integral constant expression}} \
// pedantic-ref-error {{not an integral constant expression}} \
// expected-error {{not an integral constant expression}} \
// pedantic-expected-error {{not an integral constant expression}}
_Static_assert(a == 5, ""); // all-error {{not an integral constant expression}}


const int b = 3;
Expand Down Expand Up @@ -67,52 +64,34 @@ _Static_assert((&a - 100) != 0, ""); // pedantic-ref-warning {{is a GNU extensio
/// extern variable of a composite type.
/// FIXME: The 'cast from void*' note is missing in the new interpreter.
extern struct Test50S Test50;
_Static_assert(&Test50 != (void*)0, ""); // ref-warning {{always true}} \
// pedantic-ref-warning {{always true}} \
_Static_assert(&Test50 != (void*)0, ""); // all-warning {{always true}} \
// pedantic-ref-warning {{is a GNU extension}} \
// pedantic-ref-note {{cast from 'void *' is not allowed}} \
// expected-warning {{always true}} \
// pedantic-expected-warning {{always true}} \
// pedantic-expected-warning {{is a GNU extension}}

struct y {int x,y;};
int a2[(intptr_t)&((struct y*)0)->y]; // expected-warning {{folded to constant array}} \
// pedantic-expected-warning {{folded to constant array}} \
// ref-warning {{folded to constant array}} \
// pedantic-ref-warning {{folded to constant array}}
int a2[(intptr_t)&((struct y*)0)->y]; // all-warning {{folded to constant array}}

const struct y *yy = (struct y*)0;
const intptr_t L = (intptr_t)(&(yy->y)); // expected-error {{not a compile-time constant}} \
// pedantic-expected-error {{not a compile-time constant}} \
// ref-error {{not a compile-time constant}} \
// pedantic-ref-error {{not a compile-time constant}}
const intptr_t L = (intptr_t)(&(yy->y)); // all-error {{not a compile-time constant}}

const ptrdiff_t m = &m + 137 - &m;
_Static_assert(m == 137, ""); // pedantic-ref-warning {{GNU extension}} \
// pedantic-expected-warning {{GNU extension}}

/// from test/Sema/switch.c, used to cause an assertion failure.
void f (int z) {
while (z) {
default: z--; // expected-error {{'default' statement not in switch}} \
// pedantic-expected-error {{'default' statement not in switch}} \
// ref-error {{'default' statement not in switch}} \
// pedantic-ref-error {{'default' statement not in switch}}
default: z--; // all-error {{'default' statement not in switch}}
}
}

int expr;
int chooseexpr[__builtin_choose_expr(1, 1, expr)];

int somefunc(int i) {
return (i, 65537) * 65537; // expected-warning {{left operand of comma operator has no effect}} \
// expected-warning {{overflow in expression; result is 131073}} \
// pedantic-expected-warning {{left operand of comma operator has no effect}} \
// pedantic-expected-warning {{overflow in expression; result is 131073}} \
// ref-warning {{left operand of comma operator has no effect}} \
// ref-warning {{overflow in expression; result is 131073}} \
// pedantic-ref-warning {{left operand of comma operator has no effect}} \
// pedantic-ref-warning {{overflow in expression; result is 131073}}

return (i, 65537) * 65537; // all-warning {{left operand of comma operator has no effect}} \
// all-warning {{overflow in expression; result is 131073}}
}

/// FIXME: The following test is incorrect in the new interpreter.
Expand All @@ -129,3 +108,7 @@ _Static_assert(sizeof(name2) == 0, ""); // expected-error {{failed}} \
// expected-note {{evaluates to}} \
// pedantic-expected-error {{failed}} \
// pedantic-expected-note {{evaluates to}}

#ifdef __SIZEOF_INT128__
void *PR28739d = &(&PR28739d)[(__int128)(unsigned long)-1]; // all-warning {{refers past the last possible element}}
#endif
5 changes: 3 additions & 2 deletions clang/test/AST/Interp/complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ constexpr _Complex int I3 = {15};
static_assert(__real(I3) == 15, "");
static_assert(__imag(I3) == 0, "");

/// FIXME: This should work in the new interpreter as well.
// constexpr _Complex _BitInt(8) A = 0;// = {4};
constexpr _Complex _BitInt(8) A = {4};
static_assert(__real(A) == 4, "");
static_assert(__imag(A) == 0, "");


constexpr _Complex double Doubles[4] = {{1.0, 2.0}};
Expand Down
11 changes: 11 additions & 0 deletions clang/test/AST/Interp/records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,3 +1228,14 @@ namespace InheritedConstructor {
constexpr S s(1);
}
}

namespace InvalidCtorInitializer {
struct X {
int Y;
constexpr X() // expected-note {{declared here}}
: Y(fo_o_()) {} // both-error {{use of undeclared identifier 'fo_o_'}}
};
// no crash on evaluating the constexpr ctor.
constexpr int Z = X().Y; // both-error {{constexpr variable 'Z' must be initialized by a constant expression}} \
// expected-note {{undefined constructor 'X'}}
}
2 changes: 2 additions & 0 deletions clang/test/CXX/drs/dr11xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ namespace dr1113 { // dr1113: partial
}
void g() { f(); }
}

// dr1150: na
24 changes: 24 additions & 0 deletions clang/test/CXX/drs/dr14xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,30 @@ enum E2 : S<E2>::I { e };
#endif
} // namespace dr1482

namespace dr1487 { // dr1487: 3.3
#if __cplusplus >= 201103L
struct A { // #dr1482-A
struct B {
using A::A;
// since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'B'}}
};

struct C : A {
// since-cxx11-error@-1 {{base class has incomplete type}}
// since-cxx11-note@#dr1482-A {{definition of 'dr1487::A' is not complete until the closing '}'}}
using A::A;
// since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'C'}}
};

struct D;
};

struct D : A {
using A::A;
};
#endif
} // namespace dr1487

namespace dr1490 { // dr1490: 3.7 c++11
#if __cplusplus >= 201103L
// List-initialization from a string literal
Expand Down
39 changes: 39 additions & 0 deletions clang/test/CXX/drs/dr15xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,45 @@ namespace dr1563 { // dr1563: yes
#endif
}

namespace dr1567 { // dr1567: 3.3
#if __cplusplus >= 201103L
struct B;
struct A {
A(const A&);
A(const B&) = delete;
A(A&&);
A(B&&) = delete;
A(int); // #dr1567-A-int
};

struct B: A { // #dr1567-B
using A::A; // #dr1567-using-A
B(double); // #dr1567-B-double
};

A a{0};
B b{1.0};
// Good, deleted converting ctors are not inherited as copy/move ctors
B b2{b};
B b3{B{1.0}};
// Good, copy/move ctors are not inherited
B b4{a};
// since-cxx11-error@-1 {{no matching constructor for initialization of 'B'}}
// since-cxx11-note@#dr1567-A-int {{candidate inherited constructor not viable: no known conversion from 'A' to 'int' for 1st argument}}
// since-cxx11-note@#dr1567-using-A {{constructor from base class 'A' inherited here}}
// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A' to 'const B' for 1st argument}}
// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'A' to 'B' for 1st argument}}
// since-cxx11-note@#dr1567-B-double {{candidate constructor not viable: no known conversion from 'A' to 'double' for 1st argument}}
B b5{A{0}};
// since-cxx11-error@-1 {{no matching constructor for initialization of 'B'}}
// since-cxx11-note@#dr1567-A-int {{candidate inherited constructor not viable: no known conversion from 'A' to 'int' for 1st argument}}
// since-cxx11-note@#dr1567-using-A {{constructor from base class 'A' inherited here}}
// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A' to 'const B' for 1st argument}}
// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'A' to 'B' for 1st argument}}
// since-cxx11-note@#dr1567-B-double {{candidate constructor not viable: no known conversion from 'A' to 'double' for 1st argument}}
#endif
}

namespace dr1573 { // dr1573: 3.9
#if __cplusplus >= 201103L
// ellipsis is inherited (p0136r1 supersedes this part).
Expand Down
17 changes: 17 additions & 0 deletions clang/test/CXX/drs/dr17xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ S s(q); // #dr1736-s
#endif
}

namespace dr1738 { // dr1738: sup P0136R1
#if __cplusplus >= 201103L
struct A {
template <typename T>
A(int, T) {}
};

struct B : A {
using A::A;
};

// FIXME: this is well-formed since P0136R1
template B::B(int, double);
// since-cxx11-error@-1 {{explicit instantiation of 'B' does not refer to a function template, variable template, member function, member class, or static data member}}
#endif
}

// dr1748 is in dr1748.cpp

namespace dr1753 { // dr1753: 11
Expand Down
41 changes: 41 additions & 0 deletions clang/test/CXX/drs/dr22xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,47 @@ const D &d3(c); // FIXME ill-formed
#endif
}

namespace dr2273 { // dr2273: 3.3
#if __cplusplus >= 201103L
struct A {
A(int = 0) = delete; // #dr2273-A
};

struct B : A { // #dr2273-B
using A::A;
};

B b;
// since-cxx11-error@-1 {{call to implicitly-deleted default constructor of 'B'}}
// since-cxx11-note@#dr2273-B {{default constructor of 'B' is implicitly deleted because base class 'A' has a deleted default constructor}}
// since-cxx11-note@#dr2273-A {{'A' has been explicitly marked deleted here}}
#endif
}

namespace dr2277 { // dr2277: partial
#if __cplusplus >= 201103L
struct A {
A(int, int = 0);
void f(int, int = 0); // #dr2277-A-f
};
struct B : A {
B(int);
using A::A;

void f(int); // #dr2277-B-f
using A::f;
};

void g() {
B b{0};
b.f(0); // FIXME: this is well-formed for the same reason as initialization of 'b' above
// since-cxx11-error@-1 {{call to member function 'f' is ambiguous}}
// since-cxx11-note@#dr2277-A-f {{candidate function}}
// since-cxx11-note@#dr2277-B-f {{candidate function}}
}
#endif
}

namespace dr2292 { // dr2292: 9
#if __cplusplus >= 201103L
template<typename T> using id = T;
Expand Down
25 changes: 25 additions & 0 deletions clang/test/CXX/drs/dr23xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ enum struct alignas(64) B {};
#endif
} // namespace dr2354

namespace dr2356 { // dr2356: 4
#if __cplusplus >= 201103L
struct A {
A();
A(A &&); // #1
template<typename T> A(T &&); // #2
};
struct B : A {
using A::A;
B(const B &); // #3
B(B &&) = default; // #4, implicitly deleted
// since-cxx11-warning@-1 {{explicitly defaulted move constructor is implicitly deleted}}
// since-cxx11-note@#dr2356-X {{move constructor of 'B' is implicitly deleted because field 'x' has a deleted move constructor}}
// since-cxx11-note@#dr2356-X {{'X' has been explicitly marked deleted here}}
// since-cxx11-note@-4 {{replace 'default' with 'delete'}}

struct X { X(X &&) = delete; } x; // #dr2356-X
};
extern B b1;
B b2 = static_cast<B&&>(b1); // calls #3: #1, #2, and #4 are not viable
struct C { operator B&&(); };
B b3 = C(); // calls #3
#endif
}

#if __cplusplus >= 201402L
namespace dr2358 { // dr2358: 16
void f2() {
Expand Down
37 changes: 37 additions & 0 deletions clang/test/CXX/drs/dr2504.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11

namespace dr2504 { // dr2504: no
#if __cplusplus >= 201103L
struct V { V() = default; V(int); };
struct Q { Q(); };
struct A : virtual V, Q {
using V::V;
A() = delete;
};
int bar() { return 42; }
struct B : A {
B() : A(bar()) {} // ok
};
struct C : B {};
void foo() { C c; } // bar is not invoked, because the V subobject is not initialized as part of B
#endif
}

// FIXME: As specified in the comment above (which comes from an example in the Standard),
// we are not supposed to unconditionally call `bar()` and call a constructor
// inherited from `V`.

// SINCE-CXX11-LABEL: define linkonce_odr void @dr2504::B::B()
// SINCE-CXX11-NOT: br
// SINCE-CXX11: call noundef i32 @dr2504::bar()
// SINCE-CXX11-NOT: br
// SINCE-CXX11: call void @dr2504::A::A(int)
// SINCE-CXX11-LABEL: }

// CHECK: {{.*}}
2 changes: 2 additions & 0 deletions clang/test/CXX/drs/dr25xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// expected-no-diagnostics
#endif

// dr2504 is in dr2504.cpp

namespace dr2516 { // dr2516: 3.0
// NB: reusing 1482 test
#if __cplusplus >= 201103L
Expand Down
129 changes: 68 additions & 61 deletions clang/test/CodeGen/attr-target-version.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,20 @@ int hoo(void) {

//.
// CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
// CHECK: @fmv.ifunc = weak_odr ifunc i32 (), ptr @fmv.resolver
// CHECK: @fmv_one.ifunc = weak_odr ifunc i32 (), ptr @fmv_one.resolver
// CHECK: @fmv_two.ifunc = weak_odr ifunc i32 (), ptr @fmv_two.resolver
// CHECK: @fmv_e.ifunc = weak_odr ifunc i32 (), ptr @fmv_e.resolver
// CHECK: @fmv_c.ifunc = weak_odr ifunc void (), ptr @fmv_c.resolver
// CHECK: @fmv_inline.ifunc = weak_odr ifunc i32 (), ptr @fmv_inline.resolver
// CHECK: @fmv_d.ifunc = internal ifunc i32 (), ptr @fmv_d.resolver
// CHECK: @fmv.ifunc = weak_odr alias i32 (), ptr @fmv
// CHECK: @fmv_one.ifunc = weak_odr alias i32 (), ptr @fmv_one
// CHECK: @fmv_two.ifunc = weak_odr alias i32 (), ptr @fmv_two
// CHECK: @fmv_e.ifunc = weak_odr alias i32 (), ptr @fmv_e
// CHECK: @fmv_inline.ifunc = weak_odr alias i32 (), ptr @fmv_inline
// CHECK: @fmv_d.ifunc = internal alias i32 (), ptr @fmv_d
// CHECK: @fmv_c.ifunc = weak_odr alias void (), ptr @fmv_c
// CHECK: @fmv = weak_odr ifunc i32 (), ptr @fmv.resolver
// CHECK: @fmv_one = weak_odr ifunc i32 (), ptr @fmv_one.resolver
// CHECK: @fmv_two = weak_odr ifunc i32 (), ptr @fmv_two.resolver
// CHECK: @fmv_e = weak_odr ifunc i32 (), ptr @fmv_e.resolver
// CHECK: @fmv_inline = weak_odr ifunc i32 (), ptr @fmv_inline.resolver
// CHECK: @fmv_d = internal ifunc i32 (), ptr @fmv_d.resolver
// CHECK: @fmv_c = weak_odr ifunc void (), ptr @fmv_c.resolver
//.
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv._MrngMflagmMfp16fml
Expand All @@ -105,6 +112,32 @@ int hoo(void) {
// CHECK-NEXT: ret i32 1
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_one._MsimdMls64
// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 1
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_two._Mfp
// CHECK-SAME: () #[[ATTR1]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 1
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@foo
// CHECK-SAME: () #[[ATTR2:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = call i32 @fmv()
// CHECK-NEXT: [[CALL1:%.*]] = call i32 @fmv_one()
// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], [[CALL1]]
// CHECK-NEXT: [[CALL2:%.*]] = call i32 @fmv_two()
// CHECK-NEXT: [[ADD3:%.*]] = add nsw i32 [[ADD]], [[CALL2]]
// CHECK-NEXT: ret i32 [[ADD3]]
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
Expand Down Expand Up @@ -183,42 +216,16 @@ int hoo(void) {
// CHECK-NEXT: ret ptr @fmv.default
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_one._MsimdMls64
// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 1
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv_one.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: ret ptr @fmv_one._MsimdMls64
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_two._Mfp
// CHECK-SAME: () #[[ATTR1]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 1
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv_two.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: ret ptr @fmv_two._MsimdMfp16
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@foo
// CHECK-SAME: () #[[ATTR2:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = call i32 @fmv.ifunc()
// CHECK-NEXT: [[CALL1:%.*]] = call i32 @fmv_one.ifunc()
// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], [[CALL1]]
// CHECK-NEXT: [[CALL2:%.*]] = call i32 @fmv_two.ifunc()
// CHECK-NEXT: [[ADD3:%.*]] = add nsw i32 [[ADD]], [[CALL2]]
// CHECK-NEXT: ret i32 [[ADD3]]
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv_e.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: ret ptr @fmv_e._Mls64
Expand All @@ -238,28 +245,14 @@ int hoo(void) {
// CHECK-NEXT: ret void
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv_c.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 281474976710656
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 281474976710656
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: resolver_return:
// CHECK-NEXT: ret ptr @fmv_c._Mssbs
// CHECK: resolver_else:
// CHECK-NEXT: ret ptr @fmv_c.default
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@goo
// CHECK-SAME: () #[[ATTR2]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = call i32 @fmv_inline.ifunc()
// CHECK-NEXT: [[CALL1:%.*]] = call i32 @fmv_e.ifunc()
// CHECK-NEXT: [[CALL2:%.*]] = call i32 @fmv_d.ifunc()
// CHECK-NEXT: call void @fmv_c.ifunc()
// CHECK-NEXT: [[CALL:%.*]] = call i32 @fmv_inline()
// CHECK-NEXT: [[CALL1:%.*]] = call i32 @fmv_e()
// CHECK-NEXT: [[CALL2:%.*]] = call i32 @fmv_d()
// CHECK-NEXT: call void @fmv_c()
// CHECK-NEXT: [[CALL3:%.*]] = call i32 @fmv_default()
// CHECK-NEXT: ret i32 [[CALL3]]
//
Expand Down Expand Up @@ -412,6 +405,20 @@ int hoo(void) {
// CHECK-NEXT: ret ptr @fmv_d.default
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv_c.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 281474976710656
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 281474976710656
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: resolver_return:
// CHECK-NEXT: ret ptr @fmv_c._Mssbs
// CHECK: resolver_else:
// CHECK-NEXT: ret ptr @fmv_c.default
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@recur
// CHECK-SAME: () #[[ATTR2]] {
Expand All @@ -437,9 +444,9 @@ int hoo(void) {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[FP1:%.*]] = alloca ptr, align 8
// CHECK-NEXT: [[FP2:%.*]] = alloca ptr, align 8
// CHECK-NEXT: call void @f(ptr noundef @fmv.ifunc)
// CHECK-NEXT: store ptr @fmv.ifunc, ptr [[FP1]], align 8
// CHECK-NEXT: store ptr @fmv.ifunc, ptr [[FP2]], align 8
// CHECK-NEXT: call void @f(ptr noundef @fmv)
// CHECK-NEXT: store ptr @fmv, ptr [[FP1]], align 8
// CHECK-NEXT: store ptr @fmv, ptr [[FP2]], align 8
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[FP1]], align 8
// CHECK-NEXT: [[CALL:%.*]] = call i32 [[TMP0]]()
// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[FP2]], align 8
Expand Down Expand Up @@ -561,13 +568,6 @@ int hoo(void) {
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_c.default
// CHECK-SAME: () #[[ATTR2]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret void
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._Msha1MpmullMf64mm
// CHECK-SAME: () #[[ATTR12:[0-9]+]] {
// CHECK-NEXT: entry:
Expand Down Expand Up @@ -700,6 +700,13 @@ int hoo(void) {
// CHECK-NEXT: ret i32 1
//
//
// CHECK: Function Attrs: noinline nounwind optnone
// CHECK-LABEL: define {{[^@]+}}@fmv_c.default
// CHECK-SAME: () #[[ATTR2]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret void
//
//
// CHECK-NOFMV: Function Attrs: noinline nounwind optnone
// CHECK-NOFMV-LABEL: define {{[^@]+}}@fmv
// CHECK-NOFMV-SAME: () #[[ATTR0:[0-9]+]] {
Expand Down
87 changes: 45 additions & 42 deletions clang/test/CodeGenCXX/attr-target-version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ int bar() {

//.
// CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
// CHECK: @_Z3fooi.ifunc = weak_odr ifunc i32 (i32), ptr @_Z3fooi.resolver
// CHECK: @_Z3foov.ifunc = weak_odr ifunc i32 (), ptr @_Z3foov.resolver
// CHECK: @_ZN7MyClass3gooEi.ifunc = weak_odr ifunc i32 (ptr, i32), ptr @_ZN7MyClass3gooEi.resolver
// CHECK: @_ZN7MyClass3gooEi.ifunc = weak_odr alias i32 (ptr, i32), ptr @_ZN7MyClass3gooEi
// CHECK: @_Z3fooi.ifunc = weak_odr alias i32 (i32), ptr @_Z3fooi
// CHECK: @_Z3foov.ifunc = weak_odr alias i32 (), ptr @_Z3foov
// CHECK: @_ZN7MyClass3gooEi = weak_odr ifunc i32 (ptr, i32), ptr @_ZN7MyClass3gooEi.resolver
// CHECK: @_Z3fooi = weak_odr ifunc i32 (i32), ptr @_Z3fooi.resolver
// CHECK: @_Z3foov = weak_odr ifunc i32 (), ptr @_Z3foov.resolver
//.
// CHECK-LABEL: @_Z3fooi._Mbf16Msme-f64f64(
// CHECK-NEXT: entry:
Expand All @@ -37,39 +40,11 @@ int bar() {
// CHECK-NEXT: ret i32 1
//
//
// CHECK-LABEL: @_Z3fooi.resolver(
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 36028797153181696
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 36028797153181696
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: resolver_return:
// CHECK-NEXT: ret ptr @_Z3fooi._Mbf16Msme-f64f64
// CHECK: resolver_else:
// CHECK-NEXT: ret ptr @_Z3fooi.default
//
//
// CHECK-LABEL: @_Z3foov._Msm4Mebf16(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 3
//
//
// CHECK-LABEL: @_Z3foov.resolver(
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 268435488
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 268435488
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: resolver_return:
// CHECK-NEXT: ret ptr @_Z3foov._Msm4Mebf16
// CHECK: resolver_else:
// CHECK-NEXT: ret ptr @_Z3foov.default
//
//
// CHECK-LABEL: @_ZN7MyClass3gooEi.resolver(
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
Expand All @@ -95,24 +70,40 @@ int bar() {
// CHECK-LABEL: @_Z3barv(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[M:%.*]] = alloca [[STRUCT_MYCLASS:%.*]], align 1
// CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_ZN7MyClass3gooEi.ifunc(ptr noundef nonnull align 1 dereferenceable(1) [[M]], i32 noundef 1)
// CHECK-NEXT: [[CALL1:%.*]] = call noundef i32 @_Z3fooi.ifunc(i32 noundef 1)
// CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_ZN7MyClass3gooEi(ptr noundef nonnull align 1 dereferenceable(1) [[M]], i32 noundef 1)
// CHECK-NEXT: [[CALL1:%.*]] = call noundef i32 @_Z3fooi(i32 noundef 1)
// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], [[CALL1]]
// CHECK-NEXT: [[CALL2:%.*]] = call noundef i32 @_Z3foov.ifunc()
// CHECK-NEXT: [[CALL2:%.*]] = call noundef i32 @_Z3foov()
// CHECK-NEXT: [[ADD3:%.*]] = add nsw i32 [[ADD]], [[CALL2]]
// CHECK-NEXT: ret i32 [[ADD3]]
//
//
// CHECK-LABEL: @_Z3fooi.default(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[DOTADDR:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i32 [[TMP0:%.*]], ptr [[DOTADDR]], align 4
// CHECK-NEXT: ret i32 2
// CHECK-LABEL: @_Z3fooi.resolver(
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 36028797153181696
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 36028797153181696
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: resolver_return:
// CHECK-NEXT: ret ptr @_Z3fooi._Mbf16Msme-f64f64
// CHECK: resolver_else:
// CHECK-NEXT: ret ptr @_Z3fooi.default
//
//
// CHECK-LABEL: @_Z3foov.default(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 4
// CHECK-LABEL: @_Z3foov.resolver(
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 268435488
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 268435488
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: resolver_return:
// CHECK-NEXT: ret ptr @_Z3foov._Msm4Mebf16
// CHECK: resolver_else:
// CHECK-NEXT: ret ptr @_Z3foov.default
//
//
// CHECK-LABEL: @_ZN7MyClass3gooEi._Mdotprod(
Expand Down Expand Up @@ -144,6 +135,18 @@ int bar() {
// CHECK-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
// CHECK-NEXT: ret i32 1
//
//
// CHECK-LABEL: @_Z3fooi.default(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[DOTADDR:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i32 [[TMP0:%.*]], ptr [[DOTADDR]], align 4
// CHECK-NEXT: ret i32 2
//
//
// CHECK-LABEL: @_Z3foov.default(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 4
//
//.
// CHECK: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+sme,+sme-f64f64" }
// CHECK: attributes #[[ATTR1:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+fp-armv8,+neon,+sm4" }
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Driver/tls-dialect.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// RUN: %clang -### --target=riscv64-linux %s 2>&1 | FileCheck --check-prefix=NODESC %s
// RUN: %clang -### --target=x86_64-linux -mtls-dialect=gnu %s 2>&1 | FileCheck --check-prefix=NODESC %s

/// Android supports TLSDESC by default on RISC-V
/// TLSDESC is not on by default in Linux, even on RISC-V, and is covered above
// RUN: %clang -### --target=riscv64-android %s 2>&1 | FileCheck --check-prefix=DESC %s

/// LTO
// RUN: %clang -### --target=riscv64-linux -flto -mtls-dialect=desc %s 2>&1 | FileCheck --check-prefix=LTO-DESC %s
// RUN: %clang -### --target=riscv64-linux -flto %s 2>&1 | FileCheck --check-prefix=LTO-NODESC %s
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Driver/xros-driver-requires-darwin-host.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// REQUIRES: system-darwin

// RUN: env XROS_DEPLOYMENT_TARGET=1.0 %clang -arch arm64 -c -### %s 2>&1 | FileCheck %s

// RUN: rm -rf %t.dir
// RUN: mkdir -p %t.dir/XROS1.0.sdk
// RUN: %clang -arch arm64 -isysroot %t.dir/XROS1.0.sdk -c -### %s 2>&1 | FileCheck %s
// RUN: mkdir -p %t.dir/XRSimulator1.0.sdk
// RUN: %clang -arch arm64 -isysroot %t.dir/XRSimulator1.0.sdk -c -### %s 2>&1 | FileCheck --check-prefix=CHECK_SIM %s


// CHECK: "-cc1"{{.*}} "-triple" "arm64-apple-xros1.0.0"
// CHECK_SIM: "-cc1"{{.*}} "-triple" "arm64-apple-xros1.0.0-simulator"
1 change: 1 addition & 0 deletions clang/test/Sema/ms_predefined_expr.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexperimental-new-constant-interpreter

using size_t = __SIZE_TYPE__;

Expand Down
2 changes: 2 additions & 0 deletions clang/test/SemaCXX/conditional-expr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify=expected,expected-cxx11 -std=c++11 -Wsign-conversion %s
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify=expected,expected-cxx11 -std=c++11 -Wsign-conversion %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify=expected,expected-cxx17 -std=c++17 -Wsign-conversion %s
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify=expected,expected-cxx17 -std=c++17 -Wsign-conversion %s -fexperimental-new-constant-interpreter

// C++ rules for ?: are a lot stricter than C rules, and have to take into
// account more conversion options.
Expand Down
22 changes: 22 additions & 0 deletions clang/test/SemaCXX/crash-GH10518.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %clang_cc1 -verify -std=c++98 %s
// RUN: %clang_cc1 -verify -std=c++11 %s
// RUN: %clang_cc1 -verify -std=c++14 %s
// RUN: %clang_cc1 -verify -std=c++17 %s
// RUN: %clang_cc1 -verify -std=c++20 %s
// RUN: %clang_cc1 -verify -std=c++23 %s
// RUN: %clang_cc1 -verify -std=c++2c %s

// https://github.com/llvm/llvm-project/issues/10518

template <class T>
class A : public T {
};

template <class T>
class B : public A<T> {
};

template <class T>
class B<int> : public A<T> { // expected-error 0-1 {{}}
B(T *t) {}
};
13 changes: 13 additions & 0 deletions clang/test/SemaCXX/crash-GH49103-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -verify -std=c++98 %s
// RUN: %clang_cc1 -verify -std=c++11 %s
// RUN: %clang_cc1 -verify -std=c++14 %s
// RUN: %clang_cc1 -verify -std=c++17 %s
// RUN: %clang_cc1 -verify -std=c++20 %s
// RUN: %clang_cc1 -verify -std=c++23 %s
// RUN: %clang_cc1 -verify -std=c++2c %s

// https://github.com/llvm/llvm-project/issues/49103

template<class> struct A; // expected-note 0+ {{}}
struct S : __make_integer_seq<A, int, 42> { }; // expected-error 0+ {{}}
S s;
78 changes: 78 additions & 0 deletions clang/test/SemaCXX/crash-GH67914.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// RUN: %clang_cc1 -verify -std=c++98 %s
// RUN: %clang_cc1 -verify -std=c++11 %s
// RUN: %clang_cc1 -verify -std=c++14 %s
// RUN: %clang_cc1 -verify -std=c++17 %s
// RUN: %clang_cc1 -verify -std=c++20 %s
// RUN: %clang_cc1 -verify -std=c++23 %s
// RUN: %clang_cc1 -verify -std=c++2c %s

// https://github.com/llvm/llvm-project/issues/67914

template < typename, int >
struct Mask;

template < int, class >
struct conditional {
using type = Mask< int, 16 >; // expected-warning 0+ {{}}
};

template < class _Then >
struct conditional< 0, _Then > {
using type = _Then; // expected-warning 0+ {{}}
};

template < int _Bp, class, class _Then >
using conditional_t = typename conditional< _Bp, _Then >::type; // expected-warning 0+ {{}}

template < typename, int >
struct Array;

template < typename, int, bool, typename >
struct StaticArrayImpl;

template < typename Value_, int Size_ >
struct Mask : StaticArrayImpl< Value_, Size_, 1, Mask< Value_, Size_ > > { // expected-note 0+ {{}}
template < typename T1 >
Mask(T1) {} // expected-note 0+ {{}}
};

template < typename T >
void load(typename T::MaskType mask) {
T::load_(mask); // expected-note 0+ {{}}
}

template < typename Value_, int IsMask_, typename Derived_ >
struct StaticArrayImpl< Value_, 32, IsMask_, Derived_ > {
using Array1 = conditional_t< IsMask_, void, Array< Value_, 16 > >; // expected-warning 0+ {{}}

template < typename Mask >
static Derived_ load_(Mask mask) {
return Derived_{load< Array1 >(mask.a1), Mask{}}; // expected-error 0+ {{}}
}

Array1 a1;
};

template < typename Derived_ >
struct KMaskBase;

template < typename Derived_ >
struct StaticArrayImpl< float, 16, 0, Derived_ > {
template < typename Mask >
static Derived_ load_(Mask mask);
};

template < typename Derived_ >
struct StaticArrayImpl< float, 16, 1, Mask< float, 16 > > : KMaskBase< Derived_ > {}; // expected-error 0+ {{}}

template < typename Derived_ >
struct StaticArrayImpl< int, 16, 1, Derived_ > {};

template < typename Value_, int Size_ >
struct Array : StaticArrayImpl< Value_, Size_, 0, Array< Value_, Size_ > > {
using MaskType = Mask< Value_, Size_ >; // expected-warning 0+ {{}}
};

void test11_load_masked() {
load< Array< float, 32 > >{} == 0; // expected-error 0+ {{}} expected-warning 0+ {{}} expected-note 0+ {{}}
}
17 changes: 17 additions & 0 deletions clang/test/SemaCXX/crash-GH78388.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %clang_cc1 -verify -std=c++98 %s
// RUN: %clang_cc1 -verify -std=c++11 %s
// RUN: %clang_cc1 -verify -std=c++14 %s
// RUN: %clang_cc1 -verify -std=c++17 %s
// RUN: %clang_cc1 -verify -std=c++20 %s
// RUN: %clang_cc1 -verify -std=c++23 %s
// RUN: %clang_cc1 -verify -std=c++2c %s

// https://github.com/llvm/llvm-project/issues/78388

typedef mbstate_t; // expected-error 0+ {{}} expected-note 0+ {{}}
template < typename , typename , typename >
class a // expected-error 0+ {{}}
class b { // expected-error 0+ {{}}
namespace { // expected-note 0+ {{}} expected-note 0+ {{}}
template < typename c > b::operator=() { // expected-error 0+ {{}} expected-note 0+ {{}}
struct :a< c, char, stdmbstate_t > d // expected-error 0+ {{}} expected-warning 0+ {{}}
1 change: 1 addition & 0 deletions clang/test/SemaCXX/expression-traits.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions %s
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions %s -fexperimental-new-constant-interpreter

//
// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
Expand Down
1 change: 1 addition & 0 deletions clang/test/SemaCXX/self-comparison.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++2a
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++2a -fexperimental-new-constant-interpreter

int foo(int x) {
return x == x; // expected-warning {{self-comparison always evaluates to true}}
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaCXX/warn-unused-filescoped-fmv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify -Wunused -std=c++98 %s
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify -Wunused -std=c++14 %s

__attribute__((target_version("fp16")))
static int not_used_fmv(void) { return 1; }
__attribute__((target_version("fp16fml")))
static int not_used_fmv(void) { return 2; }
__attribute__((target_version("default")))
static int not_used_fmv(void) { return 0; } // expected-warning {{unused function 'not_used_fmv'}}


__attribute__((target_version("fp16")))
static int definitely_used_fmv(void) { return 1; }
__attribute__((target_version("fp16fml")))
static int definitely_used_fmv(void) { return 2; }
__attribute__((target_version("default")))
static int definitely_used_fmv(void) { return 0; }
int definite_user(void) { return definitely_used_fmv(); }
3 changes: 3 additions & 0 deletions clang/unittests/Format/QualifierFixerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ TEST_F(QualifierFixerTest, IsQualifierType) {

auto Tokens = annotate(
"const static inline auto restrict int double long constexpr friend");
ASSERT_EQ(Tokens.size(), 11u) << Tokens;

EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
Tokens[0], ConfiguredTokens));
Expand Down Expand Up @@ -1089,6 +1090,7 @@ TEST_F(QualifierFixerTest, IsQualifierType) {
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[9]));

auto NotTokens = annotate("for while do Foo Bar ");
ASSERT_EQ(NotTokens.size(), 6u) << Tokens;

EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
NotTokens[0], ConfiguredTokens));
Expand Down Expand Up @@ -1120,6 +1122,7 @@ TEST_F(QualifierFixerTest, IsQualifierType) {
TEST_F(QualifierFixerTest, IsMacro) {

auto Tokens = annotate("INT INTPR Foo int");
ASSERT_EQ(Tokens.size(), 5u) << Tokens;

EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isPossibleMacro(Tokens[0]));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isPossibleMacro(Tokens[1]));
Expand Down
2 changes: 1 addition & 1 deletion clang/utils/TableGen/ClangBuiltinsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void EmitBuiltinDef(llvm::raw_ostream &OS, StringRef Substitution,
break;
}
case BuiltinType::TargetBuiltin:
OS << ", \"\"";
OS << ", \"" << Builtin->getValueAsString("Features") << "\"";
break;
case BuiltinType::AtomicBuiltin:
case BuiltinType::Builtin:
Expand Down
16 changes: 8 additions & 8 deletions clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -6708,7 +6708,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1150.html">1150</a></td>
<td>NAD</td>
<td>Inheriting constructors have not been implemented</td>
<td class="unknown" align="center">Unknown</td>
<td class="na" align="center">N/A</td>
</tr>
<tr id="1151">
<td><a href="https://cplusplus.github.io/CWG/issues/1151.html">1151</a></td>
Expand Down Expand Up @@ -8730,7 +8730,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1487.html">1487</a></td>
<td>CD3</td>
<td>When are inheriting constructors declared?</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 3.3</td>
</tr>
<tr class="open" id="1488">
<td><a href="https://cplusplus.github.io/CWG/issues/1488.html">1488</a></td>
Expand Down Expand Up @@ -9210,7 +9210,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1567.html">1567</a></td>
<td>C++14</td>
<td>Inheriting constructors and copy/move constructors</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 3.3</td>
</tr>
<tr id="1568">
<td><a href="https://cplusplus.github.io/CWG/issues/1568.html">1568</a></td>
Expand Down Expand Up @@ -10236,7 +10236,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1738.html">1738</a></td>
<td>C++14</td>
<td>Explicit instantiation/specialization of inheriting constructor templates</td>
<td class="unknown" align="center">Unknown</td>
<td class="na" align="center">Superseded by <a href="https://wg21.link/P0136R1">P0136R1</a></td>
</tr>
<tr id="1739">
<td><a href="https://cplusplus.github.io/CWG/issues/1739.html">1739</a></td>
Expand Down Expand Up @@ -13446,7 +13446,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/2273.html">2273</a></td>
<td>CD5</td>
<td>Inheriting constructors vs implicit default constructor</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 3.3</td>
</tr>
<tr id="2274">
<td><a href="https://cplusplus.github.io/CWG/issues/2274.html">2274</a></td>
Expand All @@ -13470,7 +13470,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/2277.html">2277</a></td>
<td>CD5</td>
<td>Ambiguity inheriting constructors with default arguments</td>
<td class="unknown" align="center">Unknown</td>
<td class="partial" align="center">Partial</td>
</tr>
<tr id="2278">
<td><a href="https://cplusplus.github.io/CWG/issues/2278.html">2278</a></td>
Expand Down Expand Up @@ -13944,7 +13944,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/2356.html">2356</a></td>
<td>CD5</td>
<td>Base class copy and move constructors should not be inherited</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 4</td>
</tr>
<tr id="2357">
<td><a href="https://cplusplus.github.io/CWG/issues/2357.html">2357</a></td>
Expand Down Expand Up @@ -14832,7 +14832,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/2504.html">2504</a></td>
<td>DR</td>
<td>Inheriting constructors from virtual base classes</td>
<td class="unknown" align="center">Unknown</td>
<td class="none" align="center">No</td>
</tr>
<tr class="open" id="2505">
<td><a href="https://cplusplus.github.io/CWG/issues/2505.html">2505</a></td>
Expand Down
1 change: 1 addition & 0 deletions flang/include/flang/Evaluate/characteristics.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct DummyDataObject {
static std::optional<DummyDataObject> Characterize(
const semantics::Symbol &, FoldingContext &);
bool CanBePassedViaImplicitInterface(std::string *whyNot = nullptr) const;
bool IsPassedByDescriptor(bool isBindC) const;
llvm::raw_ostream &Dump(llvm::raw_ostream &) const;

TypeAndShape type;
Expand Down
6 changes: 4 additions & 2 deletions flang/include/flang/Optimizer/Builder/FIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,14 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
llvm::StringRef name,
mlir::StringAttr linkage = {},
mlir::Attribute value = {}, bool isConst = false,
bool isTarget = false);
bool isTarget = false,
fir::CUDAAttributeAttr cudaAttr = {});

fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
llvm::StringRef name, bool isConst, bool isTarget,
std::function<void(FirOpBuilder &)> bodyBuilder,
mlir::StringAttr linkage = {});
mlir::StringAttr linkage = {},
fir::CUDAAttributeAttr cudaAttr = {});

/// Create a global constant (read-only) value.
fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
Expand Down
3 changes: 2 additions & 1 deletion flang/include/flang/Optimizer/Dialect/FIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,8 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
OptionalAttr<AnyAttr>:$initVal,
OptionalAttr<UnitAttr>:$constant,
OptionalAttr<UnitAttr>:$target,
OptionalAttr<StrAttr>:$linkName
OptionalAttr<StrAttr>:$linkName,
OptionalAttr<fir_CUDAAttributeAttr>:$cuda_attr
);

let regions = (region AtMostRegion<1>:$region);
Expand Down
28 changes: 28 additions & 0 deletions flang/lib/Evaluate/characteristics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,34 @@ bool DummyDataObject::CanBePassedViaImplicitInterface(
}
}

bool DummyDataObject::IsPassedByDescriptor(bool isBindC) const {
constexpr TypeAndShape::Attrs shapeRequiringBox = {
TypeAndShape::Attr::AssumedShape, TypeAndShape::Attr::DeferredShape,
TypeAndShape::Attr::AssumedRank, TypeAndShape::Attr::Coarray};
if ((attrs & Attrs{Attr::Allocatable, Attr::Pointer}).any()) {
return true;
} else if ((type.attrs() & shapeRequiringBox).any()) {
// Need to pass shape/coshape info in a descriptor.
return true;
} else if (type.type().IsPolymorphic() && !type.type().IsAssumedType()) {
// Need to pass dynamic type info in a descriptor.
return true;
} else if (const auto *derived{GetDerivedTypeSpec(type.type())}) {
if (!derived->parameters().empty()) {
for (const auto &param : derived->parameters()) {
if (param.second.isLen()) {
// Need to pass length type parameters in a descriptor.
return true;
}
}
}
} else if (isBindC && type.type().IsAssumedLengthCharacter()) {
// Fortran 2018 18.3.6 point 2 (5)
return true;
}
return false;
}

llvm::raw_ostream &DummyDataObject::Dump(llvm::raw_ostream &o) const {
attrs.Dump(o, EnumToString);
if (intent != common::Intent::Default) {
Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3115,10 +3115,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
hlfir::Entity nullBoxProc(
fir::factory::createNullBoxProc(*builder, loc, boxTy));
builder->createStoreWithConvert(loc, nullBoxProc, pptr);
return;
} else {
fir::MutableBoxValue box = genExprMutableBox(loc, *expr);
fir::factory::disassociateMutableBox(*builder, loc, box);
}
fir::MutableBoxValue box = genExprMutableBox(loc, *expr);
fir::factory::disassociateMutableBox(*builder, loc, box);
}
}

Expand Down
27 changes: 1 addition & 26 deletions flang/lib/Lower/CallInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,31 +916,6 @@ class Fortran::lower::CallInterfaceImpl {
}
}

// Define when an explicit argument must be passed in a fir.box.
bool dummyRequiresBox(
const Fortran::evaluate::characteristics::DummyDataObject &obj,
bool isBindC) {
using ShapeAttr = Fortran::evaluate::characteristics::TypeAndShape::Attr;
using ShapeAttrs = Fortran::evaluate::characteristics::TypeAndShape::Attrs;
constexpr ShapeAttrs shapeRequiringBox = {
ShapeAttr::AssumedShape, ShapeAttr::DeferredShape,
ShapeAttr::AssumedRank, ShapeAttr::Coarray};
if ((obj.type.attrs() & shapeRequiringBox).any())
// Need to pass shape/coshape info in fir.box.
return true;
if (obj.type.type().IsPolymorphic() && !obj.type.type().IsAssumedType())
// Need to pass dynamic type info in fir.box.
return true;
if (const Fortran::semantics::DerivedTypeSpec *derived =
Fortran::evaluate::GetDerivedTypeSpec(obj.type.type()))
if (const Fortran::semantics::Scope *scope = derived->scope())
// Need to pass length type parameters in fir.box if any.
return scope->IsDerivedTypeWithLengthParameter();
if (isBindC && obj.type.type().IsAssumedLengthCharacter())
return true; // Fortran 2018 18.3.6 point 2 (5)
return false;
}

mlir::Type
translateDynamicType(const Fortran::evaluate::DynamicType &dynamicType) {
Fortran::common::TypeCategory cat = dynamicType.category();
Expand Down Expand Up @@ -1027,7 +1002,7 @@ class Fortran::lower::CallInterfaceImpl {
addFirOperand(boxRefType, nextPassedArgPosition(), Property::MutableBox,
attrs);
addPassedArg(PassEntityBy::MutableBox, entity, characteristics);
} else if (dummyRequiresBox(obj, isBindC)) {
} else if (obj.IsPassedByDescriptor(isBindC)) {
// Pass as fir.box or fir.class
if (isValueAttr &&
!getConverter().getLoweringOptions().getLowerToHighLevelFIR())
Expand Down
16 changes: 11 additions & 5 deletions flang/lib/Lower/ConvertVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ static bool isConstant(const Fortran::semantics::Symbol &sym) {
static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
const Fortran::lower::pft::Variable &var,
llvm::StringRef globalName,
mlir::StringAttr linkage);
mlir::StringAttr linkage,
fir::CUDAAttributeAttr cudaAttr = {});

static mlir::Location genLocation(Fortran::lower::AbstractConverter &converter,
const Fortran::semantics::Symbol &sym) {
Expand Down Expand Up @@ -462,7 +463,8 @@ void Fortran::lower::createGlobalInitialization(
static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
const Fortran::lower::pft::Variable &var,
llvm::StringRef globalName,
mlir::StringAttr linkage) {
mlir::StringAttr linkage,
fir::CUDAAttributeAttr cudaAttr) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
const Fortran::semantics::Symbol &sym = var.getSymbol();
mlir::Location loc = genLocation(converter, sym);
Expand Down Expand Up @@ -500,8 +502,9 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
}
}
if (!global)
global = builder.createGlobal(loc, symTy, globalName, linkage,
mlir::Attribute{}, isConst, var.isTarget());
global =
builder.createGlobal(loc, symTy, globalName, linkage, mlir::Attribute{},
isConst, var.isTarget(), cudaAttr);
if (Fortran::semantics::IsAllocatableOrPointer(sym) &&
!Fortran::semantics::IsProcedure(sym)) {
const auto *details =
Expand Down Expand Up @@ -2219,7 +2222,10 @@ void Fortran::lower::defineModuleVariable(
// Do nothing. Mapping will be done on user side.
} else {
std::string globalName = converter.mangleName(sym);
defineGlobal(converter, var, globalName, linkage);
fir::CUDAAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDAAttribute(
converter.getFirOpBuilder().getContext(), sym);
defineGlobal(converter, var, globalName, linkage, cudaAttr);
}
}

Expand Down
344 changes: 172 additions & 172 deletions flang/lib/Lower/OpenMP.cpp

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions flang/lib/Optimizer/Builder/FIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,27 +271,32 @@ mlir::Value fir::FirOpBuilder::createHeapTemporary(

/// Create a global variable in the (read-only) data section. A global variable
/// must have a unique name to identify and reference it.
fir::GlobalOp fir::FirOpBuilder::createGlobal(mlir::Location loc,
mlir::Type type,
llvm::StringRef name,
mlir::StringAttr linkage,
mlir::Attribute value,
bool isConst, bool isTarget) {
fir::GlobalOp fir::FirOpBuilder::createGlobal(
mlir::Location loc, mlir::Type type, llvm::StringRef name,
mlir::StringAttr linkage, mlir::Attribute value, bool isConst,
bool isTarget, fir::CUDAAttributeAttr cudaAttr) {
auto module = getModule();
auto insertPt = saveInsertionPoint();
if (auto glob = module.lookupSymbol<fir::GlobalOp>(name))
return glob;
setInsertionPoint(module.getBody(), module.getBody()->end());
auto glob =
create<fir::GlobalOp>(loc, name, isConst, isTarget, type, value, linkage);
llvm::SmallVector<mlir::NamedAttribute> attrs;
if (cudaAttr) {
auto globalOpName = mlir::OperationName(fir::GlobalOp::getOperationName(),
module.getContext());
attrs.push_back(mlir::NamedAttribute(
fir::GlobalOp::getCudaAttrAttrName(globalOpName), cudaAttr));
}
auto glob = create<fir::GlobalOp>(loc, name, isConst, isTarget, type, value,
linkage, attrs);
restoreInsertionPoint(insertPt);
return glob;
}

fir::GlobalOp fir::FirOpBuilder::createGlobal(
mlir::Location loc, mlir::Type type, llvm::StringRef name, bool isConst,
bool isTarget, std::function<void(FirOpBuilder &)> bodyBuilder,
mlir::StringAttr linkage) {
mlir::StringAttr linkage, fir::CUDAAttributeAttr cudaAttr) {
auto module = getModule();
auto insertPt = saveInsertionPoint();
if (auto glob = module.lookupSymbol<fir::GlobalOp>(name))
Expand Down
16 changes: 11 additions & 5 deletions flang/lib/Semantics/canonicalize-omp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ class CanonicalizationOfOmp {
auto &dir{std::get<parser::OmpLoopDirective>(beginDir.t)};

nextIt = it;
if (++nextIt != block.end()) {
while (++nextIt != block.end()) {
// Ignore compiler directives.
if (auto *directive{GetConstructIf<parser::CompilerDirective>(*nextIt)})
continue;

if (auto *doCons{GetConstructIf<parser::DoConstruct>(*nextIt)}) {
if (doCons->GetLoopControl()) {
// move DoConstruct
Expand All @@ -111,12 +115,14 @@ class CanonicalizationOfOmp {
"DO loop after the %s directive must have loop control"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
}
return; // found do-loop
} else {
messages_.Say(dir.source,
"A DO loop must follow the %s directive"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
}
// If we get here, we either found a loop, or issued an error message.
return;
}
messages_.Say(dir.source,
"A DO loop must follow the %s directive"_err_en_US,
parser::ToUpperCaseLetters(dir.source.ToString()));
}

void RewriteOmpAllocations(parser::ExecutionPart &body) {
Expand Down
14 changes: 9 additions & 5 deletions flang/lib/Semantics/runtime-type-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ void RuntimeTableBuilder::DescribeSpecialProc(
which = scalarFinalEnum_;
if (int rank{evaluate::GetRank(typeAndShape.shape())}; rank > 0) {
which = IntExpr<1>(ToInt64(which).value() + rank);
if (!proc->dummyArguments[0].CanBePassedViaImplicitInterface()) {
if (dummyData.IsPassedByDescriptor(proc->IsBindC())) {
argThatMightBeDescriptor = 1;
}
if (!typeAndShape.attrs().test(evaluate::characteristics::
Expand Down Expand Up @@ -1187,10 +1187,14 @@ void RuntimeTableBuilder::DescribeSpecialProc(
break;
}
}
if (argThatMightBeDescriptor != 0 &&
!proc->dummyArguments.at(argThatMightBeDescriptor - 1)
.CanBePassedViaImplicitInterface()) {
isArgDescriptorSet |= 1 << (argThatMightBeDescriptor - 1);
if (argThatMightBeDescriptor != 0) {
if (const auto *dummyData{
std::get_if<evaluate::characteristics::DummyDataObject>(
&proc->dummyArguments.at(argThatMightBeDescriptor - 1).u)}) {
if (dummyData->IsPassedByDescriptor(proc->IsBindC())) {
isArgDescriptorSet |= 1 << (argThatMightBeDescriptor - 1);
}
}
}
evaluate::StructureConstructorValues values;
auto index{evaluate::ToInt64(which)};
Expand Down
51 changes: 30 additions & 21 deletions flang/test/Lower/CUDA/cuda-data-attribute.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,62 @@

! Test lowering of CUDA attribute on variables.

module cuda_var
real, constant :: mod_a_rc
! CHECK: fir.global @_QMcuda_varEmod_a_rc {cuda_attr = #fir.cuda<constant>} : f32
real, device :: mod_b_ra
! CHECK: fir.global @_QMcuda_varEmod_b_ra {cuda_attr = #fir.cuda<device>} : f32
real, allocatable, managed :: mod_c_rm
! CHECK: fir.global @_QMcuda_varEmod_c_rm {cuda_attr = #fir.cuda<managed>} : !fir.box<!fir.heap<f32>>
real, allocatable, pinned :: mod_d_rp
! CHECK: fir.global @_QMcuda_varEmod_d_rp {cuda_attr = #fir.cuda<pinned>} : !fir.box<!fir.heap<f32>>

contains

subroutine local_var_attrs
real, constant :: rc
real, device :: rd
real, allocatable, managed :: rm
real, allocatable, pinned :: rp
end subroutine

! CHECK-LABEL: func.func @_QPlocal_var_attrs()
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<constant>, uniq_name = "_QFlocal_var_attrsErc"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<device>, uniq_name = "_QFlocal_var_attrsErd"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<managed>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFlocal_var_attrsErm"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<pinned>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFlocal_var_attrsErp"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
! CHECK-LABEL: func.func @_QMcuda_varPlocal_var_attrs()
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<constant>, uniq_name = "_QMcuda_varFlocal_var_attrsErc"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<device>, uniq_name = "_QMcuda_varFlocal_var_attrsErd"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<managed>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMcuda_varFlocal_var_attrsErm"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
! CHECK: %{{.*}}:2 = hlfir.declare %{{.*}} {cuda_attr = #fir.cuda<pinned>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMcuda_varFlocal_var_attrsErp"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)

! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<constant>, uniq_name = "_QFlocal_var_attrsErc"} : (!fir.ref<f32>) -> !fir.ref<f32>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<device>, uniq_name = "_QFlocal_var_attrsErd"} : (!fir.ref<f32>) -> !fir.ref<f32>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<managed>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFlocal_var_attrsErm"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<pinned>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFlocal_var_attrsErp"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<constant>, uniq_name = "_QMcuda_varFlocal_var_attrsErc"} : (!fir.ref<f32>) -> !fir.ref<f32>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<device>, uniq_name = "_QMcuda_varFlocal_var_attrsErd"} : (!fir.ref<f32>) -> !fir.ref<f32>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<managed>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMcuda_varFlocal_var_attrsErm"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>
! FIR: %{{.*}} = fir.declare %{{.*}} {cuda_attr = #fir.cuda<pinned>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMcuda_varFlocal_var_attrsErp"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>

subroutine dummy_arg_constant(dc)
real, constant :: dc
end subroutine
! CHECK-LABEL: func.func @_QPdummy_arg_constant(
! CHECK-LABEL: func.func @_QMcuda_varPdummy_arg_constant(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<f32> {fir.bindc_name = "dc", fir.cuda_attr = #fir.cuda<constant>}
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<constant>, uniq_name = "_QFdummy_arg_constantEdc"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<constant>, uniq_name = "_QMcuda_varFdummy_arg_constantEdc"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)

subroutine dummy_arg_device(dd)
real, device :: dd
end subroutine
! CHECK-LABEL: func.func @_QPdummy_arg_device(
! CHECK-LABEL: func.func @_QMcuda_varPdummy_arg_device(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<f32> {fir.bindc_name = "dd", fir.cuda_attr = #fir.cuda<device>}) {
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<device>, uniq_name = "_QFdummy_arg_deviceEdd"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<device>, uniq_name = "_QMcuda_varFdummy_arg_deviceEdd"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)

subroutine dummy_arg_managed(dm)
real, allocatable, managed :: dm
end subroutine
! CHECK-LABEL: func.func @_QPdummy_arg_managed(
! CHECK-LABEL: func.func @_QMcuda_varPdummy_arg_managed(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.heap<f32>>> {fir.bindc_name = "dm", fir.cuda_attr = #fir.cuda<managed>}) {
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<managed>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFdummy_arg_managedEdm"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<managed>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMcuda_varFdummy_arg_managedEdm"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)

subroutine dummy_arg_pinned(dp)
real, allocatable, pinned :: dp
end subroutine
! CHECK-LABEL: func.func @_QPdummy_arg_pinned(
! CHECK-LABEL: func.func @_QMcuda_varPdummy_arg_pinned(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.heap<f32>>> {fir.bindc_name = "dp", fir.cuda_attr = #fir.cuda<pinned>}) {
! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<pinned>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFdummy_arg_pinnedEdp"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)




! CHECK: %{{.*}}:2 = hlfir.declare %[[ARG0]] {cuda_attr = #fir.cuda<pinned>, fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMcuda_varFdummy_arg_pinnedEdp"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)

end module
8 changes: 8 additions & 0 deletions flang/test/Semantics/OpenMP/loop-association.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
c = c - 1
END DO outer

! Accept directives between parallel do and actual loop.
!$OMP PARALLEL DO
!DIR$ VECTOR ALIGNED
DO 20 i=1,N
a = a + 0.5
20 CONTINUE
!$OMP END PARALLEL DO

c = 16
!ERROR: DO loop after the PARALLEL DO directive must have loop control
!$omp parallel do
Expand Down
20 changes: 20 additions & 0 deletions flang/test/Semantics/typeinfo09.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
!RUN: bbc --dump-symbols %s | FileCheck %s
!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
! test setting of isargdescriptorset in the runtime type info.

module m
type :: sometype
contains
procedure :: copy => copy_impl
generic :: assignment(=) => copy
end type
interface
subroutine copy_impl(this, x)
import
class(sometype), intent(out) :: this
type(sometype), target, intent(in) :: x
end subroutine
end interface
end module

!CHECK: .s.sometype, SAVE, TARGET (CompilerCreated, ReadOnly): ObjectEntity type: TYPE(specialbinding) shape: 0_8:0_8 init:[specialbinding::specialbinding(which=1_1,isargdescriptorset=1_1,istypebound=1_1,isargcontiguousset=0_1,proc=copy_impl)]
1 change: 1 addition & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ if(LIBC_COMPILER_HAS_FLOAT128)
libc.src.math.ceilf128
libc.src.math.copysignf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fminf128
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ if(LIBC_COMPILER_HAS_FLOAT128)
libc.src.math.ceilf128
libc.src.math.copysignf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fminf128
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ if(LIBC_COMPILER_HAS_FLOAT128)
libc.src.math.ceilf128
libc.src.math.copysignf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fminf128
Expand Down
2 changes: 2 additions & 0 deletions libc/docs/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Basic Operations
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| fdiml | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| fdimf128 | |check| | |check| | | |check| | | | | | | | | |
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| floor | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| floorf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
Expand Down
1 change: 1 addition & 0 deletions libc/spec/stdc.td
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"fdim", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"fdimf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
FunctionSpec<"fdiml", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
GuardedFunctionSpec<"fdimf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_COMPILER_HAS_FLOAT128">,

FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
Expand Down
1 change: 1 addition & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ add_math_entrypoint_object(fabsf128)
add_math_entrypoint_object(fdim)
add_math_entrypoint_object(fdimf)
add_math_entrypoint_object(fdiml)
add_math_entrypoint_object(fdimf128)

add_math_entrypoint_object(floor)
add_math_entrypoint_object(floorf)
Expand Down
20 changes: 20 additions & 0 deletions libc/src/math/fdimf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for fdimf128 ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_FDIMF128_H
#define LLVM_LIBC_SRC_MATH_FDIMF128_H

#include "src/__support/macros/properties/float.h"

namespace LIBC_NAMESPACE {

float128 fdimf128(float128 x, float128 y);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_FDIMF128_H
32 changes: 27 additions & 5 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ add_entrypoint_object(
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.nearest_integer_operations
)

Expand Down Expand Up @@ -215,6 +216,7 @@ add_entrypoint_object(
HDRS
../fabsf128.h
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
Expand Down Expand Up @@ -265,6 +267,7 @@ add_entrypoint_object(
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.nearest_integer_operations
)

Expand Down Expand Up @@ -313,6 +316,7 @@ add_entrypoint_object(
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.nearest_integer_operations
)

Expand Down Expand Up @@ -361,6 +365,7 @@ add_entrypoint_object(
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.nearest_integer_operations
)

Expand Down Expand Up @@ -899,6 +904,7 @@ add_entrypoint_object(
HDRS
../copysignf128.h
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.manipulation_functions
COMPILE_OPTIONS
-O3
Expand Down Expand Up @@ -1298,6 +1304,7 @@ add_entrypoint_object(
HDRS
../fminf128.h
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
Expand Down Expand Up @@ -1346,6 +1353,7 @@ add_entrypoint_object(
HDRS
../fmaxf128.h
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
Expand Down Expand Up @@ -1394,6 +1402,7 @@ add_entrypoint_object(
HDRS
../sqrtf128.h
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.sqrt
COMPILE_OPTIONS
-O3
Expand Down Expand Up @@ -1491,10 +1500,10 @@ add_entrypoint_object(
fdim.cpp
HDRS
../fdim.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -1503,10 +1512,10 @@ add_entrypoint_object(
fdimf.cpp
HDRS
../fdimf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -1515,10 +1524,23 @@ add_entrypoint_object(
fdiml.cpp
HDRS
../fdiml.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.basic_operations
)

add_entrypoint_object(
fdimf128
SRCS
fdimf128.cpp
HDRS
../fdimf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.basic_operations
)

add_entrypoint_object(
Expand Down
19 changes: 19 additions & 0 deletions libc/src/math/generic/fdimf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fdimf128 function -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fdimf128.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float128, fdimf128, (float128 x, float128 y)) {
return fputil::fdim(x, y);
}

} // namespace LIBC_NAMESPACE
2 changes: 1 addition & 1 deletion libc/test/src/__support/FPUtil/fpbits_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ template <typename T> constexpr auto make(Sign sign, FP fp) {
case FP::QUIET_NAN:
return T::quiet_nan(sign);
}
};
}

// Tests all properties for all types of float.
TYPED_TEST(LlvmLibcFPBitsTest, Properties, FPTypes) {
Expand Down
17 changes: 14 additions & 3 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,6 @@ add_fp_unittest(
HDRS
FDimTest.h
DEPENDS
libc.include.math
libc.src.math.fdimf
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
Expand All @@ -1022,7 +1021,6 @@ add_fp_unittest(
HDRS
FDimTest.h
DEPENDS
libc.include.math
libc.src.math.fdim
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
Expand All @@ -1037,12 +1035,25 @@ add_fp_unittest(
HDRS
FDimTest.h
DEPENDS
libc.include.math
libc.src.math.fdiml
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fdimf128_test
SUITE
libc-math-smoke-tests
SRCS
fdimf128_test.cpp
HDRS
FDimTest.h
DEPENDS
libc.src.math.fdimf128
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

# FIXME: These tests are currently broken on the GPU.
if(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_fp_unittest(
Expand Down
21 changes: 16 additions & 5 deletions libc/test/src/math/smoke/FDimTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>

template <typename T>
class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
Expand All @@ -26,7 +25,7 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::quiet_nan().get_val();

void test_na_n_arg(FuncPtr func) {
void test_nan_arg(FuncPtr func) {
EXPECT_FP_EQ(nan, func(nan, inf));
EXPECT_FP_EQ(nan, func(neg_inf, nan));
EXPECT_FP_EQ(nan, func(nan, zero));
Expand Down Expand Up @@ -66,12 +65,15 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
FPBits xbits(v), ybits(w);
if (xbits.is_inf_or_nan())
continue;
if (isnan(y) || isinf(y))
if (ybits.is_inf_or_nan())
continue;

T x = xbits.get_val();
T y = ybits.get_val();

if (x > y) {
EXPECT_FP_EQ(x - y, func(x, y));
} else {
Expand All @@ -80,3 +82,12 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
}
}
};

#define LIST_FDIM_TESTS(T, func) \
using LlvmLibcFDimTest = FDimTestTemplate<T>; \
TEST_F(LlvmLibcFDimTest, NaNArg) { test_nan_arg(&func); } \
TEST_F(LlvmLibcFDimTest, InfArg) { test_inf_arg(&func); } \
TEST_F(LlvmLibcFDimTest, NegInfArg) { test_neg_inf_arg(&func); } \
TEST_F(LlvmLibcFDimTest, BothZero) { test_both_zero(&func); } \
TEST_F(LlvmLibcFDimTest, InFloatRange) { test_in_range(&func); } \
static_assert(true, "Require semicolon.")
22 changes: 1 addition & 21 deletions libc/test/src/math/smoke/fdim_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,6 @@

#include "FDimTest.h"

#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdim.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>

using LlvmLibcFDimTest = FDimTestTemplate<double>;

TEST_F(LlvmLibcFDimTest, NaNArg_fdim) { test_na_n_arg(&LIBC_NAMESPACE::fdim); }

TEST_F(LlvmLibcFDimTest, InfArg_fdim) { test_inf_arg(&LIBC_NAMESPACE::fdim); }

TEST_F(LlvmLibcFDimTest, NegInfArg_fdim) {
test_neg_inf_arg(&LIBC_NAMESPACE::fdim);
}

TEST_F(LlvmLibcFDimTest, BothZero_fdim) {
test_both_zero(&LIBC_NAMESPACE::fdim);
}

TEST_F(LlvmLibcFDimTest, InDoubleRange_fdim) {
test_in_range(&LIBC_NAMESPACE::fdim);
}
LIST_FDIM_TESTS(double, LIBC_NAMESPACE::fdim);
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fdimf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fdimf128 --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FDimTest.h"

#include "src/math/fdimf128.h"

LIST_FDIM_TESTS(float128, LIBC_NAMESPACE::fdimf128);
24 changes: 1 addition & 23 deletions libc/test/src/math/smoke/fdimf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@

#include "FDimTest.h"

#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdimf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>

using LlvmLibcFDimTest = FDimTestTemplate<float>;

TEST_F(LlvmLibcFDimTest, NaNArg_fdimf) {
test_na_n_arg(&LIBC_NAMESPACE::fdimf);
}

TEST_F(LlvmLibcFDimTest, InfArg_fdimf) { test_inf_arg(&LIBC_NAMESPACE::fdimf); }

TEST_F(LlvmLibcFDimTest, NegInfArg_fdimf) {
test_neg_inf_arg(&LIBC_NAMESPACE::fdimf);
}

TEST_F(LlvmLibcFDimTest, BothZero_fdimf) {
test_both_zero(&LIBC_NAMESPACE::fdimf);
}

TEST_F(LlvmLibcFDimTest, InFloatRange_fdimf) {
test_in_range(&LIBC_NAMESPACE::fdimf);
}
LIST_FDIM_TESTS(float, LIBC_NAMESPACE::fdimf);
24 changes: 1 addition & 23 deletions libc/test/src/math/smoke/fdiml_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@

#include "FDimTest.h"

#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdiml.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>

using LlvmLibcFDimTest = FDimTestTemplate<long double>;

TEST_F(LlvmLibcFDimTest, NaNArg_fdiml) {
test_na_n_arg(&LIBC_NAMESPACE::fdiml);
}

TEST_F(LlvmLibcFDimTest, InfArg_fdiml) { test_inf_arg(&LIBC_NAMESPACE::fdiml); }

TEST_F(LlvmLibcFDimTest, NegInfArg_fdiml) {
test_neg_inf_arg(&LIBC_NAMESPACE::fdiml);
}

TEST_F(LlvmLibcFDimTest, BothZero_fdiml) {
test_both_zero(&LIBC_NAMESPACE::fdiml);
}

TEST_F(LlvmLibcFDimTest, InLongDoubleRange_fdiml) {
test_in_range(&LIBC_NAMESPACE::fdiml);
}
LIST_FDIM_TESTS(long double, LIBC_NAMESPACE::fdiml);
1 change: 0 additions & 1 deletion libc/test/src/sys/socket/linux/bind_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "src/unistd/close.h"

#include "src/errno/libc_errno.h"
#include "test/UnitTest/LibcTest.h"
#include "test/UnitTest/Test.h"

#include <sys/socket.h> // For AF_UNIX and SOCK_DGRAM
Expand Down
75 changes: 42 additions & 33 deletions libcxx/modules/std.compat.cppm.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,48 @@ module;
#endif

// *** Headers not yet available ***
#if __has_include(<debugging>)
# error "please update the header information for <debugging> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<debugging>)
#if __has_include(<flat_map>)
# error "please update the header information for <flat_map> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<flat_map>)
#if __has_include(<flat_set>)
# error "please update the header information for <flat_set> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<flat_set>)
#if __has_include(<generator>)
# error "please update the header information for <generator> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<generator>)
#if __has_include(<hazard_pointer>)
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<hazard_pointer>)
#if __has_include(<linalg>)
# error "please update the header information for <linalg> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<linalg>)
#if __has_include(<rcu>)
# error "please update the header information for <rcu> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<rcu>)
#if __has_include(<spanstream>)
# error "please update the header information for <spanstream> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<spanstream>)
#if __has_include(<stacktrace>)
# error "please update the header information for <stacktrace> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<stacktrace>)
#if __has_include(<stdfloat>)
# error "please update the header information for <stdfloat> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<stdfloat>)
#if __has_include(<text_encoding>)
# error "please update the header information for <text_encoding> in headers_not_available in utils/libcxx/header_information.py"
#endif // __has_include(<text_encoding>)
//
// This validation is mainly to aid libc++ developers to add modules for new
// headers. On Windows the Windows SDK can be in the include path. This SDK
// contains the MSVC STL headers. This may give false positives when MSVC STL
// provides a header libc++ has not implemented yet. Therefore this validation
// is not done on Windows.
//
#ifndef _WIN32
# if __has_include(<debugging>)
# error "please update the header information for <debugging> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<debugging>)
# if __has_include(<flat_map>)
# error "please update the header information for <flat_map> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<flat_map>)
# if __has_include(<flat_set>)
# error "please update the header information for <flat_set> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<flat_set>)
# if __has_include(<generator>)
# error "please update the header information for <generator> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<generator>)
# if __has_include(<hazard_pointer>)
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<hazard_pointer>)
# if __has_include(<linalg>)
# error "please update the header information for <linalg> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<linalg>)
# if __has_include(<rcu>)
# error "please update the header information for <rcu> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<rcu>)
# if __has_include(<spanstream>)
# error "please update the header information for <spanstream> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<spanstream>)
# if __has_include(<stacktrace>)
# error "please update the header information for <stacktrace> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<stacktrace>)
# if __has_include(<stdfloat>)
# error "please update the header information for <stdfloat> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<stdfloat>)
# if __has_include(<text_encoding>)
# error "please update the header information for <text_encoding> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<text_encoding>)
#endif // _WIN32

export module std.compat;
export import std;
Expand Down
Loading