]> granicus.if.org Git - clang/commitdiff
More gracefully handle parentheses in templare arguments in template diffing.
authorRichard Trieu <rtrieu@google.com>
Tue, 22 Jul 2014 04:06:54 +0000 (04:06 +0000)
committerRichard Trieu <rtrieu@google.com>
Tue, 22 Jul 2014 04:06:54 +0000 (04:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213611 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTDiagnostic.cpp
test/Misc/diag-template-diffing.cpp

index 15e288acb9a30781ca831f64bc2072c8df880dd4..20540f3ce128a23a06c18d4124267268fb38d3a2 100644 (file)
@@ -1184,7 +1184,8 @@ class TemplateDiff {
       }
     DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr);
     if (!DRE) {
-      DRE = cast<DeclRefExpr>(cast<UnaryOperator>(ArgExpr)->getSubExpr());
+      DRE = cast<DeclRefExpr>(
+          cast<UnaryOperator>(ArgExpr->IgnoreParens())->getSubExpr());
     }
 
     return DRE->getDecl();
index 41cdca47126ae45b51136d9e44229f2c8d937465..391915ee970e1f7bf7d5eece987f59872ffaa6c6 100644 (file)
@@ -1114,11 +1114,15 @@ struct Wrapper {};
 
 template <class T>
 Wrapper<T> MakeWrapper();
-int global;
+int global, global2;
 constexpr int * ptr = nullptr;
 Wrapper<S<ptr>> W = MakeWrapper<S<&global>>();
 // Don't print an extra '&' for 'ptr'
 // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr>>'
+
+Wrapper<S<(&global2)>> W2 = MakeWrapper<S<&global>>();
+// Handle parens correctly
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<global2>>'
 }
 
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.