Skip to content

Commit dc1000d

Browse files
committed
Revert "[C2X] N3007 Type inference for object definitions"
This reverts commit 5d78b78. Reverting due to the failure found by: https://lab.llvm.org/buildbot/#/builders/245/builds/14999
1 parent c73d554 commit dc1000d

File tree

11 files changed

+11
-542
lines changed

11 files changed

+11
-542
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,6 @@ def ext_imaginary_constant : Extension<
240240
"imaginary constants are a GNU extension">, InGroup<GNUImaginaryConstant>;
241241
def ext_integer_complex : Extension<
242242
"complex integer types are a GNU extension">, InGroup<GNUComplexInteger>;
243-
def ext_c23_auto_non_plain_identifier : Extension<
244-
"type inference of a declaration other than a plain identifier with optional "
245-
"trailing attributes is a Clang extension">,
246-
InGroup<DiagGroup<"auto-decl-extensions">>;
247243

248244
def err_invalid_saturation_spec : Error<"'_Sat' specifier is only valid on "
249245
"'_Fract' or '_Accum', not '%0'">;
@@ -2392,8 +2388,7 @@ def err_auto_not_allowed : Error<
23922388
"|in conversion function type|here|in lambda parameter"
23932389
"|in type allocated by 'new'|in K&R-style function parameter"
23942390
"|in template parameter|in friend declaration|in function prototype that is "
2395-
"not a function declaration|in requires expression parameter"
2396-
"|in array declaration}1">;
2391+
"not a function declaration|in requires expression parameter}1">;
23972392
def err_dependent_deduced_tst : Error<
23982393
"typename specifier refers to "
23992394
"%select{class template|function template|variable template|alias template|"
@@ -2466,8 +2461,7 @@ def err_implied_std_initializer_list_not_found : Error<
24662461
def err_malformed_std_initializer_list : Error<
24672462
"std::initializer_list must be a class template with a single type parameter">;
24682463
def err_auto_init_list_from_c : Error<
2469-
"cannot use %select{'auto'|<ERROR>|'__auto_type'}0 with "
2470-
"%select{initializer list|array}1 in C">;
2464+
"cannot use __auto_type with initializer list in C">;
24712465
def err_auto_bitfield : Error<
24722466
"cannot pass bit-field as __auto_type initializer in C">;
24732467

@@ -6670,8 +6664,8 @@ def err_func_def_incomplete_result : Error<
66706664
def err_atomic_specifier_bad_type
66716665
: Error<"_Atomic cannot be applied to "
66726666
"%select{incomplete |array |function |reference |atomic |qualified "
6673-
"|sizeless ||integer |}0type "
6674-
"%1 %select{|||||||which is not trivially copyable||in C23}0">;
6667+
"|sizeless ||integer }0type "
6668+
"%1 %select{|||||||which is not trivially copyable|}0">;
66756669
def warn_atomic_member_access : Warning<
66766670
"accessing a member of an atomic structure or union is undefined behavior">,
66776671
InGroup<DiagGroup<"atomic-access">>, DefaultError;

clang/lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4038,7 +4038,7 @@ void Parser::ParseDeclarationSpecifiers(
40384038
isStorageClass = true;
40394039
break;
40404040
case tok::kw_auto:
4041-
if (getLangOpts().CPlusPlus11 || getLangOpts().C23) {
4041+
if (getLangOpts().CPlusPlus11) {
40424042
if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
40434043
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_auto, Loc,
40444044
PrevSpec, DiagID, Policy);

clang/lib/Sema/DeclSpec.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,8 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
13751375
StorageClassSpecLoc = SourceLocation();
13761376
}
13771377
// Diagnose if we've recovered from an ill-formed 'auto' storage class
1378-
// specifier in a pre-C++11 dialect of C++ or in a pre-C23 dialect of C.
1379-
if (!S.getLangOpts().CPlusPlus11 && !S.getLangOpts().C23 &&
1380-
TypeSpecType == TST_auto)
1378+
// specifier in a pre-C++11 dialect of C++.
1379+
if (!S.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto)
13811380
S.Diag(TSTLoc, diag::ext_auto_type_specifier);
13821381
if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11 &&
13831382
StorageClassSpec == SCS_auto)

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12863,15 +12863,6 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
1286312863
DeducedType *Deduced = Type->getContainedDeducedType();
1286412864
assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type");
1286512865

12866-
// Diagnose auto array declarations in C23, unless it's a supported extension.
12867-
if (getLangOpts().C23 && Type->isArrayType() &&
12868-
!isa_and_present<StringLiteral, InitListExpr>(Init)) {
12869-
Diag(Range.getBegin(), diag::err_auto_not_allowed)
12870-
<< (int)Deduced->getContainedAutoType()->getKeyword()
12871-
<< /*in array decl*/ 23 << Range;
12872-
return QualType();
12873-
}
12874-
1287512866
// C++11 [dcl.spec.auto]p3
1287612867
if (!Init) {
1287712868
assert(VDecl && "no init for init capture deduction?");

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4842,25 +4842,9 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *Init, QualType &Result,
48424842
return TDK_Success;
48434843
}
48444844

4845-
// Make sure that we treat 'char[]' equaly as 'char*' in C23 mode.
4846-
auto *String = dyn_cast<StringLiteral>(Init);
4847-
if (getLangOpts().C23 && String && Type.getType()->isArrayType()) {
4848-
Diag(Type.getBeginLoc(), diag::ext_c23_auto_non_plain_identifier);
4849-
TypeLoc TL = TypeLoc(Init->getType(), Type.getOpaqueData());
4850-
Result = SubstituteDeducedTypeTransform(*this, DependentResult).Apply(TL);
4851-
assert(!Result.isNull() && "substituting DependentTy can't fail");
4852-
return TDK_Success;
4853-
}
4854-
4855-
// Emit a warning if 'auto*' is used in pedantic and in C23 mode.
4856-
if (getLangOpts().C23 && Type.getType()->isPointerType()) {
4857-
Diag(Type.getBeginLoc(), diag::ext_c23_auto_non_plain_identifier);
4858-
}
4859-
48604845
auto *InitList = dyn_cast<InitListExpr>(Init);
48614846
if (!getLangOpts().CPlusPlus && InitList) {
4862-
Diag(Init->getBeginLoc(), diag::err_auto_init_list_from_c)
4863-
<< (int)AT->getKeyword() << getLangOpts().C23;
4847+
Diag(Init->getBeginLoc(), diag::err_auto_init_list_from_c);
48644848
return TDK_AlreadyDiagnosed;
48654849
}
48664850

clang/lib/Sema/SemaType.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9880,14 +9880,11 @@ QualType Sema::BuildAtomicType(QualType T, SourceLocation Loc) {
98809880
DisallowedKind = 5;
98819881
else if (T->isSizelessType())
98829882
DisallowedKind = 6;
9883-
else if (!T.isTriviallyCopyableType(Context) && getLangOpts().CPlusPlus)
9883+
else if (!T.isTriviallyCopyableType(Context))
98849884
// Some other non-trivially-copyable type (probably a C++ class)
98859885
DisallowedKind = 7;
98869886
else if (T->isBitIntType())
98879887
DisallowedKind = 8;
9888-
else if (getLangOpts().C23 && T->isUndeducedAutoType())
9889-
// _Atomic auto is prohibited in C23
9890-
DisallowedKind = 9;
98919888

98929889
if (DisallowedKind != -1) {
98939890
Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;

clang/test/C/C2x/n3007.c

Lines changed: 0 additions & 186 deletions
This file was deleted.

clang/test/CodeGen/auto.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)