Skip to content

Commit 83ebaf0

Browse files
committed
Merge remote-tracking branch 'origin/main' into aballman-wg14-n3341
2 parents 3f20756 + 4027400 commit 83ebaf0

File tree

168 files changed

+5544
-2353
lines changed

Some content is hidden

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

168 files changed

+5544
-2353
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5975,6 +5975,7 @@ Clang guarantees the following behaviors:
59755975
59765976
Currently, the above extension only applies to C source code, not C++.
59775977
5978+
59785979
Empty Objects in C
59795980
==================
59805981
The declaration of a structure or union type which has no named members is
@@ -5983,3 +5984,21 @@ Clang allows the declaration of a structure or union type with no named members
59835984
in all C language modes. `sizeof` for such a type returns `0`, which is
59845985
different behavior than in C++ (where the size of such an object is typically
59855986
`1`).
5987+
5988+
5989+
Qualified function types in C
5990+
=============================
5991+
Declaring a function with a qualified type in C is undefined behavior (C23 and
5992+
earlier) or implementation-defined behavior (C2y). Clang allows a function type
5993+
to be specified with the ``const`` and ``volatile`` qualifiers, but ignores the
5994+
qualifications.
5995+
5996+
.. code-block:: c
5997+
5998+
typedef int f(void);
5999+
const volatile f func; // Qualifier on function type has no effect.
6000+
6001+
6002+
Note, Clang does not allow an ``_Atomic`` function type because
6003+
of explicit constraints against atomically qualified (arrays and) function
6004+
types.

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ C2y Feature Support
304304
behavior is a conforming GNU extension in those modes, but will no longer
305305
have an effect in C2y mode.
306306

307+
- Updated conformance for `N3342 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3342.pdf>`_
308+
which made qualified function types implementation-defined rather than
309+
undefined. Clang has always accepted ``const`` and ``volatile`` qualified
310+
function types by ignoring the qualifiers.
311+
312+
307313
C23 Feature Support
308314
^^^^^^^^^^^^^^^^^^^
309315

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,6 @@ def LifetimeBound : DeclOrTypeAttr {
18861886
let Spellings = [Clang<"lifetimebound", 0>];
18871887
let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
18881888
let Documentation = [LifetimeBoundDocs];
1889-
let LangOpts = [CPlusPlus];
18901889
let SimpleHandler = 1;
18911890
}
18921891

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3858,8 +3858,7 @@ def LifetimeBoundDocs : Documentation {
38583858
The ``lifetimebound`` attribute on a function parameter or implicit object
38593859
parameter indicates that objects that are referred to by that parameter may
38603860
also be referred to by the return value of the annotated function (or, for a
3861-
parameter of a constructor, by the value of the constructed object). It is only
3862-
supported in C++.
3861+
parameter of a constructor, by the value of the constructed object).
38633862

38643863
By default, a reference is considered to refer to its referenced object, a
38653864
pointer is considered to refer to its pointee, a ``std::initializer_list<T>``

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6241,8 +6241,9 @@ def err_typecheck_negative_array_size : Error<"array size is negative">;
62416241
def warn_typecheck_function_qualifiers_ignored : Warning<
62426242
"'%0' qualifier on function type %1 has no effect">,
62436243
InGroup<IgnoredQualifiers>;
6244-
def warn_typecheck_function_qualifiers_unspecified : Warning<
6245-
"'%0' qualifier on function type %1 has unspecified behavior">;
6244+
def ext_typecheck_function_qualifiers_unspecified : ExtWarn<
6245+
"'%0' qualifier on function type %1 has no effect and is a Clang extension">,
6246+
InGroup<IgnoredQualifiers>;
62466247
def warn_typecheck_reference_qualifiers : Warning<
62476248
"'%0' qualifier on reference type %1 has no effect">,
62486249
InGroup<IgnoredReferenceQualifiers>;
@@ -12747,6 +12748,19 @@ def err_acc_gang_reduction_numgangs_conflict
1274712748
def err_reduction_op_mismatch
1274812749
: Error<"OpenACC 'reduction' variable must have the same operator in all "
1274912750
"nested constructs (%0 vs %1)">;
12751+
def err_acc_loop_variable_type
12752+
: Error<"loop variable of loop associated with an OpenACC 'loop' construct "
12753+
"must be of integer, pointer, or random-access-iterator type (is "
12754+
"%0)">;
12755+
def err_acc_loop_variable
12756+
: Error<"OpenACC 'loop' construct must have initialization clause in "
12757+
"canonical form ('var = init' or 'T var = init')">;
12758+
def err_acc_loop_terminating_condition
12759+
: Error<"OpenACC 'loop' construct must have a terminating condition">;
12760+
def err_acc_loop_not_monotonic
12761+
: Error<"OpenACC 'loop' variable must monotonically increase or decrease "
12762+
"('++', '--', or compound assignment)">;
12763+
1275012764
// AMDGCN builtins diagnostics
1275112765
def err_amdgcn_global_load_lds_size_invalid_value : Error<"invalid size value">;
1275212766
def note_amdgcn_global_load_lds_size_valid_value : Note<"size must be 1, 2, or 4">;

