def err_expr_not_cce : Error<
"%select{case value|enumerator value|non-type template argument}0 "
"is not a constant expression">;
-def err_cce_narrowing : Error<
+def err_cce_narrowing : ExtWarn<
+ "%select{case value|enumerator value|non-type template argument}0 "
+ "%select{cannot be narrowed from type %2 to %3|"
+ "evaluates to %2, which cannot be narrowed to type %3}1">,
+ InGroup<CXX11Narrowing>, DefaultError;
+def err_cce_narrowing_sfinae : Error<
"%select{case value|enumerator value|non-type template argument}0 "
"%select{cannot be narrowed from type %2 to %3|"
"evaluates to %2, which cannot be narrowed to type %3}1">;
def err_illegal_initializer_type : Error<"illegal initializer type %0">;
def err_init_list_type_narrowing_sfinae : Error<
"type %0 cannot be narrowed to %1 in initializer list">;
-def err_init_list_type_narrowing : Warning<
+def err_init_list_type_narrowing : ExtWarn<
"type %0 cannot be narrowed to %1 in initializer list">,
InGroup<CXX11Narrowing>, DefaultError;
def err_init_list_variable_narrowing_sfinae : Error<
"non-constant-expression cannot be narrowed from type %0 to %1 in "
"initializer list">;
-def err_init_list_variable_narrowing : Warning<
+def err_init_list_variable_narrowing : ExtWarn<
"non-constant-expression cannot be narrowed from type %0 to %1 in "
"initializer list">, InGroup<CXX11Narrowing>, DefaultError;
def err_init_list_constant_narrowing_sfinae : Error<
"constant expression evaluates to %0 which cannot be narrowed to type %1">;
-def err_init_list_constant_narrowing : Warning<
+def err_init_list_constant_narrowing : ExtWarn<
"constant expression evaluates to %0 which cannot be narrowed to type %1">,
InGroup<CXX11Narrowing>, DefaultError;
def warn_init_list_type_narrowing : Warning<
// Check for a narrowing implicit conversion.
APValue PreNarrowingValue;
QualType PreNarrowingType;
- bool Diagnosed = false;
switch (SCS->getNarrowingKind(Context, Result.get(), PreNarrowingValue,
PreNarrowingType)) {
case NK_Variable_Narrowing:
break;
case NK_Constant_Narrowing:
- Diag(From->getLocStart(), diag::err_cce_narrowing)
+ Diag(From->getLocStart(),
+ isSFINAEContext() ? diag::err_cce_narrowing_sfinae :
+ diag::err_cce_narrowing)
<< CCE << /*Constant*/1
<< PreNarrowingValue.getAsString(Context, PreNarrowingType) << T;
- Diagnosed = true;
break;
case NK_Type_Narrowing:
- Diag(From->getLocStart(), diag::err_cce_narrowing)
+ Diag(From->getLocStart(),
+ isSFINAEContext() ? diag::err_cce_narrowing_sfinae :
+ diag::err_cce_narrowing)
<< CCE << /*Constant*/0 << From->getType() << T;
- Diagnosed = true;
break;
}
}
}
- // Only issue one narrowing diagnostic.
- if (Diagnosed)
- return Result;
-
// It's not a constant expression. Produce an appropriate diagnostic.
if (Notes.size() == 1 &&
Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)