summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-02 17:45:47 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-02 17:45:47 +0000
commit8b98d02976dd7ae8d06bfb4d7ac06968f3953068 (patch)
tree3abce45cecad29967f6007ae8f334b58009163e6
parentf150572af72f108fd727d11c0b4641a618fc57d4 (diff)
downloadbcm5719-llvm-8b98d02976dd7ae8d06bfb4d7ac06968f3953068.tar.gz
bcm5719-llvm-8b98d02976dd7ae8d06bfb4d7ac06968f3953068.zip
Downgrade the invalid offsetof error to a warning.
llvm-svn: 70634
-rw-r--r--clang/include/clang/Basic/DiagnosticGroups.td1
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--clang/lib/Sema/SemaExpr.cpp6
-rw-r--r--clang/test/SemaCXX/offsetof.cpp2
4 files changed, 7 insertions, 5 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 8e9296db165..bee24ad9033 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -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">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 72689b9523a..2900c3d3aa4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 33d308ee398..dc058b2a3a5 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index 726dc7e5277..c8a3d3df457 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -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'}}
}
OpenPOWER on IntegriCloud