diff options
| author | Richard Trieu <rtrieu@google.com> | 2014-12-20 02:42:08 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2014-12-20 02:42:08 +0000 |
| commit | d787e8dc9d74011f4d2fa70e5941aad3eeec0f53 (patch) | |
| tree | a2da0cac72a43f442ba04ec94c645c9946b23401 /clang/lib | |
| parent | 113dc64c67b4c56ab0a32835d148600c5fb544e0 (diff) | |
| download | bcm5719-llvm-d787e8dc9d74011f4d2fa70e5941aad3eeec0f53.tar.gz bcm5719-llvm-d787e8dc9d74011f4d2fa70e5941aad3eeec0f53.zip | |
Fix for PR21758
When a non-type template argument expression needs a conversion to change it
into the argument type, preserve that information by remaking the
TemplateArgument with an expression that has those conversions. Also a small
fix to template type diffing to handle the extra conversions in some cases.
llvm-svn: 224667
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTDiagnostic.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 3212359db18..ed823f5537a 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1655,11 +1655,14 @@ class TemplateDiff { } Unbold(); } - + /// HasExtraInfo - Returns true if E is not an integer literal or the /// negation of an integer literal bool HasExtraInfo(Expr *E) { if (!E) return false; + + E = E->IgnoreImpCasts(); + if (isa<IntegerLiteral>(E)) return false; if (UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 67c36a5fb5e..20996492268 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3433,6 +3433,13 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, if (Res.isInvalid()) return true; + // If the resulting expression is new, then use it in place of the + // old expression in the template argument. + if (Res.get() != Arg.getArgument().getAsExpr()) { + TemplateArgument TA(Res.get()); + Arg = TemplateArgumentLoc(TA, Res.get()); + } + Converted.push_back(Result); break; } |