clang/include/clang/Basic/arm_sve.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ let SVETargetGuard = "sve2,lut,bf16", SMETargetGuard = "sme2,lut,bf16" in {
19621962
////////////////////////////////////////////////////////////////////////////////
19631963
// SVE2 - Optional
19641964

1965-
let SVETargetGuard = "sve2-aes", SMETargetGuard = InvalidMode in {
1965+
let SVETargetGuard = "sve2,sve-aes", SMETargetGuard = InvalidMode in {
19661966
def SVAESD : SInst<"svaesd[_{d}]", "ddd", "Uc", MergeNone, "aarch64_sve_aesd", [IsOverloadNone]>;
19671967
def SVAESIMC : SInst<"svaesimc[_{d}]", "dd", "Uc", MergeNone, "aarch64_sve_aesimc", [IsOverloadNone]>;
19681968
def SVAESE : SInst<"svaese[_{d}]", "ddd", "Uc", MergeNone, "aarch64_sve_aese", [IsOverloadNone]>;

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,43 @@ class SemaOpenACC : public SemaBase {
118118
/// 'loop' clause enforcement, where this is 'blocked' by a compute construct.
119119
llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
120120

121+
// Type to check the info about the 'for stmt'.
122+
struct ForStmtBeginChecker {
123+
SemaOpenACC &SemaRef;
124+
SourceLocation ForLoc;
125+
bool IsRangeFor = false;
126+
std::optional<const CXXForRangeStmt *> RangeFor = nullptr;
127+
const Stmt *Init = nullptr;
128+
bool InitChanged = false;
129+
std::optional<const Stmt *> Cond = nullptr;
130+
std::optional<const Stmt *> Inc = nullptr;
131+
// Prevent us from checking 2x, which can happen with collapse & tile.
132+
bool AlreadyChecked = false;
133+
134+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
135+
std::optional<const CXXForRangeStmt *> S)
136+
: SemaRef(SemaRef), ForLoc(ForLoc), IsRangeFor(true), RangeFor(S) {}
137+
138+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
139+
const Stmt *I, bool InitChanged,
140+
std::optional<const Stmt *> C,
141+
std::optional<const Stmt *> Inc)
142+
: SemaRef(SemaRef), ForLoc(ForLoc), IsRangeFor(false), Init(I),
143+
InitChanged(InitChanged), Cond(C), Inc(Inc) {}
144+
// Do the checking for the For/Range-For. Currently this implements the 'not
145+
// seq' restrictions only, and should be called either if we know we are a
146+
// top-level 'for' (the one associated via associated-stmt), or extended via
147+
// 'collapse'.
148+
void check();
149+
150+
const ValueDecl *checkInit();
151+
void checkCond();
152+
void checkInc(const ValueDecl *Init);
153+
};
154+
155+
/// Helper function for checking the 'for' and 'range for' stmts.
156+
void ForStmtBeginHelper(SourceLocation ForLoc, ForStmtBeginChecker &C);
157+
121158
public:
122159
ComputeConstructInfo &getActiveComputeConstructInfo() {
123160
return ActiveComputeConstructInfo;
@@ -137,6 +174,11 @@ class SemaOpenACC : public SemaBase {
137174
/// permits us to implement the restriction of no further 'gang', 'vector', or
138175
/// 'worker' clauses.
139176
SourceLocation LoopVectorClauseLoc;
177+
/// If there is a current 'active' loop construct that does NOT have a 'seq'
178+
/// clause on it, this has that source location. This permits us to implement
179+
/// the 'loop' restrictions on the loop variable. This can be extended via
180+
/// 'collapse', so we need to keep this around for a while.
181+
SourceLocation LoopWithoutSeqLoc;
140182

141183
// Redeclaration of the version in OpenACCClause.h.
142184
using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
@@ -568,8 +610,19 @@ class SemaOpenACC : public SemaBase {
568610
void ActOnWhileStmt(SourceLocation WhileLoc);
569611
// Called when we encounter a 'do' statement, before looking at its 'body'.
570612
void ActOnDoStmt(SourceLocation DoLoc);
613+
// Called when we encounter a 'for' statement, before looking at its 'body',
614+
// for the 'range-for'. 'ActOnForStmtEnd' is used after the body.
615+
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor,
616+
const Stmt *RangeFor);
617+
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *RangeFor);
571618
// Called when we encounter a 'for' statement, before looking at its 'body'.
572-
void ActOnForStmtBegin(SourceLocation ForLoc);
619+
// 'ActOnForStmtEnd' is used after the body.
620+
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First,
621+
const Stmt *Second, const Stmt *Third);
622+
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *OldFirst,
623+
const Stmt *First, const Stmt *OldSecond,
624+
const Stmt *Second, const Stmt *OldThird,
625+
const Stmt *Third);
573626
// Called when we encounter a 'for' statement, after we've consumed/checked
574627
// the body. This is necessary for a number of checks on the contents of the
575628
// 'for' statement.
@@ -598,7 +651,9 @@ class SemaOpenACC : public SemaBase {
598651
/// Called when we encounter an associated statement for our construct, this
599652
/// should check legality of the statement as it appertains to this Construct.
600653
StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc,
601-
OpenACCDirectiveKind K, StmtResult AssocStmt);
654+
OpenACCDirectiveKind K,
655+
ArrayRef<const OpenACCClause *> Clauses,
656+
StmtResult AssocStmt);
602657

