]> granicus.if.org Git - clang/commitdiff
Don't crash with -Wlarge-by-value-copy and a dependent type. PR11726.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 9 Jan 2012 23:46:59 +0000 (23:46 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 9 Jan 2012 23:46:59 +0000 (23:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147812 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/warn-large-by-value-copy.cpp

index b541e7d9e717a47b3763aa5e8757e8958b796470..4a804bfcff2828abe5eed7b5198f78c8f16a4100 100644 (file)
@@ -6777,7 +6777,7 @@ void Sema::DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Param,
 
   // Warn if the return value is pass-by-value and larger than the specified
   // threshold.
-  if (ReturnTy.isPODType(Context)) {
+  if (!ReturnTy->isDependentType() && ReturnTy.isPODType(Context)) {
     unsigned Size = Context.getTypeSizeInChars(ReturnTy).getQuantity();
     if (Size > LangOpts.NumLargeByValueCopy)
       Diag(D->getLocation(), diag::warn_return_value_size)
@@ -6788,7 +6788,7 @@ void Sema::DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Param,
   // threshold.
   for (; Param != ParamEnd; ++Param) {
     QualType T = (*Param)->getType();
-    if (!T.isPODType(Context))
+    if (T->isDependentType() || !T.isPODType(Context))
       continue;
     unsigned Size = Context.getTypeSizeInChars(T).getQuantity();
     if (Size > LangOpts.NumLargeByValueCopy)
index 39dbd7697d26bbfec264d3304f43a61d18c76718..3e419ec08f075ad992b164cbb06c8cd5a93a7025 100644 (file)
@@ -40,3 +40,8 @@ void g() {
 }
 
 }
+
+template<typename T> class DependentPOD {
+  enum b { x };
+  b foo() { return x; }
+};