[flang-commits] [flang] 044a71d - [flang] Don't attempt to compute element size if no DynamicType

Tim Keith via flang-commits flang-commits at lists.llvm.org
Mon Aug 24 18:23:50 PDT 2020


Author: Tim Keith
Date: 2020-08-24T18:20:24-07:00
New Revision: 044a71d828cab57b9aefd402105960959a4e2c0e

URL: https://github.com/llvm/llvm-project/commit/044a71d828cab57b9aefd402105960959a4e2c0e
DIFF: https://github.com/llvm/llvm-project/commit/044a71d828cab57b9aefd402105960959a4e2c0e.diff

LOG: [flang] Don't attempt to compute element size if no DynamicType

If an error has occurred a symbol may have a DeclTypeSpec but no
valid DynamicType. There is no need to compute the size of erroneous
symbols.

Also, we only need to process object entities and procedure entities.
All other kinds of symbols can be skipped.

This fixes another problem revealed by https://bugs.llvm.org/show_bug.cgi?id=47265

Differential Revision: https://reviews.llvm.org/D86484

Added: 
    

Modified: 
    flang/lib/Semantics/compute-offsets.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/compute-offsets.cpp b/flang/lib/Semantics/compute-offsets.cpp
index a927f094afa8..f2a3a10bb4fa 100644
--- a/flang/lib/Semantics/compute-offsets.cpp
+++ b/flang/lib/Semantics/compute-offsets.cpp
@@ -295,9 +295,8 @@ std::size_t ComputeOffsetsHelper::ComputeOffset(
 }
 
 void ComputeOffsetsHelper::DoSymbol(Symbol &symbol) {
-  if (symbol.has<TypeParamDetails>() || symbol.has<SubprogramDetails>() ||
-      symbol.has<UseDetails>() || symbol.has<ProcBindingDetails>()) {
-    return; // these have type but no size
+  if (!symbol.has<ObjectEntityDetails>() && !symbol.has<ProcEntityDetails>()) {
+    return;
   }
   SizeAndAlignment s{GetSizeAndAlignment(symbol)};
   if (s.size == 0) {
@@ -324,7 +323,7 @@ auto ComputeOffsetsHelper::GetSizeAndAlignment(const Symbol &symbol)
 auto ComputeOffsetsHelper::GetElementSize(const Symbol &symbol)
     -> SizeAndAlignment {
   const DeclTypeSpec *type{symbol.GetType()};
-  if (!type) {
+  if (!evaluate::DynamicType::From(type).has_value()) {
     return {};
   }
   // TODO: The size of procedure pointers is not yet known


        


More information about the flang-commits mailing list