Skip to content

Commit 7977a1a

Browse files
committed
Merge from 'main' to 'sycl-web' (#16)
CONFLICT (content): Merge conflict in clang/utils/TableGen/TableGenBackends.h CONFLICT (content): Merge conflict in clang/utils/TableGen/TableGen.cpp
2 parents b5ebe45 + 8866793 commit 7977a1a

File tree

68 files changed

+2303
-4312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2303
-4312
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6358,6 +6358,7 @@ def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">;
63586358
// Unsupported:
63596359

63606360
def _SLASH_await : CLFlag<"await">;
6361+
def _SLASH_await_COLON : CLJoined<"await:">;
63616362
def _SLASH_constexpr : CLJoined<"constexpr:">;
63626363
def _SLASH_AI : CLJoinedOrSeparate<"AI">;
63636364
def _SLASH_Bt : CLFlag<"Bt">;

clang/include/clang/Sema/Initialization.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ class InitializationSequence {
804804
SK_ResolveAddressOfOverloadedFunction,
805805

806806
/// Perform a derived-to-base cast, producing an rvalue.
807-
SK_CastDerivedToBaseRValue,
807+
SK_CastDerivedToBasePRValue,
808808

809809
/// Perform a derived-to-base cast, producing an xvalue.
810810
SK_CastDerivedToBaseXValue,

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
608608
Builder.defineMacro("__cpp_designated_initializers", "201707L");
609609
Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L");
610610
//Builder.defineMacro("__cpp_modules", "201907L");
611-
//Builder.defineMacro("__cpp_using_enum", "201907L");
611+
Builder.defineMacro("__cpp_using_enum", "201907L");
612612
}
613613
// C++2b features.
614614
if (LangOpts.CPlusPlus2b)

clang/lib/Sema/SemaExpr.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15800,8 +15800,46 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
1580015800
QualType PromoteType;
1580115801
if (TInfo->getType()->isPromotableIntegerType()) {
1580215802
PromoteType = Context.getPromotedIntegerType(TInfo->getType());
15803-
if (Context.typesAreCompatible(PromoteType, TInfo->getType()))
15803+
// [cstdarg.syn]p1 defers the C++ behavior to what the C standard says,
15804+
// and C2x 7.16.1.1p2 says, in part:
15805+
// If type is not compatible with the type of the actual next argument
15806+
// (as promoted according to the default argument promotions), the
15807+
// behavior is undefined, except for the following cases:
15808+
// - both types are pointers to qualified or unqualified versions of
15809+
// compatible types;
15810+
// - one type is a signed integer type, the other type is the
15811+
// corresponding unsigned integer type, and the value is
15812+
// representable in both types;
15813+
// - one type is pointer to qualified or unqualified void and the
15814+
// other is a pointer to a qualified or unqualified character type.
15815+
// Given that type compatibility is the primary requirement (ignoring
15816+
// qualifications), you would think we could call typesAreCompatible()
15817+
// directly to test this. However, in C++, that checks for *same type*,
15818+
// which causes false positives when passing an enumeration type to
15819+
// va_arg. Instead, get the underlying type of the enumeration and pass
15820+
// that.
15821+
QualType UnderlyingType = TInfo->getType();
15822+
if (const auto *ET = UnderlyingType->getAs<EnumType>())
15823+
UnderlyingType = ET->getDecl()->getIntegerType();
15824+
if (Context.typesAreCompatible(PromoteType, UnderlyingType,
15825+
/*CompareUnqualified*/ true))
1580415826
PromoteType = QualType();
15827+
15828+
// If the types are still not compatible, we need to test whether the
15829+
// promoted type and the underlying type are the same except for
15830+
// signedness. Ask the AST for the correctly corresponding type and see
15831+
// if that's compatible.
15832+
if (!PromoteType.isNull() &&
15833+
PromoteType->isUnsignedIntegerType() !=
15834+
UnderlyingType->isUnsignedIntegerType()) {
15835+
UnderlyingType =
15836+
UnderlyingType->isUnsignedIntegerType()
15837+
? Context.getCorrespondingSignedType(UnderlyingType)
15838+
: Context.getCorrespondingUnsignedType(UnderlyingType);
15839+
if (Context.typesAreCompatible(PromoteType, UnderlyingType,
15840+
/*CompareUnqualified*/ true))
15841+
PromoteType = QualType();
15842+
}
1580515843
}
1580615844
if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float))
1580715845
PromoteType = Context.DoubleTy;

