Skip to content

Commit 729ee78

Browse files
author
git apple-llvm automerger
committed
Merge commit 'edf296435099' from swift/release/6.3 into stable/21.x
2 parents 1afa997 + edf2964 commit 729ee78

File tree

23 files changed

+129
-1062
lines changed

23 files changed

+129
-1062
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,6 @@ C23 Feature Support
296296
scope.
297297
- Fixed a bug where you could not cast a null pointer constant to type
298298
``nullptr_t``. Fixes #GH133644.
299-
- Implemented `WG14 N3037 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf>`_
300-
which allows tag types to be redefined within the same translation unit so
301-
long as both definitions are structurally equivalent (same tag types, same
302-
tag names, same tag members, etc). As a result of this paper, ``-Wvisibility``
303-
is no longer diagnosed in C23 if the parameter is a complete tag type (it
304-
does still fire when the parameter is an incomplete tag type as that cannot
305-
be completed).
306299
- Fixed a failed assertion with an invalid parameter to the ``#embed``
307300
directive. Fixes #GH126940.
308301
- Fixed a crash when a declaration of a ``constexpr`` variable with an invalid

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3354,7 +3354,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
33543354
QualType mergeTransparentUnionType(QualType, QualType,
33553355
bool OfBlockPointer=false,
33563356
bool Unqualified = false);
3357-
QualType mergeTagDefinitions(QualType, QualType);
33583357

33593358
QualType mergeObjCGCQualifiers(QualType, QualType);
33603359

