[cfe-commits] r168521 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/Sema/SemaOverload.cpp test/SemaTemplate/default-expr-arguments.cpp

Benjamin Kramer benny.kra at gmail.com
Fri Nov 23 11:47:26 PST 2012


On 23.11.2012, at 18:04, Benjamin Kramer <benny.kra at googlemail.com> wrote:

> Author: d0k
> Date: Fri Nov 23 11:04:52 2012
> New Revision: 168521
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=168521&view=rev
> Log:
> Sema: Provide a valid source location when instantiating templates based on a CXXDefaultArgExpr.
> 
> Fixes PR13758.
> 
> Modified:
>    cfe/trunk/include/clang/AST/ExprCXX.h
>    cfe/trunk/lib/Sema/SemaOverload.cpp
>    cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
> 
> Modified: cfe/trunk/include/clang/AST/ExprCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=168521&r1=168520&r2=168521&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/ExprCXX.h (original)
> +++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Nov 23 11:04:52 2012
> @@ -795,6 +795,8 @@
>     return SourceRange();
>   }
> 
> +  SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
> +
>   static bool classof(const Stmt *T) {
>     return T->getStmtClass() == CXXDefaultArgExprClass;
>   }
> 
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=168521&r1=168520&r2=168521&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Nov 23 11:04:52 2012
> @@ -2980,7 +2980,7 @@
>          S.IsDerivedFrom(From->getType(), ToType)))
>       ConstructorsOnly = true;
> 
> -    S.RequireCompleteType(From->getLocStart(), ToType, 0);
> +    S.RequireCompleteType(From->getExprLoc(), ToType, 0);
>     // RequireCompleteType may have returned true due to some invalid decl
>     // during template instantiation, but ToType may be complete enough now
>     // to try to recover.
> 
> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp?rev=168521&r1=168520&r2=168521&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp Fri Nov 23 11:04:52 2012
> @@ -303,3 +303,21 @@
>   {
>   }
> }
> +
> +namespace PR13758 {
> +  template <typename T> struct move_from {
> +    T invalid; // expected-error {{field has incomplete type 'void'}}
> +  };
> +  template <class K>
> +  struct unordered_map {
> +    explicit unordered_map(int n = 42);
> +    unordered_map(move_from<K> other);
> +  };
> +  template<typename T>
> +  void StripedHashTable() {
> +    new unordered_map<void>(); // expected-note {{in instantiation of template class 'PR13758::move_from<void>' requested here}}
> +  }
> +  void tt() {
> +    StripedHashTable<int>(); // expected-note {{in instantiation of function template specialization 'PR13758::StripedHashTable<int>' requested here}}
> +  }
> +}

Looking closer at the test case, I don't see why it instantiates move_from<void> at that point. GCC and EDG accept the code, maybe there is another clang bug here. Any ideas?

- Ben



More information about the cfe-commits mailing list