]> granicus.if.org Git - clang/commitdiff
Merging r227368:
authorHans Wennborg <hans@hanshq.net>
Wed, 28 Jan 2015 21:59:15 +0000 (21:59 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 28 Jan 2015 21:59:15 +0000 (21:59 +0000)
------------------------------------------------------------------------
r227368 | rikka | 2015-01-28 13:10:46 -0800 (Wed, 28 Jan 2015) | 9 lines

Revert a change from r222797 that is no longer needed and can cause
infinite recursion.

Also guard against said infinite recursion by adding an assert that will
trigger if CorrectDelayedTyposInExpr is called before a previous call to
CorrectDelayedTyposInExpr returns (i.e. if the TreeTransform run by
CorrectDelayedTyposInExpr calls a sequence of methods that
end up calling CorrectDelayedTyposInExpr, as the new test case had done
prior to this commit). Fixes PR22292.
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_36@227375 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
test/SemaCXX/typo-correction-delayed.cpp

index 93b4c30871fc687bd1181009571c129766cbfe41..091fd27db85ddb838023f275c045b3264a3dafd0 100644 (file)
@@ -4762,12 +4762,8 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
                                      VK_RValue, RParenLoc);
 
   // Bail out early if calling a builtin with custom typechecking.
-  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
-    ExprResult Res = CorrectDelayedTyposInExpr(TheCall);
-    if (!Res.isUsable() || !isa<CallExpr>(Res.get()))
-      return Res;
-    return CheckBuiltinFunctionCall(FDecl, BuiltinID, cast<CallExpr>(Res.get()));
-  }
+  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID))
+    return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
 
  retry:
   const FunctionType *FuncT;
index ca155507685a2ffef4c30a5a1a40efc58af73e86..3e2a2de5b4061e014fe07eb2734da7990cfc5c6d 100644 (file)
@@ -6232,8 +6232,12 @@ ExprResult Sema::CorrectDelayedTyposInExpr(
   if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
       (E->isTypeDependent() || E->isValueDependent() ||
        E->isInstantiationDependent())) {
+    auto TyposInContext = ExprEvalContexts.back().NumTypos;
+    assert(TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr");
+    ExprEvalContexts.back().NumTypos = ~0U;
     auto TyposResolved = DelayedTypos.size();
     auto Result = TransformTypos(*this, Filter).Transform(E);
+    ExprEvalContexts.back().NumTypos = TyposInContext;
     TyposResolved -= DelayedTypos.size();
     if (Result.isInvalid() || Result.get() != E) {
       ExprEvalContexts.back().NumTypos -= TyposResolved;
index a73a5dc809435cc80cb144ed3b6ce83c89ecfc85..79ab3f597954a7d5d6a7da3b7b15bdb8f3fdc1f6 100644 (file)
@@ -166,6 +166,14 @@ namespace PR22250 {
 int getenv_s(size_t *y, char(&z)) {}
 }
 
+namespace PR22291 {
+template <unsigned I> void f() {
+  unsigned *prio_bits_array;  // expected-note {{'prio_bits_array' declared here}}
+  // expected-error@+1 {{use of undeclared identifier 'prio_op_array'; did you mean 'prio_bits_array'?}}
+  __atomic_store_n(prio_op_array + I, false, __ATOMIC_RELAXED);
+}
+}
+
 namespace PR22297 {
 double pow(double x, double y);
 struct TimeTicks {