Make the "too many braces in scalar initialization" extension cause

SFINAE failures.

llvm-svn: 349820
This commit is contained in:
Richard Smith 2018-12-20 20:58:53 +00:00
parent b3c56af49b
commit 0a90d7c92b
2 changed files with 24 additions and 1 deletions

View File

@ -4880,7 +4880,7 @@ def warn_braces_around_scalar_init : Warning<
"braces around scalar initializer">, InGroup<DiagGroup<"braced-scalar-init">>;
def ext_many_braces_around_scalar_init : ExtWarn<
"too many braces around scalar initializer">,
InGroup<DiagGroup<"many-braces-around-scalar-init">>;
InGroup<DiagGroup<"many-braces-around-scalar-init">>, SFINAEFailure;
def ext_complex_component_init : Extension<
"complex initialization specifying real and imaginary components "
"is an extension">, InGroup<DiagGroup<"complex-component-init">>;

View File

@ -127,3 +127,26 @@ namespace PR12118 {
static_assert(sizeof(f({0})) == sizeof(one), "bad overload");
}
}
namespace excess_braces_sfinae {
using valid = int&;
using invalid = float&;
template<typename T> valid braces1(decltype(T{0})*);
template<typename T> invalid braces1(...);
template<typename T> valid braces2(decltype(T{{0}})*);
template<typename T> invalid braces2(...);
template<typename T> valid braces3(decltype(T{{{0}}})*);
template<typename T> invalid braces3(...);
valid a = braces1<int>(0);
invalid b = braces2<int>(0);
invalid c = braces3<int>(0);
struct X { int n; };
valid d = braces1<X>(0);
valid e = braces2<X>(0);
invalid f = braces3<X>(0);
}