diff options
author | Mark de Wever <koraq@xs4all.nl> | 2020-10-03 14:31:46 +0200 |
---|---|---|
committer | Mark de Wever <koraq@xs4all.nl> | 2020-10-03 14:33:28 +0200 |
commit | 0ce6d6b46eb7040283ad0800c5533672fbfb9bac (patch) | |
tree | e9f34f50667b6c8f5a1d41fd7cc06f0bae3301b6 /clang/lib/Sema/SemaInit.cpp | |
parent | 49e34e239b3632bd26d6c2ac648915bfed5b05fc (diff) | |
download | llvm-0ce6d6b46eb7040283ad0800c5533672fbfb9bac.zip llvm-0ce6d6b46eb7040283ad0800c5533672fbfb9bac.tar.gz llvm-0ce6d6b46eb7040283ad0800c5533672fbfb9bac.tar.bz2 |
[Sema] List conversion validate character array.
The function `TryListConversion` didn't properly validate the following
part of the standard:
Otherwise, if the parameter type is a character array [... ]
and the initializer list has a single element that is an
appropriately-typed string literal (8.5.2 [dcl.init.string]), the
implicit conversion sequence is the identity conversion.
This caused the following call to `f()` to be ambiguous.
void f(int(&&)[1]);
void f(unsigned(&&)[1]);
void g(unsigned i) {
f({i});
}
This issue only occurs when the initializer list had one element.
Differential Revision: https://reviews.llvm.org/D87561
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index a9f707b..751b785 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -141,6 +141,10 @@ static StringInitFailureKind IsStringInit(Expr *init, QualType declType, return IsStringInit(init, arrayType, Context); } +bool Sema::IsStringInit(Expr *Init, const ArrayType *AT) { + return ::IsStringInit(Init, AT, Context) == SIF_None; +} + /// Update the type of a string literal, including any surrounding parentheses, /// to match the type of the object which it is initializing. static void updateStringLiteralType(Expr *E, QualType Ty) { |