Skip to content

Commit dc44953

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents 721b68c + 45d96df commit dc44953

Some content is hidden

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

55 files changed

+1326
-206
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ def binary_operator(self):
18871887
"""
18881888

18891889
if not hasattr(self, "_binopcode"):
1890-
self._binopcode = conf.lib.clang_Cursor_getBinaryOpcode(self)
1890+
self._binopcode = conf.lib.clang_getCursorBinaryOperatorKind(self)
18911891

18921892
return BinaryOperator.from_id(self._binopcode)
18931893

@@ -4097,7 +4097,7 @@ def set_property(self, property, value):
40974097
("clang_Cursor_getTemplateArgumentType", [Cursor, c_uint], Type),
40984098
("clang_Cursor_getTemplateArgumentValue", [Cursor, c_uint], c_longlong),
40994099
("clang_Cursor_getTemplateArgumentUnsignedValue", [Cursor, c_uint], c_ulonglong),
4100-
("clang_Cursor_getBinaryOpcode", [Cursor], c_int),
4100+
("clang_getCursorBinaryOperatorKind", [Cursor], c_int),
41014101
("clang_Cursor_getBriefCommentText", [Cursor], _CXString),
41024102
("clang_Cursor_getRawCommentText", [Cursor], _CXString),
41034103
("clang_Cursor_getOffsetOfField", [Cursor], c_longlong),

clang/docs/CommandGuide/clang.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ Language Selection and Mode Options
146146
147147
ISO C 2017 with GNU extensions
148148

149+
| ``c23``
150+
| ``iso9899:2024``
151+
152+
ISO C 2023
153+
154+
| ``gnu23``
155+
156+
ISO C 2023 with GNU extensions
157+
149158
The default C language standard is ``gnu17``, except on PS4, where it is
150159
``gnu99``.
151160

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ C Language Changes
205205
``-Wunterminated-string-initialization``. However, this diagnostic is not
206206
silenced by the ``nonstring`` attribute as these initializations are always
207207
incompatible with C++.
208-
- Added ``-Wjump-bypasses-init``, which is off by default and grouped under
208+
- Added ``-Wjump-misses-init``, which is off by default and grouped under
209209
``-Wc++-compat``. It diagnoses when a jump (``goto`` to its label, ``switch``
210210
to its ``case``) will bypass the initialization of a local variable, which is
211211
invalid in C++.
@@ -241,6 +241,7 @@ C2y Feature Support
241241

242242
C23 Feature Support
243243
^^^^^^^^^^^^^^^^^^^
244+
- Clang now accepts ``-std=iso9899:2024`` as an alias for C23.
244245
- Added ``__builtin_c23_va_start()`` for compatibility with GCC and to enable
245246
better diagnostic behavior for the ``va_start()`` macro in C23 and later.
246247
This also updates the definition of ``va_start()`` in ``<stdarg.h>`` to use
@@ -566,7 +567,9 @@ Bug Fixes in This Version
566567
- Fixed visibility calculation for template functions. (#GH103477)
567568
- Fixed a bug where an attribute before a ``pragma clang attribute`` or
568569
``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses
569-
the invalid attribute location appropriately. (#GH137861)
570+
the invalid attribute location appropriately. (#GH137861)
571+
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
572+
``#include`` directive. (#GH138094)
570573

571574
Bug Fixes to Compiler Builtins
572575
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -819,6 +822,10 @@ libclang
819822
- Fixed a buffer overflow in ``CXString`` implementation. The fix may result in
820823
increased memory allocation.
821824

825+
- Deprecate ``clang_Cursor_GetBinaryOpcode`` and ``clang_Cursor_getBinaryOpcodeStr``
826+
implementations, which are duplicates of ``clang_getCursorBinaryOperatorKind``
827+
and ``clang_getBinaryOperatorKindSpelling`` respectively.
828+
822829
Code Completion
823830
---------------
824831

clang/include/clang-c/Index.h

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3882,12 +3882,16 @@ enum CX_BinaryOperatorKind {
38823882

38833883
/**
38843884
* \brief Returns the operator code for the binary operator.
3885+
*
3886+
* @deprecated: use clang_getCursorBinaryOperatorKind instead.
38853887
*/
38863888
CINDEX_LINKAGE enum CX_BinaryOperatorKind
38873889
clang_Cursor_getBinaryOpcode(CXCursor C);
38883890

38893891
/**
38903892
* \brief Returns a string containing the spelling of the binary operator.
3893+
*
3894+
* @deprecated: use clang_getBinaryOperatorKindSpelling instead
38913895
*/
38923896
CINDEX_LINKAGE CXString
38933897
clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op);
@@ -6683,73 +6687,74 @@ CINDEX_LINKAGE unsigned clang_visitCXXMethods(CXType T, CXFieldVisitor visitor,
66836687
*/
66846688
enum CXBinaryOperatorKind {
66856689
/** This value describes cursors which are not binary operators. */
6686-
CXBinaryOperator_Invalid,
6690+
CXBinaryOperator_Invalid = 0,
66876691
/** C++ Pointer - to - member operator. */
6688-
CXBinaryOperator_PtrMemD,
6692+
CXBinaryOperator_PtrMemD = 1,
66896693
/** C++ Pointer - to - member operator. */
6690-
CXBinaryOperator_PtrMemI,
6694+
CXBinaryOperator_PtrMemI = 2,
66916695
/** Multiplication operator. */
6692-
CXBinaryOperator_Mul,
6696+
CXBinaryOperator_Mul = 3,
66936697
/** Division operator. */
6694-
CXBinaryOperator_Div,
6698+
CXBinaryOperator_Div = 4,
66956699
/** Remainder operator. */
6696-
CXBinaryOperator_Rem,
6700+
CXBinaryOperator_Rem = 5,
66976701
/** Addition operator. */
6698-
CXBinaryOperator_Add,
6702+
CXBinaryOperator_Add = 6,
66996703
/** Subtraction operator. */
6700-
CXBinaryOperator_Sub,
6704+
CXBinaryOperator_Sub = 7,
67016705
/** Bitwise shift left operator. */
6702-
CXBinaryOperator_Shl,
6706+
CXBinaryOperator_Shl = 8,
67036707
/** Bitwise shift right operator. */
6704-
CXBinaryOperator_Shr,
6708+
CXBinaryOperator_Shr = 9,
67056709
/** C++ three-way comparison (spaceship) operator. */
6706-
CXBinaryOperator_Cmp,
6710+
CXBinaryOperator_Cmp = 10,
67076711
/** Less than operator. */
6708-
CXBinaryOperator_LT,
6712+
CXBinaryOperator_LT = 11,
67096713
/** Greater than operator. */
6710-
CXBinaryOperator_GT,
6714+
CXBinaryOperator_GT = 12,
67116715
/** Less or equal operator. */
6712-
CXBinaryOperator_LE,
6716+
CXBinaryOperator_LE = 13,
67136717
/** Greater or equal operator. */
6714-
CXBinaryOperator_GE,
6718+
CXBinaryOperator_GE = 14,
67156719
/** Equal operator. */
6716-
CXBinaryOperator_EQ,
6720+
CXBinaryOperator_EQ = 15,
67176721
/** Not equal operator. */
6718-
CXBinaryOperator_NE,
6722+
CXBinaryOperator_NE = 16,
67196723
/** Bitwise AND operator. */
6720-
CXBinaryOperator_And,
6724+
CXBinaryOperator_And = 17,
67216725
/** Bitwise XOR operator. */
6722-
CXBinaryOperator_Xor,
6726+
CXBinaryOperator_Xor = 18,
67236727
/** Bitwise OR operator. */
6724-
CXBinaryOperator_Or,
6728+
CXBinaryOperator_Or = 19,
67256729
/** Logical AND operator. */
6726-
CXBinaryOperator_LAnd,
6730+
CXBinaryOperator_LAnd = 20,
67276731
/** Logical OR operator. */
6728-
CXBinaryOperator_LOr,
6732+
CXBinaryOperator_LOr = 21,
67296733
/** Assignment operator. */
6730-
CXBinaryOperator_Assign,
6734+
CXBinaryOperator_Assign = 22,
67316735
/** Multiplication assignment operator. */
6732-
CXBinaryOperator_MulAssign,
6736+
CXBinaryOperator_MulAssign = 23,
67336737
/** Division assignment operator. */
6734-
CXBinaryOperator_DivAssign,
6738+
CXBinaryOperator_DivAssign = 24,
67356739
/** Remainder assignment operator. */
6736-
CXBinaryOperator_RemAssign,
6740+
CXBinaryOperator_RemAssign = 25,
67376741
/** Addition assignment operator. */
6738-
CXBinaryOperator_AddAssign,
6742+
CXBinaryOperator_AddAssign = 26,
67396743
/** Subtraction assignment operator. */
6740-
CXBinaryOperator_SubAssign,
6744+
CXBinaryOperator_SubAssign = 27,
67416745
/** Bitwise shift left assignment operator. */
6742-
CXBinaryOperator_ShlAssign,
6746+
CXBinaryOperator_ShlAssign = 28,
67436747
/** Bitwise shift right assignment operator. */
6744-
CXBinaryOperator_ShrAssign,
6748+
CXBinaryOperator_ShrAssign = 29,
67456749
/** Bitwise AND assignment operator. */
6746-
CXBinaryOperator_AndAssign,
6750+
CXBinaryOperator_AndAssign = 30,
67476751
/** Bitwise XOR assignment operator. */
6748-
CXBinaryOperator_XorAssign,
6752+
CXBinaryOperator_XorAssign = 31,
67496753
/** Bitwise OR assignment operator. */
6750-
CXBinaryOperator_OrAssign,
6754+
CXBinaryOperator_OrAssign = 32,
67516755
/** Comma operator. */
6752-
CXBinaryOperator_Comma
6756+
CXBinaryOperator_Comma = 33,
6757+
CXBinaryOperator_Last = CXBinaryOperator_Comma
67536758
};
67546759

67556760
/**

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def DefaultConstInit : DiagGroup<"default-const-init",
177177
def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">;
178178
def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast",
179179
[ImplicitEnumEnumCast]>;
180-
def JumpBypassesInit : DiagGroup<"jump-bypasses-init">;
180+
def JumpBypassesInit : DiagGroup<"jump-misses-init">;
181181
def TentativeDefnCompat : DiagGroup<"tentative-definition-compat">;
182182
def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit,
183183
ImplicitIntToEnumCast, HiddenCppDecl,

clang/include/clang/Basic/LangStandards.def

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@ LANGSTANDARD_ALIAS(gnu17, "gnu18")
8989

9090
// C23 modes
9191
LANGSTANDARD(c23, "c23",
92-
C, "Working Draft for ISO C23",
92+
C, "ISO C 2023",
9393
LineComment | C99 | C11 | C17 | C23 | Digraphs | HexFloat)
94+
LANGSTANDARD_ALIAS(c23, "iso9899:2024")
9495
LANGSTANDARD_ALIAS_DEPR(c23, "c2x")
9596
LANGSTANDARD(gnu23, "gnu23",
96-
C, "Working Draft for ISO C23 with GNU extensions",
97+
C, "ISO C 2023 with GNU extensions",
9798
LineComment | C99 | C11 | C17 | C23 | Digraphs | GNUMode | HexFloat)
9899
LANGSTANDARD_ALIAS_DEPR(gnu23, "gnu2x")
99-
// FIXME: Add the alias for iso9899:202* once we know the year ISO publishes
100-
// the document (expected to be 2024).
101100

102101
// C2y modes
103102
LANGSTANDARD(c2y, "c2y",

clang/lib/AST/ExternalASTSource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
129129
// FIXME: Only bump the generation counter if the current generation number
130130
// has been observed?
131131
if (!++CurrentGeneration)
132-
llvm::report_fatal_error("generation counter overflowed", false);
132+
llvm::reportFatalUsageError("generation counter overflowed");
133133
}
134134

135135
return OldGeneration;

clang/lib/Lex/Pragma.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
220220
if (!tok::isStringLiteral(Tok.getKind())) {
221221
Diag(PragmaLoc, diag::err__Pragma_malformed);
222222
// Skip bad tokens, and the ')', if present.
223-
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof))
223+
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof) && Tok.isNot(tok::eod))
224224
Lex(Tok);
225225
while (Tok.isNot(tok::r_paren) &&
226226
!Tok.isAtStartOfLine() &&
227-
Tok.isNot(tok::eof))
227+
Tok.isNot(tok::eof) && Tok.isNot(tok::eod))
228228
Lex(Tok);
229229
if (Tok.is(tok::r_paren))
230230
Lex(Tok);

clang/lib/Sema/JumpDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
998998
SmallVector<unsigned, 10> ToScopesError;
999999
SmallVector<unsigned, 10> ToScopesWarning;
10001000
for (unsigned I = ToScope; I != CommonScope; I = Scopes[I].ParentScope) {
1001-
if (S.getLangOpts().MSVCCompat && JumpDiagWarning != 0 &&
1001+
if (S.getLangOpts().MSVCCompat && S.getLangOpts().CPlusPlus &&
1002+
JumpDiagWarning != 0 &&
10021003
IsMicrosoftJumpWarning(JumpDiagError, Scopes[I].InDiag))
10031004
ToScopesWarning.push_back(I);
10041005
else if (IsCXX98CompatWarning(S, Scopes[I].InDiag) ||

clang/lib/Sema/SemaExpr.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9840,15 +9840,35 @@ AssignConvertType Sema::CheckSingleAssignmentConstraints(QualType LHSType,
98409840
((getLangOpts().C23 && RHS.get()->getType()->isNullPtrType()) ||
98419841
RHS.get()->isNullPointerConstant(Context,
98429842
Expr::NPC_ValueDependentIsNull))) {
9843+
AssignConvertType Ret = AssignConvertType::Compatible;
98439844
if (Diagnose || ConvertRHS) {
98449845
CastKind Kind;
98459846
CXXCastPath Path;
98469847
CheckPointerConversion(RHS.get(), LHSType, Kind, Path,
98479848
/*IgnoreBaseAccess=*/false, Diagnose);
9849+
9850+
// If there is a conversion of some kind, check to see what kind of
9851+
// pointer conversion happened so we can diagnose a C++ compatibility
9852+
// diagnostic if the conversion is invalid. This only matters if the RHS
9853+
// is some kind of void pointer.
9854+
if (Kind != CK_NoOp && !getLangOpts().CPlusPlus) {
9855+
QualType CanRHS =
9856+
RHS.get()->getType().getCanonicalType().getUnqualifiedType();
9857+
QualType CanLHS = LHSType.getCanonicalType().getUnqualifiedType();
9858+
if (CanRHS->isVoidPointerType() && CanLHS->isPointerType()) {
9859+
Ret = checkPointerTypesForAssignment(*this, CanLHS, CanRHS,
9860+
RHS.get()->getExprLoc());
9861+
// Anything that's not considered perfectly compatible would be
9862+
// incompatible in C++.
9863+
if (Ret != AssignConvertType::Compatible)
9864+
Ret = AssignConvertType::CompatibleVoidPtrToNonVoidPtr;
9865+
}
9866+
}
9867+
98489868
if (ConvertRHS)
98499869
RHS = ImpCastExprToType(RHS.get(), LHSType, Kind, VK_PRValue, &Path);
98509870
}
9851-
return AssignConvertType::Compatible;
9871+
return Ret;
98529872
}
98539873
// C23 6.5.16.1p1: the left operand has type atomic, qualified, or
98549874
// unqualified bool, and the right operand is a pointer or its type is
@@ -13991,7 +14011,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
1399114011
LHSType->isObjCObjectPointerType())))
1399214012
ConvTy = AssignConvertType::Compatible;
1399314013

13994-
if (ConvTy == AssignConvertType::Compatible && LHSType->isObjCObjectType())
14014+
if (IsAssignConvertCompatible(ConvTy) && LHSType->isObjCObjectType())
1399514015
Diag(Loc, diag::err_objc_object_assignment) << LHSType;
1399614016

1399714017
// If the RHS is a unary plus or minus, check to see if they = and + are
@@ -14014,7 +14034,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
1401414034
}
1401514035
}
1401614036

14017-
if (ConvTy == AssignConvertType::Compatible) {
14037+
if (IsAssignConvertCompatible(ConvTy)) {
1401814038
if (LHSType.getObjCLifetime() == Qualifiers::OCL_Strong) {
1401914039
// Warn about retain cycles where a block captures the LHS, but
1402014040
// not if the LHS is a simple variable into which the block is

0 commit comments

Comments
 (0)