]> granicus.if.org Git - clang/commitdiff
Downgrade the invalid offsetof error to a warning.
authorAnders Carlsson <andersca@mac.com>
Sat, 2 May 2009 17:45:47 +0000 (17:45 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 2 May 2009 17:45:47 +0000 (17:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70634 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/SemaCXX/offsetof.cpp

index 8e9296db165c26265e2467cf0dba13c2ce314060..bee24ad9033fd53720a930a955b7968c14db675c 100644 (file)
@@ -82,6 +82,7 @@ def : DiagGroup<"strict-overflow=1">;
 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">;
index 72689b9523a274e66e87e812de69658d7dd0c790..2900c3d3aa4d3ec348b0bb6c72094c865860a609 100644 (file)
@@ -936,7 +936,8 @@ def err_offsetof_record_type : Error<
 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">,
index 33d308ee3982171545c5e94668e92703a941de04..dc058b2a3a54550d50c31a482d6cbcf301c0ed5e 100644 (file)
@@ -4777,9 +4777,9 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
       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
index 726dc7e5277eedb480971e50bd99b19fa9b2d94b..c8a3d3df45714f3df7a2ab73b2e51444edd9300f 100644 (file)
@@ -10,6 +10,6 @@ struct P {
 };
 
 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'}}
 }