DiagGroup<"float-conversion", [FloatOverflowConversion,
FloatZeroConversion]>;
+def FrameAddress : DiagGroup<"frame-address">;
def DoublePromotion : DiagGroup<"double-promotion">;
def EnumTooLarge : DiagGroup<"enum-too-large">;
def UnsupportedNan : DiagGroup<"unsupported-nan">;
DeleteNonVirtualDtor,
Format,
ForLoopAnalysis,
+ FrameAddress,
Implicit,
InfiniteRecursion,
IntInBoolContext,
def err_illegal_union_or_anon_struct_member : Error<
"%select{anonymous struct|union}0 member %1 has a non-trivial "
"%sub{select_special_member_kind}2">;
+
+def warn_frame_address : Warning<
+ "calling '%0' with a nonzero argument is unsafe">,
+ InGroup<FrameAddress>, DefaultIgnore;
+
def warn_cxx98_compat_nontrivial_union_or_anon_struct_member : Warning<
"%select{anonymous struct|union}0 member %1 with a non-trivial "
"%sub{select_special_member_kind}2 is incompatible with C++98">,
case Builtin::BI__builtin_return_address:
if (SemaBuiltinConstantArgRange(TheCall, 0, 0, 0xFFFF))
return ExprError();
+
+ // -Wframe-address warning if non-zero passed to builtin
+ // return/frame address.
+ Expr::EvalResult Result;
+ if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
+ Result.Val.getInt() != 0)
+ Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
+ << ((BuiltinID == Builtin::BI__builtin_return_address)
+ ? "__builtin_return_address"
+ : "__builtin_frame_address")
+ << TheCall->getSourceRange();
break;
}
CHECK-NEXT: -Wformat-y2k
CHECK-NEXT: -Wformat-invalid-specifier
CHECK-NEXT: -Wfor-loop-analysis
+CHECK-NEXT: -Wframe-address
CHECK-NEXT: -Wimplicit
CHECK-NEXT: -Wimplicit-function-declaration
CHECK-NEXT: -Wimplicit-int