clang/include/clang/AST/ASTStructuralEquivalence.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ struct StructuralEquivalenceContext {
4343
/// key: (from, to, IgnoreTemplateParmDepth)
4444
using NonEquivalentDeclSet = llvm::DenseSet<std::tuple<Decl *, Decl *, int>>;
4545

46-
/// The language options to use for making a structural equivalence check.
47-
const LangOptions &LangOpts;
48-
4946
/// AST contexts for which we are checking structural equivalence.
5047
ASTContext &FromCtx, &ToCtx;
5148

@@ -79,17 +76,15 @@ struct StructuralEquivalenceContext {
7976
/// Whether to ignore comparing the depth of template param(TemplateTypeParm)
8077
bool IgnoreTemplateParmDepth;
8178

82-
StructuralEquivalenceContext(const LangOptions &LangOpts, ASTContext &FromCtx,
83-
ASTContext &ToCtx,
79+
StructuralEquivalenceContext(ASTContext &FromCtx, ASTContext &ToCtx,
8480
NonEquivalentDeclSet &NonEquivalentDecls,
8581
StructuralEquivalenceKind EqKind,
8682
bool StrictTypeSpelling = false,
8783
bool Complain = true,
8884
bool ErrorOnTagTypeMismatch = false,
8985
bool IgnoreTemplateParmDepth = false)
90-
: LangOpts(LangOpts), FromCtx(FromCtx), ToCtx(ToCtx),
91-
NonEquivalentDecls(NonEquivalentDecls), EqKind(EqKind),
92-
StrictTypeSpelling(StrictTypeSpelling),
86+
: FromCtx(FromCtx), ToCtx(ToCtx), NonEquivalentDecls(NonEquivalentDecls),
87+
EqKind(EqKind), StrictTypeSpelling(StrictTypeSpelling),
9388
ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain),
9489
IgnoreTemplateParmDepth(IgnoreTemplateParmDepth) {}
9590

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -480,23 +480,16 @@ def warn_odr_function_type_inconsistent : Warning<
480480
"external function %0 declared with incompatible types in different "
481481
"translation units (%1 vs. %2)">,
482482
InGroup<ODR>;
483-
def warn_odr_tag_type_with_attributes : Warning<
484-
"type %0 has %select{an attribute|a member with an attribute}1 which "
485-
"currently causes the types to be treated as though they are incompatible">,
486-
InGroup<ODR>, DefaultError;
487-
def note_odr_attr_here : Note<"attribute %0 here">;
488483
def err_odr_tag_type_inconsistent
489-
: Error<"type %0 has incompatible definitions%select{| in different "
490-
"translation units}1">;
484+
: Error<"type %0 has incompatible definitions in different translation "
485+
"units">;
491486
def warn_odr_tag_type_inconsistent
492-
: Warning<"type %0 has incompatible definitions%select{| in different "
493-
"translation units}1">,
487+
: Warning<"type %0 has incompatible definitions in different translation "
488+
"units">,
494489
InGroup<ODR>;
495490
def note_odr_tag_kind_here: Note<
496491
"%0 is a %select{struct|interface|union|class|enum}1 here">;
497492
def note_odr_field : Note<"field %0 has type %1 here">;
498-
def note_odr_field_bit_width : Note<"bit-field %0 has bit-width %1 here">;
499-
def note_odr_field_not_bit_field : Note<"field %0 is not a bit-field">;
500493
def note_odr_field_name : Note<"field has name %0 here">;
501494
def note_odr_missing_field : Note<"no corresponding field here">;
502495
def note_odr_base : Note<"class has base type %0">;
@@ -507,14 +500,6 @@ def note_odr_number_of_bases : Note<
507500
"class has %0 base %plural{1:class|:classes}0">;
508501
def note_odr_enumerator : Note<"enumerator %0 with value %1 here">;
509502
def note_odr_missing_enumerator : Note<"no corresponding enumerator here">;
510-
def note_odr_incompatible_fixed_underlying_type : Note<
511-
"enumeration %0 declared with incompatible fixed underlying types (%1 vs. "
512-
"%2)">;
513-
def note_odr_fixed_underlying_type : Note<
514-
"enumeration %0 has fixed underlying type here">;
515-
def note_odr_missing_fixed_underlying_type : Note<
516-
"enumeration %0 missing fixed underlying type here">;
517-
518503
def err_odr_field_type_inconsistent : Error<
519504
"field %0 declared with incompatible types in different "
520505
"translation units (%1 vs. %2)">;

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,21 +1964,6 @@ class Parser : public CodeCompletionHandler {
19641964
const ParsedTemplateInfo &TemplateInfo,
19651965
AccessSpecifier AS, DeclSpecContext DSC);
19661966

1967-
/// ParseEnumBody - Parse a {} enclosed enumerator-list.
1968-
/// \verbatim
1969-
/// enumerator-list:
1970-
/// enumerator
1971-
/// enumerator-list ',' enumerator
1972-
/// enumerator:
1973-
/// enumeration-constant attributes[opt]
1974-
/// enumeration-constant attributes[opt] '=' constant-expression
1975-
/// enumeration-constant:
1976-
/// identifier
1977-
/// \endverbatim
1978-
///
1979-
void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl,
1980-
SkipBodyInfo *SkipBody = nullptr);
1981-
19821967
/// ParseStructUnionBody
19831968
/// \verbatim
19841969
/// struct-contents:
@@ -1991,6 +1976,7 @@ class Parser : public CodeCompletionHandler {
19911976
/// [OBC] '@' 'defs' '(' class-name ')'
19921977
/// \endverbatim
19931978
///
1979+
void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
19941980
void ParseStructUnionBody(SourceLocation StartLoc, DeclSpec::TST TagType,
19951981
RecordDecl *TagDecl);
19961982

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,8 +4811,7 @@ class Sema final : public SemaBase {
48114811
Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
48124812
SourceLocation IdLoc, IdentifierInfo *Id,
48134813
const ParsedAttributesView &Attrs,
4814-
SourceLocation EqualLoc, Expr *Val,
4815-
SkipBodyInfo *SkipBody = nullptr);
4814+
SourceLocation EqualLoc, Expr *Val);
48164815
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
48174816
Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
48184817
const ParsedAttributesView &Attr);

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "clang/AST/APValue.h"
1717
#include "clang/AST/ASTConcept.h"
1818
#include "clang/AST/ASTMutationListener.h"
19-
#include "clang/AST/ASTStructuralEquivalence.h"
2019
#include "clang/AST/ASTTypeTraits.h"
2120
#include "clang/AST/Attr.h"
2221
#include "clang/AST/AttrIterator.h"
@@ -12358,28 +12357,6 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET,
1235812357
return {};
1235912358
}
1236012359

