Treat __extension__ like ParenExpr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116569 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 98f0656..92e7119 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -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;
   }
 }
diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c
index ffc5c83..6015e91 100644
--- a/test/Parser/expressions.c
+++ b/test/Parser/expressions.c
@@ -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;
 }