clang/lib/Sema/SemaInit.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,7 +3457,7 @@ LLVM_DUMP_METHOD void InitializedEntity::dump() const {
34573457
void InitializationSequence::Step::Destroy() {
34583458
switch (Kind) {
34593459
case SK_ResolveAddressOfOverloadedFunction:
3460-
case SK_CastDerivedToBaseRValue:
3460+
case SK_CastDerivedToBasePRValue:
34613461
case SK_CastDerivedToBaseXValue:
34623462
case SK_CastDerivedToBaseLValue:
34633463
case SK_BindReference:
@@ -3585,7 +3585,7 @@ void InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType,
35853585
Step S;
35863586
switch (VK) {
35873587
case VK_PRValue:
3588-
S.Kind = SK_CastDerivedToBaseRValue;
3588+
S.Kind = SK_CastDerivedToBasePRValue;
35893589
break;
35903590
case VK_XValue: S.Kind = SK_CastDerivedToBaseXValue; break;
35913591
case VK_LValue: S.Kind = SK_CastDerivedToBaseLValue; break;
@@ -8107,7 +8107,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
81078107
// initializer.
81088108
switch (Steps.front().Kind) {
81098109
case SK_ResolveAddressOfOverloadedFunction:
8110-
case SK_CastDerivedToBaseRValue:
8110+
case SK_CastDerivedToBasePRValue:
81118111
case SK_CastDerivedToBaseXValue:
81128112
case SK_CastDerivedToBaseLValue:
81138113
case SK_BindReference:
@@ -8192,7 +8192,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
81928192
Step->Function.Function);
81938193
break;
81948194

8195-
case SK_CastDerivedToBaseRValue:
8195+
case SK_CastDerivedToBasePRValue:
81968196
case SK_CastDerivedToBaseXValue:
81978197
case SK_CastDerivedToBaseLValue: {
81988198
// We have a derived-to-base cast that produces either an rvalue or an
@@ -9628,8 +9628,8 @@ void InitializationSequence::dump(raw_ostream &OS) const {
96289628
OS << "resolve address of overloaded function";
96299629
break;
96309630

9631-
case SK_CastDerivedToBaseRValue:
9632-
OS << "derived-to-base (rvalue)";
9631+
case SK_CastDerivedToBasePRValue:
9632+
OS << "derived-to-base (prvalue)";
96339633
break;
96349634

96359635
case SK_CastDerivedToBaseXValue:

clang/test/Driver/cl-options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@
420420
// (/Zs is for syntax-only)
421421
// RUN: %clang_cl /Zs \
422422
// RUN: /await \
423+
// RUN: /await:strict \
423424
// RUN: /constexpr:depth1000 /constexpr:backtrace1000 /constexpr:steps1000 \
424425
// RUN: /AIfoo \
425426
// RUN: /AI foo_does_not_exist \

clang/test/Lexer/cxx-features.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@
9898
#error "wrong value for __cpp_modules"
9999
#endif
100100

101-
#if check(using_enum, 0, 0, 0, 0, 0, 0)
102-
// FIXME: 201907 in C++20
101+
#if check(using_enum, 0, 0, 0, 0, 201907, 201907)
103102
#error "wrong value for __cpp_using_enum"
104103
#endif
105104

clang/test/SemaCXX/varargs.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -std=c++03 -verify %s
2-
// RUN: %clang_cc1 -std=c++11 -verify %s
1+
// RUN: %clang_cc1 -std=c++03 -Wno-c++11-extensions -triple i386-pc-unknown -verify %s
2+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin9 -verify %s
33

44
__builtin_va_list ap;
55

@@ -28,6 +28,33 @@ void record_context(int a, ...) {
2828
};
2929
}
3030

31+
// Ensure the correct behavior for promotable type UB checking.
32+
void promotable(int a, ...) {
33+
enum Unscoped1 { One = 0x7FFFFFFF };
34+
(void)__builtin_va_arg(ap, Unscoped1); // ok
35+
36+
enum Unscoped2 { Two = 0xFFFFFFFF };
37+
(void)__builtin_va_arg(ap, Unscoped2); // ok
38+
39+
enum class Scoped { Three };
40+
(void)__builtin_va_arg(ap, Scoped); // ok
41+
42+
enum Fixed : int { Four };
43+
(void)__builtin_va_arg(ap, Fixed); // ok
44+
45+
enum FixedSmall : char { Five };
46+
(void)__builtin_va_arg(ap, FixedSmall); // expected-warning {{second argument to 'va_arg' is of promotable type 'FixedSmall'; this va_arg has undefined behavior because arguments will be promoted to 'int'}}
47+
48+
enum FixedLarge : long long { Six };
49+
(void)__builtin_va_arg(ap, FixedLarge); // ok
50+
51+
// Ensure that qualifiers are ignored.
52+
(void)__builtin_va_arg(ap, const volatile int); // ok
53+
54+
// Ensure that signed vs unsigned doesn't matter either.
55+
(void)__builtin_va_arg(ap, unsigned int);
56+
}
57+
3158
#if __cplusplus >= 201103L
3259
// We used to have bugs identifying the correct enclosing function scope in a
3360
// lambda.

0 commit comments

Comments
 (0)