We know that const_cast<char *>((void)Something) is ill-formed, even if
'Something' is dependent because you can't cast from void to a pointer
type.
This fixes PR21845.
llvm-svn: 224299
QualType DestType = DestTInfo->getType();
// If the type is dependent, we won't do the semantic analysis now.
- // FIXME: should we check this in a more fine-grained manner?
- bool TypeDependent = DestType->isDependentType() ||
- Ex.get()->isTypeDependent() ||
- Ex.get()->isValueDependent();
+ bool TypeDependent =
+ DestType->isDependentType() || Ex.get()->isTypeDependent();
CastOperation Op(*this, DestType, E);
Op.OpRange = SourceRange(OpLoc, Parens.getEnd());
(void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}} expected-warning {{C++11}}
return **var3;
}
+
+template <typename T>
+char *PR21845() { return const_cast<char *>((void)T::x); } // expected-error {{const_cast from 'void' to 'char *' is not allowed}}