[cfe-commits] r70634 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaCXX/offsetof.cpp
Anders Carlsson
andersca at mac.com
Sat May 2 10:45:48 PDT 2009
Author: andersca
Date: Sat May 2 12:45:47 2009
New Revision: 70634
URL: http://llvm.org/viewvc/llvm-project?rev=70634&view=rev
Log:
Downgrade the invalid offsetof error to a warning.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/offsetof.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=70634&r1=70633&r2=70634&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sat May 2 12:45:47 2009
@@ -82,6 +82,7 @@
def : DiagGroup<"strict-overflow=2">;
def : DiagGroup<"strict-overflow">;
+def InvalidOffsetof : DiagGroup<"invalid-offsetof">;
def : DiagGroup<"strict-prototypes">;
def : DiagGroup<"strict-selector-match">;
def Switch : DiagGroup<"switch">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=70634&r1=70633&r2=70634&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat May 2 12:45:47 2009
@@ -936,7 +936,8 @@
def err_offsetof_array_type : Error<"offsetof requires array type, %0 invalid">;
def ext_offsetof_extended_field_designator : Extension<
"using extended field designator is an extension">;
-def err_offsetof_non_pod_type : Error<"offset of on non-POD type %0">;
+def warn_offsetof_non_pod_type : Warning<"offset of on non-POD type %0">,
+ InGroup<InvalidOffsetof>;
def warn_floatingpoint_eq : Warning<
"comparing floating point with == or != is unsafe">,
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=70634&r1=70633&r2=70634&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat May 2 12:45:47 2009
@@ -4777,9 +4777,9 @@
RecordDecl *RD = RC->getDecl();
if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
if (!CRD->isPOD())
- return ExprError(Diag(BuiltinLoc, diag::err_offsetof_non_pod_type)
- << SourceRange(CompPtr[0].LocStart, OC.LocEnd)
- << Res->getType());
+ ExprError(Diag(BuiltinLoc, diag::warn_offsetof_non_pod_type)
+ << SourceRange(CompPtr[0].LocStart, OC.LocEnd)
+ << Res->getType());
}
FieldDecl *MemberDecl
Modified: cfe/trunk/test/SemaCXX/offsetof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/offsetof.cpp?rev=70634&r1=70633&r2=70634&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/offsetof.cpp (original)
+++ cfe/trunk/test/SemaCXX/offsetof.cpp Sat May 2 12:45:47 2009
@@ -10,6 +10,6 @@
};
void f() {
- int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-error{{offset of on non-POD type 'struct P'}}
+ int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'struct P'}}
}
More information about the cfe-commits
mailing list