]> granicus.if.org Git - clang/commitdiff
Fix a thinko and a test.
authorAnders Carlsson <andersca@mac.com>
Sat, 2 May 2009 18:36:10 +0000 (18:36 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 2 May 2009 18:36:10 +0000 (18:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70637 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/offsetof.cpp

index dc058b2a3a54550d50c31a482d6cbcf301c0ed5e..2986cc366a8d81caf8c41f624d1aecbc0fc1a771 100644 (file)
@@ -4734,6 +4734,8 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
       << SourceRange(CompPtr[1].LocStart, CompPtr[NumComponents-1].LocEnd);
 
   if (!Dependent) {
+    bool DidWarnAboutNonPOD;
+    
     // FIXME: Dependent case loses a lot of information here. And probably
     // leaks like a sieve.
     for (unsigned i = 0; i != NumComponents; ++i) {
@@ -4776,10 +4778,12 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
       // Get the decl corresponding to this.
       RecordDecl *RD = RC->getDecl();
       if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
-        if (!CRD->isPOD())
+        if (!CRD->isPOD() && !DidWarnAboutNonPOD) {
           ExprError(Diag(BuiltinLoc, diag::warn_offsetof_non_pod_type)
             << SourceRange(CompPtr[0].LocStart, OC.LocEnd)
             << Res->getType());
+          DidWarnAboutNonPOD = true;
+        }
       }
       
       FieldDecl *MemberDecl
index c8a3d3df45714f3df7a2ab73b2e51444edd9300f..f0290e889a298f9ba4195404b1372acd6d016564 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify %s -Winvalid-offsetof
 
 struct NonPOD {
   virtual void f();