r177987 - Handle CXXOperatorCallExpr when checking self referrnce during initialization of

Richard Trieu rtrieu at google.com
Mon Mar 25 20:41:40 PDT 2013


Author: rtrieu
Date: Mon Mar 25 22:41:40 2013
New Revision: 177987

URL: http://llvm.org/viewvc/llvm-project?rev=177987&view=rev
Log:
Handle CXXOperatorCallExpr when checking self referrnce during initialization of
class types.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/uninitialized.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=177987&r1=177986&r2=177987&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Mar 25 22:41:40 2013
@@ -7097,6 +7097,14 @@ namespace {
       Visit(Base);
     }
 
+    void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+      if (E->getNumArgs() > 0)
+        if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->getArg(0)))
+          HandleDeclRefExpr(DRE);
+
+      Inherited::VisitCXXOperatorCallExpr(E);
+    }
+
     void VisitUnaryOperator(UnaryOperator *E) {
       // For POD record types, addresses of its own members are well-defined.
       if (E->getOpcode() == UO_AddrOf && isRecordType &&

Modified: cfe/trunk/test/SemaCXX/uninitialized.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/uninitialized.cpp?rev=177987&r1=177986&r2=177987&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/uninitialized.cpp (original)
+++ cfe/trunk/test/SemaCXX/uninitialized.cpp Mon Mar 25 22:41:40 2013
@@ -496,3 +496,18 @@ namespace references {
     int &b;
   };
 }
+
+namespace operators {
+  struct A {
+    A(bool);
+    bool operator==(A);
+  };
+
+  A makeA();
+
+  A a1 = a1 = makeA();  // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}}
+  A a2 = a2 == a1;  // expected-warning{{variable 'a2' is uninitialized when used within its own initialization}}
+  A a3 = a2 == a3;  // expected-warning{{variable 'a3' is uninitialized when used within its own initialization}}
+
+  int x = x = 5;
+}





More information about the cfe-commits mailing list