https://bugs.llvm.org/show_bug.cgi?id=35957

            Bug ID: 35957
           Summary: When declaring variable with __auto_type, name should
                    not be in scope until after initializer
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: oliver.klei...@c-01a.de
                CC: llvm-bugs@lists.llvm.org

Created attachment 19679
  --> https://bugs.llvm.org/attachment.cgi?id=19679&action=edit
example program code

When declaring a variable with __auto_type and initializing it with a variable
in an outer scope, having the same name, clang fails with

"error: variable 'var' declared with deduced type '__auto_type' cannot appear
in its own initializer"

The GCC docs (https://gcc.gnu.org/onlinedocs/gcc/Typeof.html, at bottom) state
that "[..]the name of the variable is not in scope until after the
initializer."

Note that GCC behaviour is similar to a variable declaration with a standard
type-specifier. I attach a small example that demonstrates both cases.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to