It appears I have bungled the clang call in the test case header. Oops.
The attached patch rectifies this.
Cheers,
~~ Ondra
Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td (revision 195304)
+++ include/clang/Basic/DiagnosticGroups.td (working copy)
@@ -216,7 +216,7 @@
def : DiagGroup<"nonportable-cfstrings">;
def NonVirtualDtor : DiagGroup<"non-virtual-dtor">;
def OveralignedType : DiagGroup<"over-aligned">;
-def : DiagGroup<"old-style-cast">;
+def OldStyleCast : DiagGroup<"old-style-cast">;
def : DiagGroup<"old-style-definition">;
def OutOfLineDeclaration : DiagGroup<"out-of-line-declaration">;
def : DiagGroup<"overflow">;
Index: include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- include/clang/Basic/DiagnosticParseKinds.td (revision 195304)
+++ include/clang/Basic/DiagnosticParseKinds.td (working copy)
@@ -672,6 +672,8 @@
def warn_cxx98_compat_defaulted_function : Warning<
"defaulted function definitions are incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
+def warn_old_style_cast : Warning<
+ "use of old-style cast">, InGroup<OldStyleCast>, DefaultIgnore;
// C++11 in-class member initialization
def ext_nonstatic_member_init : ExtWarn<
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp (revision 195304)
+++ lib/Parse/ParseExpr.cpp (working copy)
@@ -2171,7 +2171,13 @@
CastTy = Ty.get();
return ExprResult();
}
-
+
+ // Warn about C-style casts when using C++.
+ if (getLangOpts().CPlusPlus) {
+ Diag(OpenLoc, diag::warn_old_style_cast)
+ << SourceRange(OpenLoc, RParenLoc);
+ }
+
// Reject the cast of super idiom in ObjC.
if (Tok.is(tok::identifier) && getLangOpts().ObjC1 &&
Tok.getIdentifierInfo() == Ident_super &&
Index: test/Parser/cxx-old-style-cast.cpp
===================================================================
--- test/Parser/cxx-old-style-cast.cpp (revision 0)
+++ test/Parser/cxx-old-style-cast.cpp (working copy)
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wold-style-cast %s
+
+void test1() {
+ long x = (long)12; // expected-warning {{use of old-style cast}}
+ long y = static_cast<long>(12);
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits