diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-05-01 06:05:57 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-05-01 06:05:57 +0000 |
commit | 7afed5e5bf340d6716413acf82ff52f66f77b56b (patch) | |
tree | ac996c4381c9ce3cf6c6174b736627b83a66e384 /clang/lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 124066c5cb73cf2e47d542371df125ff885a1c29 (diff) | |
download | bcm5719-llvm-7afed5e5bf340d6716413acf82ff52f66f77b56b.tar.gz bcm5719-llvm-7afed5e5bf340d6716413acf82ff52f66f77b56b.zip |
PR12710 - broken default argument handling for templates.
I broke this in r155838 by not actually instantiating non-dependent default arg
expressions. The motivation for that change was to avoid producing duplicate
conversion warnings for such default args (we produce them once when we parse
the template - there's no need to produce them at each instantiation) but
without actually instantiating the default arg, things break in weird ways.
Technically, I think we could still get the right diagnostic experience without
the bugs if we instantiated the non-dependent args (for non-dependent params
only) immediately, rather than lazily. But I'm not sure if such a refactoring/
change would be desirable so here's the conservative fix for now.
llvm-svn: 155893
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 3635e64f3d0..344af6097d8 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1594,13 +1594,11 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, } else if (OldParm->hasUnparsedDefaultArg()) { NewParm->setUnparsedDefaultArg(); UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm); - } else if (Expr *Arg = OldParm->getDefaultArg()) { - if (Arg->isInstantiationDependent() || - OldDI->getType()->isInstantiationDependentType()) - NewParm->setUninstantiatedDefaultArg(Arg); - else - NewParm->setDefaultArg(Arg); - } + } else if (Expr *Arg = OldParm->getDefaultArg()) + // FIXME: if we non-lazily instantiated non-dependent default args for + // non-dependent parameter types we could remove a bunch of duplicate + // conversion warnings for such arguments. + NewParm->setUninstantiatedDefaultArg(Arg); NewParm->setHasInheritedDefaultArg(OldParm->hasInheritedDefaultArg()); |