603658
/// Called after the directive has been completely parsed, including the
604659
/// declaration group or associated statement.
@@ -712,12 +767,13 @@ class SemaOpenACC : public SemaBase {
712767
SourceLocation OldLoopGangClauseOnKernelLoc;
713768
SourceLocation OldLoopWorkerClauseLoc;
714769
SourceLocation OldLoopVectorClauseLoc;
770+
SourceLocation OldLoopWithoutSeqLoc;
715771
llvm::SmallVector<OpenACCLoopConstruct *> ParentlessLoopConstructs;
716772
llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
717773
LoopInConstructRAII LoopRAII;
718774

719775
public:
720-
AssociatedStmtRAII(SemaOpenACC &, OpenACCDirectiveKind,
776+
AssociatedStmtRAII(SemaOpenACC &, OpenACCDirectiveKind, SourceLocation,
721777
ArrayRef<const OpenACCClause *>,
722778
ArrayRef<OpenACCClause *>);
723779
void SetCollapseInfoBeforeAssociatedStmt(

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
473473
if (HasSVE2p1)
474474
Builder.defineMacro("__ARM_FEATURE_SVE2p1", "1");
475475

476-
if (HasSVE2 && HasSVE2AES)
476+
if (HasSVE2 && HasSVEAES)
477477
Builder.defineMacro("__ARM_FEATURE_SVE2_AES", "1");
478478

479479
if (HasSVE2 && HasSVE2BitPerm)
@@ -769,7 +769,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
769769
.Case("f32mm", FPU & SveMode && HasMatmulFP32)
770770
.Case("f64mm", FPU & SveMode && HasMatmulFP64)
771771
.Case("sve2", FPU & SveMode && HasSVE2)
772-
.Case("sve2-pmull128", FPU & SveMode && HasSVE2AES)
772+
.Case("sve2-pmull128", FPU & SveMode && HasSVEAES && HasSVE2)
773773
.Case("sve2-bitperm", FPU & SveMode && HasSVE2BitPerm)
774774
.Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
775775
.Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
@@ -861,12 +861,10 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
861861
HasSVE2 = true;
862862
HasSVE2p1 = true;
863863
}
864-
if (Feature == "+sve2-aes") {
864+
if (Feature == "+sve-aes") {
865865
FPU |= NeonMode;
866-
FPU |= SveMode;
867-
HasFullFP16 = true;
868-
HasSVE2 = true;
869-
HasSVE2AES = true;
866+
HasAES = true;
867+
HasSVEAES = true;
870868
}
871869
if (Feature == "+sve2-sha3") {
872870
FPU |= NeonMode;

clang/lib/Basic/Targets/AArch64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
7878
bool HasBFloat16 = false;
7979
bool HasSVE2 = false;
8080
bool HasSVE2p1 = false;
81-
bool HasSVE2AES = false;
81+
bool HasSVEAES = false;
8282
bool HasSVE2SHA3 = false;
8383
bool HasSVE2SM4 = false;
8484
bool HasSVEB16B16 = false;

clang/lib/Headers/emmintrin.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,8 +4626,9 @@ _mm_movepi64_pi64(__m128i __a) {
46264626
/// A 64-bit value.
46274627
/// \returns A 128-bit integer vector. The lower 64 bits contain the value from
46284628
/// the operand. The upper 64 bits are assigned zeros.
4629-
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_movpi64_epi64(__m64 __a) {
4630-
return __extension__(__m128i)(__v2di){(long long)__a, 0};
4629+
static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
4630+
_mm_movpi64_epi64(__m64 __a) {
4631+
return __builtin_shufflevector((__v1di)__a, _mm_setzero_si64(), 0, 1);
46314632
}
46324633

46334634
/// Moves the lower 64 bits of a 128-bit integer vector to a 128-bit

0 commit comments

Comments
 (0)