12361-
QualType ASTContext::mergeTagDefinitions(QualType LHS, QualType RHS) {
12362-
// C17 and earlier and C++ disallow two tag definitions within the same TU
12363-
// from being compatible.
12364-
if (LangOpts.CPlusPlus || !LangOpts.C23)
12365-
return {};
12366-
12367-
// Nameless tags are comparable only within outer definitions. At the top
12368-
// level they are not comparable.
12369-
const TagDecl *LTagD = LHS->getAsTagDecl(), *RTagD = RHS->getAsTagDecl();
12370-
if (!LTagD->getIdentifier() || !RTagD->getIdentifier())
12371-
return {};
12372-
12373-
// C23, on the other hand, requires the members to be "the same enough", so
12374-
// we use a structural equivalence check.
12375-
StructuralEquivalenceContext::NonEquivalentDeclSet NonEquivalentDecls;
12376-
StructuralEquivalenceContext Ctx(
12377-
getLangOpts(), *this, *this, NonEquivalentDecls,
12378-
StructuralEquivalenceKind::Default, /*StrictTypeSpelling=*/false,
12379-
/*Complain=*/false, /*ErrorOnTagTypeMismatch=*/true);
12380-
return Ctx.IsEquivalent(LHS, RHS) ? LHS : QualType{};
12381-
}
12382-
1238312360
QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer,
1238412361
bool Unqualified, bool BlockReturnType,
1238512362
bool IsConditionalOperator) {
@@ -12701,7 +12678,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer,
1270112678
/*AllowCXX=*/false, IsConditionalOperator);
1270212679
case Type::Record:
1270312680
case Type::Enum:
12704-
return mergeTagDefinitions(LHS, RHS);
12681+
return {};
1270512682
case Type::Builtin:
1270612683
// Only exactly equal builtin types are compatible, which is tested above.
1270712684
return {};

clang/lib/AST/ASTImporter.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,9 +2723,8 @@ bool ASTNodeImporter::IsStructuralMatch(Decl *From, Decl *To, bool Complain,
27232723
}
27242724

27252725
StructuralEquivalenceContext Ctx(
2726-
Importer.getToContext().getLangOpts(), Importer.getFromContext(),
2727-
Importer.getToContext(), Importer.getNonEquivalentDecls(),
2728-
getStructuralEquivalenceKind(Importer),
2726+
Importer.getFromContext(), Importer.getToContext(),
2727+
Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer),
27292728
/*StrictTypeSpelling=*/false, Complain, /*ErrorOnTagTypeMismatch=*/false,
27302729
IgnoreTemplateParmDepth);
27312730
return Ctx.IsEquivalent(From, To);
@@ -4587,8 +4586,7 @@ static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1,
45874586

45884587
ASTImporter::NonEquivalentDeclSet NonEquivalentDecls;
45894588
StructuralEquivalenceContext Ctx(
4590-
Importer.getToContext().getLangOpts(), FD1->getASTContext(),
4591-
FD2->getASTContext(), NonEquivalentDecls,
4589+
FD1->getASTContext(), FD2->getASTContext(), NonEquivalentDecls,
45924590
StructuralEquivalenceKind::Default,
45934591
/* StrictTypeSpelling = */ false, /* Complain = */ false);
45944592
return Ctx.IsEquivalent(FD1, FD2);
@@ -10885,8 +10883,8 @@ bool ASTImporter::IsStructurallyEquivalent(QualType From, QualType To,
1088510883
}
1088610884
}
1088710885

10888-
StructuralEquivalenceContext Ctx(
10889-
getToContext().getLangOpts(), FromContext, ToContext, NonEquivalentDecls,
10890-
getStructuralEquivalenceKind(*this), false, Complain);
10886+
StructuralEquivalenceContext Ctx(FromContext, ToContext, NonEquivalentDecls,
10887+
getStructuralEquivalenceKind(*this), false,
10888+
Complain);
1089110889
return Ctx.IsEquivalent(From, To);
1089210890
}

0 commit comments

Comments
 (0)