[cfe-commits] r116569 - in /cfe/trunk: lib/AST/Expr.cpp test/Parser/expressions.c

Abramo Bagnara abramo.bagnara at gmail.com
Fri Oct 15 00:51:18 PDT 2010


Author: abramo
Date: Fri Oct 15 02:51:18 2010
New Revision: 116569

URL: http://llvm.org/viewvc/llvm-project?rev=116569&view=rev
Log:
Treat __extension__ like ParenExpr.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/test/Parser/expressions.c

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=116569&r1=116568&r2=116569&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Oct 15 02:51:18 2010
@@ -1554,10 +1554,19 @@
 
 Expr* Expr::IgnoreParens() {
   Expr* E = this;
-  while (ParenExpr* P = dyn_cast<ParenExpr>(E))
-    E = P->getSubExpr();
-
-  return E;
+  while (true) {
+    if (ParenExpr* P = dyn_cast<ParenExpr>(E)) {
+      E = P->getSubExpr();
+      continue;
+    }
+    if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) {
+      if (P->getOpcode() == UO_Extension) {
+        E = P->getSubExpr();
+        continue;
+      }
+    }
+    return E;
+  }
 }
 
 /// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any ParenExpr
@@ -1565,24 +1574,42 @@
 Expr *Expr::IgnoreParenCasts() {
   Expr *E = this;
   while (true) {
-    if (ParenExpr *P = dyn_cast<ParenExpr>(E))
+    if (ParenExpr* P = dyn_cast<ParenExpr>(E)) {
       E = P->getSubExpr();
-    else if (CastExpr *P = dyn_cast<CastExpr>(E))
+      continue;
+    }
+    if (CastExpr *P = dyn_cast<CastExpr>(E)) {
       E = P->getSubExpr();
-    else
-      return E;
+      continue;
+    }
+    if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) {
+      if (P->getOpcode() == UO_Extension) {
+        E = P->getSubExpr();
+        continue;
+      }
+    }
+    return E;
   }
 }
 
 Expr *Expr::IgnoreParenImpCasts() {
   Expr *E = this;
   while (true) {
-    if (ParenExpr *P = dyn_cast<ParenExpr>(E))
+    if (ParenExpr *P = dyn_cast<ParenExpr>(E)) {
       E = P->getSubExpr();
-    else if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E))
+      continue;
+    }
+    if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E)) {
       E = P->getSubExpr();
-    else
-      return E;
+      continue;
+    }
+    if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) {
+      if (P->getOpcode() == UO_Extension) {
+        E = P->getSubExpr();
+        continue;
+      }
+    }
+    return E;
   }
 }
 
@@ -1607,9 +1634,9 @@
         continue;
       }
 
-      if ((E->getType()->isPointerType() || 
+      if ((E->getType()->isPointerType() ||
            E->getType()->isIntegralType(Ctx)) &&
-          (SE->getType()->isPointerType() || 
+          (SE->getType()->isPointerType() ||
            SE->getType()->isIntegralType(Ctx)) &&
           Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SE->getType())) {
         E = SE;
@@ -1617,6 +1644,13 @@
       }
     }
 
+    if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) {
+      if (P->getOpcode() == UO_Extension) {
+        E = P->getSubExpr();
+        continue;
+      }
+    }
+
     return E;
   }
 }

Modified: cfe/trunk/test/Parser/expressions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/expressions.c?rev=116569&r1=116568&r2=116569&view=diff
==============================================================================
--- cfe/trunk/test/Parser/expressions.c (original)
+++ cfe/trunk/test/Parser/expressions.c Fri Oct 15 02:51:18 2010
@@ -39,7 +39,8 @@
 
 // PR3418
 int test_leading_extension() {
-  __extension__ (*(char*)0) = 1;
+  __extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \
+                                 // expected-note {{consider using __builtin_trap}}
   return 0;
 }
 





More information about the cfe-commits mailing list